// ==UserScript== // @name Shacknews : Read More Web 3.0 Shit // @namespace http://lmnopc.com/greasemonkey/ // @include http://www.shacknews.com/laryn.x* // @include http://shacknews.com/laryn.x* // @include http://www.shacknews.com/ // @include http://shacknews.com/ // ==/UserScript== // ©2010 THOM WETZEL // DON'T COPY THAT FLOPPY! // 2010-02-25 : initial release // 2010-02-26 : fixed to work on more stories than just latest chatty // : my parsing included an extra at the end that is now removed // 2010-03-01 : now works on the front page too! watch out because javascript-driven stuff won't work... :( (function() { function getElementByClassName(oElm, strTagName, strClassName) { var arrElements = oElm.getElementsByTagName(strTagName); for(var i=0; i < arrElements.length; i++) { if (arrElements[i].className.indexOf(strClassName) == 0) { return arrElements[i]; } } } function isFrontPage() { return (location.href.substr(-14) == 'shacknews.com/'); } function isCommentsPage() { return (location.href.indexOf('laryn.x') != -1); } if (isCommentsPage()) { // find div.news var newses = document.evaluate("//div[@class='news']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); if (newses.snapshotLength != 1) { return false }; var news = newses.snapshotItem(0); // find a.readmore var anchor = getElementByClassName(news, 'a', 'readmore'); if (anchor == null) { return; } // attach event listener to the anchor's click event anchor.addEventListener('click', webthreepointohbullshit, false); } else if (isFrontPage()) { // find div.news var items = document.evaluate("//div[@class='story']", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); for (item = null, i = 0; item = items.snapshotItem(i); i++) { // find a.readmore var anchor = getElementByClassName(item, 'a', 'readmore'); if (anchor == null) { continue; } // attach event listener to the anchor's click event anchor.addEventListener('click', webthreepointohbullshit, false); } } // function that handles the web 3.0 bullshit function webthreepointohbullshit(e) { if (!e) { var e = window.event; } // stop event from bubbling up e.stopPropagation(); e.preventDefault(); GM_xmlhttpRequest({ method:"GET", url: e.target.href, onload:function(result) { if (result.readyState == 4) { if (result.status == 200) { // get the html of the shack var doc = result.responseText; // UNFORTUNATELY I have to parse the HTML as a string... // find the start of div.news var tgt = '
OH SNAP! STRAIGHT UP WEB 3.0 BULLSHIT!
'; } } else { alert('There was a problem with the request.'); } } } }); } })();