ibisPaint post to HatenaHaiku

  • /*
     * @title ibisPaint post to HatenaHaiku
     * @description Add post to HatenaHaiku Button on ibisPaint
     * @include http://ibispaint.com/art/*
     * @license MIT License
     * @require http://code.jquery.com/jquery-1.6.4.min.js
     */
    
    (function() {
      // prepare
      var metaTitle = $("meta[property='og:title']").attr('content')
      var metaUrl = $("meta[property='og:url']").attr('content')
      var metaDescription = $("meta[property='og:description']").attr('content')
      var metaImage = $("meta[property='og:image']").attr('content')
      var youtubeUrl = $('.youtube-player')[0].src;
    
      // insert comment area
      var addHtml = '<div>' +
                    '<textarea id="haiku_post_text"></textarea>' +
                    '<img id="post2haikubutton" src="http://h.hatena.ne.jp/images/haiku-button.png"/>' +
                    '</div>';
      var commArea = $('.comment-area-start')
      $(commArea).html(addHtml + $(commArea).html());
    
      // insert template text
      $('#haiku_post_text')[0].value = [
        '[' + metaUrl +':title=' + metaTitle.replace(/ - ibisPaint$/, '') + ']',
        metaDescription,
        metaImage.replace(/s\.png$/, '.png'),
        youtubeUrl.replace(/\?.*$/, '').replace(/embed\//, 'watch?v='),
        "",
        "This post was created by [http://let.hatelabo.jp/fumokmm/let/gYC-xOHJr9_RKg:title=bookmarklet]."
      ].join('\n')
    
      // bind onClick event
      $('#post2haikubutton').bind('click', function() {
        var BR = '%0a';
        var keyword = 'http://ibispaint.com/'; // URL keyword.
        var body = $('#haiku_post_text')[0].value.replace(/\n/g, BR);
        var postUrl = 'http://h.hatena.ne.jp/?_charset_=utf-8&amp;body=' + body + '&amp;word=' + keyword;
        window.open(postUrl, '_blank', '');
      });
    
    })();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2011/11/03 02:18:14 - 2011-11-03
  2. 2011/10/29 09:56:02 - 2011-10-29
  3. 2011/10/16 20:58:32 - 2011-10-16
  4. 2011/10/16 20:55:14 - 2011-10-16