// ==UserScript== // @name 贴吧屏蔽助手 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 屏蔽 指定用户的发的帖子,点x后以后他的发的帖子(不是回复)都被屏蔽掉 // @author You // @match https://tieba.baidu.com/** // @grant GM_setValue // @grant GM_getValue // @downloadURL none // ==/UserScript== (function() { //隐藏 指定数组(如 [{"user_id":1370621204},{},{} ]格式 )里的所有用户 的主题 function hideIt(array){ var count=0; $("span.tb_icon_author").each(function(){ var spanTb=this; array.forEach(function(item,index,array){ var value=item.user_id; var value2=$(spanTb).data("field").user_id; if(value==value2){ $(spanTb).closest("li.j_thread_list.clearfix").hide(); count++; } }); }); console.log("屏蔽条数:",count); } //需先其他js执行后 执行才可获取到dom setTimeout(function(){ //初始化屏蔽......................... var userIds=GM_getValue("pbUserIds"); if(!userIds){ userIds=[]; } console.log("屏蔽用户",userIds); hideIt(userIds); //自定义屏蔽按钮 $(".frs-author-name-wrap a").after($("")); $(".xButton").click(function(){ var targetUserid=$(this).closest("span.tb_icon_author").data("field"); userIds.push(targetUserid); GM_setValue("pbUserIds",userIds); hideIt([targetUserid]); }); //定义清楚 屏蔽用户按钮 $li=$("