// zapps annoying articles by specific user (eg, rosebuntu*). // by M.W.Park 2007-07-05 // inspired by trollfreeworld.user.js http://idkiller.iz4u.net/gmonkey/trollfreeworld.user.js // Imyejin-free user script from perky http://openlook.org/src/0704/imyejinfree.user.js // http://userscripts.org/scripts/review/10398 // // 2007-07-06 added floating counter panel based on Johannes' RSS Panel (http://www.xs4all.nl/~jlpoutre/BoT/Javascript/RSSpanel/). Thanks Johannes la Poutré. // ==UserScript== // @name zapper // @namespace http://kldp.org/ // @description zapps annoying articles by specific user // @include http://kldp.org/* // @exclude // ==/UserScript== function getTitleStr() { var titleAttrs = new Array(); titleAttrs['en'] = "View user profile."; titleAttrs['ko'] = "사용자 프로필 보기"; // you may add additional title strings for specific locales here. return titleAttrs[document.documentElement.getAttribute("lang")]; } //alert(getTitleStr()); var trollLinks = document.evaluate('//a[@title=\"'+getTitleStr()+'\" and contains(text(), "rosebuntu")]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); if (trollLinks.snapshotLength > 0) { for (var i = 0; i < trollLinks.snapshotLength; i++) { var node = trollLinks.snapshotItem(i); while (node.nodeName.toLowerCase() != "tr" && node.getAttribute("class") != "comment") node = node.parentNode; node.parentNode.removeChild(node); } function removeEventHandler( target, eventName, eventHandler ) { if( target.addEventListener ) target.removeEventListener( eventName, eventHandler, true ); else if( target.attachEvent ) target.detachEvent( 'on' + eventName, eventHandler ); } function addEventHandler( target, eventName, eventHandler, scope ) { var f = scope ? function(){ eventHandler.apply( scope, arguments ); } : eventHandler; if( target.addEventListener ) target.addEventListener( eventName, f, true ); else if( target.attachEvent ) target.attachEvent( 'on' + eventName, f ); return f; } // Modified DOM-Drag from Book Burro 0.16 var Drag = function(){ this.init.apply( this, arguments ); }; Drag.fixE = function( e ) { if( typeof e == 'undefined' ) e = window.event; if( typeof e.layerX == 'undefined' ) e.layerX = e.offsetX; if( typeof e.layerY == 'undefined' ) e.layerY = e.offsetY; return e; }; Drag.prototype.init = function( handle, dragdiv ) { this.div = dragdiv || handle; this.handle = handle; if( isNaN(parseInt(this.div.style.left)) ) this.div.style.left = '0px'; if( isNaN(parseInt(this.div.style.top)) ) this.div.style.top = '0px'; this.onDragStart = function(){}; this.onDragEnd = function(){}; this.onDrag = function(){}; this.onClick = function(){}; this.mouseDown = addEventHandler(this.handle, 'mousedown', this.start, this); }; Drag.prototype.start = function( e ) { // this.mouseUp = addEventHandler(this.handle, 'mouseup', this.end, this); e = Drag.fixE(e); this.started = new Date(); var y = this.startY = parseInt(this.div.style.top); var x = this.startX = parseInt(this.div.style.left); this.onDragStart(x, y); this.lastMouseX = e.clientX; this.lastMouseY = e.clientY; this.documentMove = addEventHandler(document, 'mousemove', this.drag, this); this.documentStop = addEventHandler(document, 'mouseup', this.end, this); if (e.preventDefault) e.preventDefault(); return false; }; Drag.prototype.drag = function( e ) { e = Drag.fixE(e); var ey = e.clientY; var ex = e.clientX; var y = parseInt(this.div.style.top); var x = parseInt(this.div.style.left); var nx = ex + x - this.lastMouseX; var ny = ey + y - this.lastMouseY; this.div.style.left = nx + 'px'; this.div.style.top = ny + 'px'; this.lastMouseX = ex; this.lastMouseY = ey; this.onDrag(nx, ny); if (e.preventDefault) e.preventDefault(); return false; }; Drag.prototype.end = function() { removeEventHandler( document, 'mousemove', this.documentMove ); removeEventHandler( document, 'mouseup', this.documentStop ); var time = (new Date()) - this.started; var x = parseInt(this.div.style.left), dx = x - this.startX; var y = parseInt(this.div.style.top), dy = y - this.startY; this.onDragEnd( x, y, dx, dy, time ); if( (dx*dx + dy*dy) < (4*4) && time < 1e3 ) this.onClick( x, y, dx, dy, time ); }; function dom_setStyle(elt, str) { elt.setAttribute("style", str); // for MSIE: if (elt.style.setAttribute) { elt.style.setAttribute("cssText", str, 0); // positioning for MSIE: if (elt.style.position == "fixed") { elt.style.position = "absolute"; } } } function dom_getElements(node, elt) { var list = node.getElementsByTagName(elt); return (list.length) ? list : node.getElementsByTagNameNS("*", elt); } function dom_getFirstNodeValue(node, elt) { try { var list = dom_getElements(node, elt); var chld = list[0].firstChild; return chld.nodeValue; } catch (e) { // dbg("missing element " + elt + "\nError: " + e.message); return ""; } } BACKGROUND = "#ffc"; TEXT = "#000"; BORDER = "orange"; TITLE_BACKGROUND = "orange"; TITLE_BORDER = "#ffc"; TITLE_TEXT = "#fff"; OPACITY = "0.80"; var box = window.document.createElement("div"); dom_setStyle(box, "position:fixed;z-index:998;top:1px;left:1px;margin:0px;background-color:" + BACKGROUND + ";border:1px solid " + BORDER + ";padding:4px;text-align:left;opacity:" + OPACITY + ";font:8pt sans-serif;overflow:hidden;width:110px;height:15px;max-height:100%;margin-bottom:15px;"); var title = window.document.createElement("div"); dom_setStyle(title, "position:absolute;top:1px;left:1px;z-index:999;margin:0px;background-color:" + TITLE_BACKGROUND + ";border:1px solid " + TITLE_BORDER + ";padding:4px;text-align:left;font:8pt sans-serif;width:106px;height:11px;overflow:hidden;margin-bottom:15px;cursor:move;font-weight:bold;color:" + TITLE_TEXT + ";"); title.appendChild(window.document.createTextNode(trollLinks.snapshotLength + " item" + (trollLinks.snapshotLength > 1 ? "s" : "") + " zapped.")); box.appendChild(title); dom_getElements(document, "body")[0].appendChild(box); title.drag = new Drag(title, box); // make draggable }