last.fm links to local lastfm
By jesus2099
—
Last update Jun 26, 2008
—
Installed
43 times.
// ==UserScript==
// @name last.fm links to local lastfm
// @version 2008-06-26c
// @description Replaces any "[www.]last.fm" link by the desired local "www.lastfm.xx" link
// @author jesus2099
// @contact http://google.com/search?q=jesus2099
// @licence GPL (http://www.gnu.org/copyleft/gpl.html)
// @exclude http://www.last.fm*
// @exclude http://www.lastfm.*
// @exclude http://last.fm*
// @exclude http://lastfm.*
// ==/UserScript==
var j2lfl = "http://www.lastfm.jp"; /* put your desired local lastfm URL prefix here */
var j2lfml_oResult = document.evaluate(
'//*[local-name()="a" or local-name()="area"] \
[ \
( \
starts-with(@href, "http://last.fm") \
or starts-with(@href, "http://www.last.fm") \
) \
]'
, document, null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null);
if (j2lfml_oResult != null) {
var j2lfml_oLink,
j2lfml_array = [];
/* Put all of them in an array, because otherwise it invalidates the oResult if we make changes to any of the nodes (naja) */
while (j2lfml_oLink = j2lfml_oResult.iterateNext()) {
j2lfml_array.push(j2lfml_oLink);
}
for (var i = j2lfml_array.length - 1 ; i >= 0 ; --i) {
j2lfml_array[i].setAttribute("href", j2lfml_array[i].href.replace(/http:\/\/(www\.)?last\.fm/gi, j2lfl));
}
}