Skip to content

Instantly share code, notes, and snippets.

@FiXato
Last active September 27, 2015 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FiXato/1316472 to your computer and use it in GitHub Desktop.
Save FiXato/1316472 to your computer and use it in GitHub Desktop.
MRC Forum User Ignore user.js script
// ==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