Block Douban User's Status (reposts excluded)
当前为
// ==UserScript==
// @name Block Douban User Status
// @namespace Zcc
// @version 0.1
// @description Block Douban User's Status (reposts excluded)
// @author Zcc
// @match *://www.douban.com/*
// @match *://www.douban.com/people/*
// @copyright 2017+, Zcc
// ==/UserScript==
// window.onload = function () {
// block
var block_list = JSON.parse(localStorage.getItem('douban_block_list')) || [],
r_block = new RegExp(block_list.join('|'));
// console.log("block_list", block_list);
// console.log("r_block", r_block);
$(".status-wrapper, .status-wrapper > .reshared_by").each(function(index, wrapper){
if (!block_list.length) { return false; }
if (wrapper.dataset.uid.match(r_block)) { // block the original posts
// $(wrapper).find('.status-item').hide(); // hide()非法调用
wrapper.parentNode.removeChild(wrapper);
}
// block the reposts
});
if(window.location.pathname !== "/"){
// add user to block list
var listEle = $('.more-opt .user-group-list');
if (!listEle.length) { return false; }
// let matches = $('#profile img').attr('src').match(/ul(\d+)/), usrid;
// if (!matches || matches.length < 2) return false;
// usrid = matches[1];
var usrid = people_info.id;
if (block_list.filter(function (num) {
return num == usrid;
}).length) { // already blocked
listEle.prepend('<li><a href="javascript:;" class="cancel-block">取消屏蔽</a></li>');
} else {
listEle.prepend($('<li><a href="javascript:;" class="block-status">屏蔽广播</a></li>'));
}
listEle.delegate('.cancel-block', 'click', function () {
block_list = block_list.filter(function (num) {
return usrid != num;
});
localStorage.setItem('douban_block_list', JSON.stringify(block_list));
$(this).removeClass('cancel-block').addClass('block-status').text('屏蔽广播');
})
.delegate('.block-status', 'click', function () {
block_list.push(parseInt(usrid, 10));
localStorage.setItem('douban_block_list', JSON.stringify(block_list));
$(this).removeClass('block-status').addClass('cancel-block').text('取消屏蔽');
});
}
// };