Created
May 7, 2011 18:49
-
-
Save mpg/960727 to your computer and use it in GitHub Desktop.
"Clean up external links" user script for Greasemonkey
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "Clean up ext links" user script for Greasemonkey. | |
// version 1.0 2011-05-07 | |
// Written by Manuel Pégourié-Gonnard <[email protected]> in 2011. WTFPL v2. | |
// | |
// -------------------------------------------------------------------- | |
// | |
// This is a Greasemonkey user script. | |
// | |
// To install, you need Greasemonkey: | |
// https://addons.mozilla.org/en-US/firefox/addon/748 | |
// 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 "Clean up ext links", and click Uninstall. | |
// | |
// -------------------------------------------------------------------- | |
// | |
// ==UserScript== | |
// @name Clean up ext links | |
// @namespace http://elzevir.fr/ | |
// @description Remove the annoying prefix sometimes added to external links. | |
// | |
// Some popular blog platforms such as over-blog think it's | |
// appropriate to prefix every external link with something like | |
// http://blogname.domain.tld/ext to display a banner with their | |
// name above the page. This script cleans up the external links | |
// to remove this annoying addition. | |
// | |
// Currently supports only over-blog. | |
// @include http://*.over-blog.com/* | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js | |
// ==/UserScript== | |
// This is the list of things that will be removed from all links. | |
// | |
// Feel free to expand it; remember to add a matching @include line above. | |
// Please let me know about your additions, I'll include them in the script. | |
var regexes = [ | |
"^http://.*\\.over-blog\\.com/ext/" | |
]; | |
$(function() { | |
$("a").each(function() { | |
var href = this.href; | |
for (var i = 0; i < regexes.length; i++) { | |
href = href.replace(new RegExp (regexes[i]), ''); | |
} | |
this.href = href; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment