_Ex Add button Read in Pocket [getpocket.com]

add button "Read in Pocket" to panel

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         _Ex Add button Read in Pocket [getpocket.com]
// @version      0.2
// @namespace    132-421-129
// @description  add button "Read in Pocket" to panel
// @author       Vyacheslav Vasiliev
// @include      http://getpocket.com/a/*
// @include      https://getpocket.com/a/*
// @grant        none
// @run-at       document-end
// ==/UserScript==


window.event_for_read_in_pocket = true;
$(document).on('DOMNodeInserted', function () {
    if(window.event_for_read_in_pocket){
        window.event_for_read_in_pocket = false;
        console.log('+ change');
        var tmp_button = '<a class="read_in_pocket" href="/a/read/%ID_PAGE%" target="_blank" style="\
            position: absolute;\
            padding: 5px 10px;\
            right: 2em;\
            bottom: 0.5em;\
            background-color: #a5a5a5;\
            color: white;\
            border-radius: 5px;\
            z-index: 999;\
            ">Read in Pocket</a>';
        $('.item_type_normal').not(':has(.read_in_pocket)').each(function (ind, elem) {
            var id_page = $(elem).attr('id').match(/\d+/);
            var q = $(elem).find('.item_content');
            if(q.length){
                $(q).append(tmp_button.replace('%ID_PAGE%', id_page));
            }
        });
        window.event_for_read_in_pocket = true;
    }
});