permanently hide works
当前为
// ==UserScript==
// @name ao3 work block
// @namespace https://greasyfork.org/en/users/36620
// @version 0.2.5
// @description permanently hide works
// @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
// @grant GM_deleteValue
// ==/UserScript==
(function($) {
function blockThis(work) {
var id = $(work).attr('id');
GM_setValue(id, id);
}
function unblockThis(work) {
var id = $(work).attr('id');
GM_deleteValue(id);
}
function blockAll() {
var ids = GM_listValues();
for (j=0;j<ids.length;j++) {
$('li.blurb#'+ids[j]).hide();
}
}
$(document).ready(function() {
blockAll();
$('<style>').text('button.workblock {background-color:inherit; background-image:none; border:none; font-family:inherit; padding:0; text-decoration:underline; margin-left:5px;} button.workblock:hover {text-decoration:none}').appendTo($('head'));
// wipe GM_list clean and start over
$('ul.primary.navigation.actions li.search').before('<li class="block-clear"><a>Clear blocked list</a></li>');
$('.block-clear').click(function() {
var keys = GM_listValues();
for (k=0;k<keys.length; k++) {
GM_deleteValue(keys[k]);
}
location.reload();
});
// block works
var works = $('li.blurb');
for (i=0;i<works.length;i++) {
$(works[i]).find('.datetime').append('<button type="button" class="workblock block">Block</button>');
}
$('button.workblock.block').click(function() {
var work = $(this).parents('li.blurb');
blockThis(work);
$(work).hide();
});
});
})(window.jQuery);