// ==UserScript== // @name Fanfou Local Blacklist // @namespace http://tampermonkey.net/ // @version 0.6 // @description 为饭否网页端加入了本地屏蔽功能,只要消息转发链中包含屏蔽列表中的用户,就能屏蔽那条消息。(暂时不能考虑因为消息过长被挤掉的用户) // @author You // @include http://www.fanfou.com/* // @include http://fanfou.com/* // @grant GM_getValue // @grant GM_setValue // @run-at document-end // @downloadURL none // ==/UserScript== (function() { 'use strict'; var list = GM_getValue('blacklist'); if (!list) list = '[]'; list = JSON.parse(list); if (window.location.pathname != '/home' && window.location.pathname != '/mentions') { var url = decodeURIComponent(window.location.pathname); var blocked = list.includes(url); var actions = document.querySelector('#panel .actions'); if (actions === null) actions = document.querySelector('#profile-protected .actions'); var addButton = document.createElement('a'); addButton.href = 'javascript:void(0);'; var setButton = function(b) { addButton.className = b?'bl':'bh'; addButton.text = b?'取消屏蔽':'本地屏蔽'; }; var clicking = false; addButton.onclick = function(e) { if (clicking) return false; clicking = true; if (blocked) { var index = list.indexOf(url); list.splice(index, 1); } else { list.push(url); } blocked = !blocked; setButton(blocked); GM_setValue('blacklist', JSON.stringify(list)); clicking = false; }; setButton(blocked); actions.appendChild(addButton); } else { var messages = document.querySelector('#stream ol').children; var bad_msgs = []; for (var i=0; i