// ==UserScript== // @name Block Douban User Status // @namespace Zcc // @version 0.3 // @description Block Douban User's Status (including reposts) // @author Zcc // @match *://www.douban.com/* // @match *://www.douban.com/people/* // @copyright 2017+, Zcc // @downloadURL none // ==/UserScript== // get blocking list var blocked_UID = JSON.parse(localStorage.getItem('douban_blocked_UID')) || [], blocked_USR = JSON.parse(localStorage.getItem('douban_blocked_USR')) || [], ids_blocked = new RegExp(blocked_UID.join('|')), usr_blocked = new RegExp(blocked_USR.join('|')); // modify blocking list if(window.location.pathname === "/"){ console.log("当前屏蔽的用户ID:", blocked_UID); console.log("当前屏蔽的用户昵称:", blocked_USR); $(".status-wrapper").each(function(index){ // 在each方法的回调函数中,其this指向DOM对象 if (!blocked_UID.length || !blocked_USR.length) { return false; } var resharer = this.querySelector(".reshared_by > a"), usrname = resharer ? resharer.title : ""; if (this.dataset.uid.match(ids_blocked) || usrname.match(usr_blocked)) { // block the posts this.style.display = "none"; // $(this).hide(); } }); }else{ 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; // var usrid = matches[1]; var usrid = people_info.id, // is this method stable? usrname = people_info.name; if (blocked_UID.filter(function (num, nickname) { nickname = usrname; return num == usrid; }).length) { // user already blocked listEle.prepend('