Skip to content

Instantly share code, notes, and snippets.

@Soft
Created June 1, 2010 09:07
Show Gist options
  • Save Soft/420744 to your computer and use it in GitHub Desktop.
Save Soft/420744 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Secure Wikipedia
// @include http://*/*
// @include https://*/*
// @description Changes links to Wikipedia articles to point to secure version
// ==/UserScript==
(function(){
var links = document.getElementsByTagName("a");
for (var i = 0; i < links.length; i++) {
var wiki_regexp = /http:\/\/(..)\.wikipedia\.org\/wiki\/(.+)/;
if (wiki_regexp.test(links[i].href)) {
var matches = wiki_regexp.exec(links[i].href);
links[i].href = "https://secure.wikimedia.org/wikipedia/" + matches[1] + "/wiki/" + matches[2];
}
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment