/* Fark Lite Copyright (c) 2005, Rick FletcherReleased under the GPL license http://www.gnu.org/copyleft/gpl.html -------------------------------------------------------------------- This is a Greasemonkey user script. To install, you need Greasemonkey: http://greasemonkey.mozdev.org/ Then restart Firefox and revisit this script. Under Tools, there will be a new menu item to "Install User Script". Accept the default configuration and install. To uninstall, go to Tools/Manage User Scripts, select "Fark Lite", and click Uninstall. -------------------------------------------------------------------- Changelog 0.3 2015-08-27 RCJ update for Fark changes 0.2.2 2005/10/08 bug: no longer hiding the "view voting results" link on the comments page 0.2.1 2005/10/03 bug: updated to work with updated fark.com source 0.2 2005/10/02 new: refactored to use XPath 0.1 2005/07/20 initial release */ // ==UserScript== // @name Fark Lite // @version 0.3 // @namespace http://flet.ch/things/greasemonkey/ // @description Strips fark.com down to just the links. Hides links from categories you don't want to see. // @include http://*.fark.com/* // @include http://fark.com/* // ==/UserScript== (function () { var farklite = { config: { hide_search: true, // remove the google search form at the top of the page hide_side_columns: true, // remove the columns on either side of the page fix_link_target: true, // make links open in the current window strip_passthru_script: true, // make links direct (instead of passing through the go.fark.com script) unwanted_categories: // links that are in these categories will be removed [ "weeners", "satire", "video edit" ], }, //fark_passthru_script_regex: /^http:\/\/\w+\.fark\.com.*l=([^&]+)/i, fark_passthru_script_regex: /^http:\/\/\w+\.fark\.com\/goto\/[0-9]+\/(.*)/i, // link_container_xpath: "//table[@class='nilink']/descendant::tr/td[position() = 1]/a", link_container_xpath: "//a[@class='outbound_link']", addCSS: function( css ) { var head = window.document.getElementsByTagName( "head" )[0]; var style = window.document.createElement( "style" ); style.setAttribute( "type", "text/css" ); style.innerHTML = css; head.appendChild( style ); }, fixLinks: function() { var links = document.evaluate( this.link_container_xpath, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null ); for( var link = null, i = 0; ( link = links.snapshotItem( i ) ); i++ ) { this.config.fix_link_target && link.setAttribute( "target", "" ); this.config.strip_passthru_script && link.setAttribute( "href", unescape( link.getAttribute( "href" ).replace( this.fark_passthru_script_regex, "http://$1" ) ) ); this.config.strip_passthru_script && link.setAttribute( "onmouseover", "" ); this.config.strip_passthru_script && link.setAttribute( "onmouseout", "" ); } }, removeUnwanted: function() { for( var i = 0; i < this.config.unwanted_categories.length; i++ ) { this.config.unwanted_categories[i] = this.config.unwanted_categories[i].toLowerCase().replace( /[^a-z]/, "" ); } var link_category_xpath = "//tr[@class='headlineRow']/descendant::img[translate(@alt,'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')='" + this.config.unwanted_categories.join( "' or translate(@alt,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')='" ) + "']/parent::*"; var links = document.evaluate( link_category_xpath, document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null ); for( var link = null, i = 0; ( link = links.snapshotItem( i ) ); i++ ) { link.parentNode.parentNode.removeChild( link.parentNode ); } }, } farklite.addCSS( "td.howto, form div.howto:first-child, .banhead div, div.footnote { display: none; }" ); farklite.config.hide_search && farklite.addCSS( ".banhead form { display: none; }" ); farklite.config.hide_side_columns && farklite.addCSS( ".newtoolbar, .entirelefttoolbar, .entirerighttoolbar { display: none; }" ); farklite.removeUnwanted(); farklite.fixLinks(); farklite.fixLinks2(); })();
Thursday, August 27, 2015
Fark Lite tampermonkey script updates
Updated Fark Lite to work with the current version of Fark.com (as of 2015-08-27)
Labels:
fark,
greasemonkey,
javascript,
programming,
tampermonkey,
userscript
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment