Make onClick locations use href

By JoeSimmons Last update Jun 30, 2009 — Installed 150 times. Daily Installs: 0, 2, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2, 0

There are 3 previous versions of this script.

// ==UserScript==
// @name           Make onClick locations use href
// @namespace      http://userscripts.org/users/23652
// @description    Switches window.location into href
// @include        http://*
// @include        https://*
// @include        file://*
// @copyright      JoeSimmons
// @version        1.0.2
// @license        Creative Commons Attribution-Noncommercial 3.0 United States License
// ==/UserScript==

var array = document.evaluate("//a[contains(@onClick, 'location') and contains(@onClick,'=')]",document,null,6,null),
	re = /location(\.href)?\s*=\s*['"]([^'"]+)['"]/;

for(var i=array.snapshotLength-1; (link=array.snapshotItem(i)); i--) {
link.href = link.getAttribute('onClick').match(re)[2];
link.removeAttribute('onClick');
}