// ==UserScript== // @name wu::forums Ignore User Script // @description Removes posts made by the ignored user from display // @include http://www.ocf.berkeley.edu/~wwu/cgi-bin/yabb/YaBB.cgi?board=*;* // ==/UserScript== // Author : Arun Iyer aka TenaliRaman var eventUtils = { // cross-platform event registration // I stole this function from SMQ's script // Sorry, SMQ ;) addEventListener: function (object, event, eventHandler) { if (object.addEventListener) { object.addEventListener(event, eventHandler, false); } else if (object.attachEvent) { object.attachEvent("on" + event, eventHandler); } else if (typeof object["on" + event] != "undefined") { var prevfn = object["on" + event]; // yea for closures object["on" + event] = function (e) { eventHandler(e); if (typeof prevfn == "function") { return prevfn(e); } else { eval(prevfn); } } } else { object["on" + event] = eventHandler; } } } var wuForumsIgnoreUsers = { show: function(e) { var event = e ? e : window.event; var target = event.target ? event.target : event.srcElement; var id = target.id; var strArray = id.split(":", 2); var elementId = strArray[1]; var element = document.getElementById(elementId); element.style.display = "block"; }, hide: function(e) { var event = e ? e : window.event; var target = event.target ? event.target : event.srcElement; var id = target.id; var strArray = id.split(":", 2); var elementId = strArray[1]; var element = document.getElementById(elementId); element.style.display = "none"; }, init: function() { var anchors = document.getElementsByTagName("a"); var count = 0; for(var i = 0; i < anchors.length; i++) { var href = anchors[i].href; if(href.search(/username=srn347/i) != -1) { //Found the iggy's post count++; //Travelling to the post' parentNode var firstTable = anchors[i].parentNode.parentNode.parentNode; var secondTable = firstTable.parentNode.parentNode.parentNode; var thirdTable = secondTable.parentNode.parentNode.parentNode; //Giving the post a new shining ID var id = "removedPost" + count; thirdTable.id = id; //Making the post disappear thirdTable.style.display = "none"; //Creating a button that will display the post if necessary var buttonShow = document.createElement("img"); buttonShow.id = "showButton:" + id; buttonShow.src="http://www.ocf.berkeley.edu/~wwu/YaBBImages/shocked.gif"; eventUtils.addEventListener(buttonShow, 'click', this.show); //Creating a text description of the button var showText = document.createElement("span"); showText.id = "showText:" + id; showText.innerHTML = "Show"; showText.display = "block"; eventUtils.addEventListener(showText, 'click', this.show); //Creating a button that will hide the post again var buttonHide = document.createElement("img"); buttonHide.id = "hideButton:" + id; buttonHide.src="http://www.ocf.berkeley.edu/~wwu/YaBBImages/wink.gif"; eventUtils.addEventListener(buttonHide, 'click', this.hide); //Creating a text description of the button var hideText = document.createElement("span"); hideText.id = "hideText:" + id; hideText.innerHTML = "Hide"; hideText.display = "block"; eventUtils.addEventListener(hideText, 'click', this.hide); var breakLine = document.createElement("br"); var postParent = thirdTable.parentNode; postParent.insertBefore(breakLine, thirdTable); postParent.insertBefore(hideText, breakLine); postParent.insertBefore(buttonHide, hideText); postParent.insertBefore(showText, buttonHide); postParent.insertBefore(buttonShow, showText); } } } } wuForumsIgnoreUsers.init();