Greasemonkey script for hp.com forums
If you’ve ever visited the hp.com forums you’ll know that any links in the post get enclosed by a call to “javascript:openExternal(’’)” in the href rather than doing it properly in onClick. Amongst other things, this breaks the ability to middle click to open links in new tabs.
This finally annoyed me enough today and as a result, I now use the following greasemonkey script:
// ==UserScript==
// @name Stupid HP.COM Links
// @namespace http://shanemcc.co.uk/
// @include *hp.com*
// ==/UserScript==
var a = document.getElementsByTagName("A");
for (var i = 0; i < a.length; i++){
var href = a[i].href;
href = href.replace(/javascript:openExternal\('([^']+)'\)/i, '$1');
a[i].href = href;
}
This will make the links no longer have the call to openExternal around them, and thus make them middle-click friendly.