twitter_dout

Twitter にダウトボタンを追加するスクリプト

当前为 2015-03-31 提交的版本,查看 最新版本

// ==UserScript==
// @name        twitter_dout
// @namespace   elzup.com
// @include     https://twitter.com/*
// @require     http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js
// @version     1
// @description Twitter にダウトボタンを追加するスクリプト
// @grant       none
// ==/UserScript==
$(function() {

    addButton();
    // 追加読み込みの監視
    $('#stream-items-id').bind('AutoPagerize_DOMNodeInserted', function(event) {
        addButton();
    });
});

function addButton() {
    $('.ProfileTweet-action.ProfileTweet-action--more').each(function() {
        $(this).next().hasClass('ProfileTweet-action--dout')
        if ($(this).next().hasClass('ProfileTweet-action--dout')) {
            console.log('skip');
            return;
        }
        var sn = $(this).parents('.content').find('.username.js-action-profile-name>b').html();
        var tweet_id = $(this).parents('li.js-stream-item').attr('data-item-id');
//        var link = 'http://twitter.com/a/status/' + $(this).parents('li.js-stream-item').attr('data-item-id');
        var $btn_div = $('<div/>').addClass('ProfileTweet-action ProfileTweet-action--dout').append(
            $('<a/>').attr('href', 'https://twitter.com/intent/tweet?text=@' + sn + ' %E3%83%80%E3%82%A6%E3%83%88%EF%BC%81&in_reply_to=' + tweet_id).attr('target', '_blank').append(
                $('<span/>').addClass('Icon Icon--reply')
            )
        );
        $(this).after($btn_div);
    });
}