ao3 work block

permanently hide works that you've blocked

当前为 2016-06-02 提交的版本,查看 最新版本

// ==UserScript==
// @name         ao3 work block
// @namespace    https://greasyfork.org/en/users/36620
// @version      0.1.5
// @description  permanently hide works that you've blocked
// @author       scriptfairy
// @match        http*://archiveofourown.org/*works*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js
// @grant        GM_setValue
// @grant        GM_listValues
// ==/UserScript==

(function($) {
    function blockThis(work) {
        var id = $(work).attr('id');
        GM_setValue(id, id);
    }
    function blockAll() {
        var ids = GM_listValues();
        for (j=0;j<ids.length;j++) {
            $('li.blurb#'+ids[j]).hide();
        }
    }
    $(document).ready(function() {
        blockAll();
        var works = $('li.blurb');
        for (i=0;i<works.length;i++) {
            $(works[i]).find('.datetime').prepend('<a href="javascript:void(0);">Block</a>');
        }
        $('.datetime a').click(function() {
            blockThis($(this).parents('li.blurb'));
            $(this).parents('li.blurb').hide();
        });
    });
})(window.jQuery);