User:Jeremyb/insecure.js

/* Script to rewrite external links to Wikipedia (and other Wikimedia projects) to * use the secure server when already browsing from https://secure.wikimedia.org, so * that links to diffs, etc., don't take you off the site. */

addOnloadHook( neversecurelinks)

function neversecurelinks { if( window.disableSecureLinks===true) return; var re1 = /^https:\/\/(?:[a-z0-9\.\\-]+\.)?(?:wik(?:i[mp]edia|tionary|isource|iquote|ibooks|inews|iversity|imediafoundation)|mediawiki)\.org\//i; var links = document.getElementsByTagName('a'); for (var i = links.length; i--;) { var link = links[i]; if (href.match(re1)) { link.href = "http" + link.href.substring(5); }	} }