您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
silence of the spam
当前为
// ==UserScript== // @name stfu // @namespace 2 // @description silence of the spam // @version 2.01 // @include http://blogs.crikey.com.au/* // @include http://www.crikey.com.au/* // @require https://greasyfork.org/scripts/1884-gm-config/code/GM_config.js?version=4836 // ==/UserScript== // Ver 2.01 // New major version to deal with New, souped-up Crikey // The first rule of stfu: stfu about stfu var scriptVer = '2.01'; //////////////////////////////////////////////////////////////////////////////// /*jslint browser: true */ /*global GM_config, GM_registerMenuCommand */ //////////////////////////////////////////////////////////////////////////////// //don't run in iframes if (window.top !== window.self) {return;} //////////////////////////////////////////////////////////////////////////////// // Config settings dialog GM_config.storage = 'stfu'; GM_config.init('stfu - Ver ' + scriptVer, { authorsFilter: { label: 'Author filter (use the format: \'bob1234|L. Ron Hubbard|Joseph Smith, Jr.\')', type: 'text', 'default': 'bob1234', size:50 }, wordsFilter: { label: 'Word/phrase filter (use the format: \'programmatic specificity|leadership rumblings\')', type: 'text', 'default': '', size:50 } }, { save: function() { location.reload(); } // reload the page when configuration was changed } ); //////////////////////////////////////////////////////////////////////////////// function showConfigSTFU() {GM_config.open();} //////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////// // Declare Global Hashtable var gh = []; //////////////////////////////////////////////////////////////////////////////// // Run if DOM is ready, otherwise add a listerner to wait if (document.readyState == "complete" || document.readyState == "loaded" || document.readyState == "interactive") {main();} else {window.addEventListener('DOMContentLoaded',function(e){main();});} //////////////////////////////////////////////////////////////////////////////// // Init Global Hash Variables function initGlobalHash() { // Filters gh["flt.authors"] = GM_config.get('authorsFilter').toLowerCase(); gh["flt.words"] = GM_config.get('wordsFilter').toLowerCase(); } //////////////////////////////////////////////////////////////////////////////// function main() { console.log('stfu main()'); initGlobalHash(); stfuNavBar(); stfuFilters(); } //////////////////////////////////////////////////////////////////////////////// // Create a new stfu_nav <div> with space for settings function stfuNavBar() { var comments = document.getElementById("comments"); if (! comments) {return;} var stfu_nav = document.createElement('div'); stfu_nav.id = "stfu_nav"; comments.insertBefore(stfu_nav,comments.firstChild); var nav = ["hlp","set","rec"]; var alg = ["left","center","right"]; var tbl = document.createElement('table'); stfu_nav.appendChild(tbl); var row = document.createElement('tr'); tbl.appendChild(row); for (var i = 0; i < nav.length; i++) { var td = document.createElement('td'); td.width = '33%'; row.appendChild(td); var dv = document.createElement('div'); dv.id = 'stfu_' + nav[i]; dv.style = "text-align: " + alg[i] + ";"; td.appendChild(dv); } // Add the stfu Settings Link var set = document.createElement("a"); document.getElementById("stfu_set").appendChild(set); set.innerHTML = "stfu Settings"; set.addEventListener("click", showConfigSTFU, false); } //////////////////////////////////////////////////////////////////////////////// function toggleComment(){ var elem = this.parentNode.nextSibling; if (elem.style.display == 'none') { elem.style.display = 'block'; this.innerHTML = this.innerHTML.replace(/Show Comment/g,'Hide Comment'); } else { elem.style.display = 'none'; this.innerHTML = this.innerHTML.replace(/Hide Comment/g,'Show Comment'); } } //////////////////////////////////////////////////////////////////////////////// function stfuFilters() { if ( ! document.getElementById('comments')) {return;} var afon = ( gh["flt.authors"] !== null && gh["flt.authors"].replace(/\s*/,'').length > 0 ); var wfon = ( gh["flt.words" ] !== null && gh["flt.words" ].replace(/\s*/,'').length > 0 ); if ( ! afon && ! wfon ) {return;} var af = '^' + gh["flt.authors"].replace(/\|/g,'$|^') + '$'; var wf = gh["flt.words"]; var avatars = document.getElementsByClassName('avatar-32'); for ( var i = 0; i < avatars.length; i++ ) { var author = getAuthor(avatars[i]); // console.log(author); if (afon && author.match(af)) {stfuFilter(avatars[i], author, 'Author');} if ( ! wfon) {continue;} var text = avatars[i].parentNode.parentNode.parentNode.getElementsByClassName('comment-content')[0].innerHTML.toLowerCase(); if (text.match(wf)) {stfuFilter(avatars[i], author, 'Words');} } } //----------------------------------------------------------------------------// function getAuthor(e) { var author; var a = e.parentNode.getElementsByClassName('fn')[0]; if ( a.firstChild.innerHTML === undefined ) { author = a.innerHTML; } else { author = a.firstChild.innerHTML; } return author.toLowerCase(); } //----------------------------------------------------------------------------// function stfuFilter(e, author, reason) { if ( e.parentNode.parentNode.parentNode.style.display == 'none') {return;} e.parentNode.parentNode.parentNode.style.display = 'none'; var p = document.createElement('p'); var a = document.createElement('a'); a.addEventListener("click", toggleComment, true); p.appendChild(a); e.parentNode.parentNode.parentNode.parentNode.insertBefore(p,e.parentNode.parentNode.parentNode); a.innerHTML = author + ' - Show Comment (' + reason + ')'; }