Last active
September 27, 2015 18:58
-
-
Save FiXato/1316472 to your computer and use it in GitHub Desktop.
MRC Forum User Ignore user.js script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name MRC Forum User Ignore(MRC) | |
// @namespace FiXato | |
// @description Hides messages from users you want to ignore on the msx.org forum | |
// @include http://www.msx.org/forum/* | |
// @version 1.1 | |
// ==/UserScript== | |
// | |
// (c) 2011-2013, Filip H.F. "FiXato" Slagter, Licensed under MIT License. | |
// Tested with GreaseMonkey for Firefox 7 on Windows and on Chrome for Mac | |
//Add the users you want to ignore to this array | |
var users_to_ignore = ['sockPuppet', 'sockPuppet2']; | |
//What do you want to do with their posts? Either 'hide' or 'replace' | |
var action = 'replace'; | |
var anchors = document.evaluate("//div[@id='forum-comments']//*[@class='author']//p/a[contains(@href, 'users/')]",document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
for (var i = 0; i < anchors.snapshotLength; i++) { | |
var link = anchors.snapshotItem(i); | |
username = link.firstChild.textContent; | |
idx = users_to_ignore.indexOf(username); | |
commentNode = link.parentNode.parentNode.parentNode; | |
if(idx != -1) { | |
//Future support for styling per username | |
if(action == 'hide') { | |
commentNode.style['display']= 'none'; | |
// link.parentNode.parentNode.nextSibling.style['display']= 'none'; | |
// link.parentNode.parentNode.nextSibling.nextSibling.style['display']= 'none'; | |
} | |
else if(action == 'replace') { | |
messageNode = commentNode.getElementsByClassName('message')[0] | |
messageNode.setAttribute('oldInnerHTML', messageNode.innerHTML); | |
messageNode.innerHTML='You have ignored this user. If you want, you can <a style="cursor: pointer" onclick="this.parentNode.innerHTML=this.parentNode.getAttribute(\'oldInnerHTML\');">temporarily show this comment again</a>.<br />'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment