MySpace Re-write www prefix to home

By JoeSimmons Last update Oct 25, 2008 — Installed 188 times.
// ==UserScript==
// @name           MySpace Re-write www prefix to home
// @namespace      http://userscripts.org/users/23652
// @description    Re-writes links starting with www to home
// @include        http://*.myspace.com/*
// @copyright      JoeSimmons
// ==/UserScript==

// XPath multiple, but the array returned is a normal array[x]
// Always uses unordered node snapshot
// Syntax: $xM("//a", "//img", "//form");
function $xM() {
  var i, x, arr = [], xpr;
  for(x=0; x<arguments.length; x++) {
  xpr = document.evaluate(arguments[x],document,null,7,null);
  for (i=0; i<xpr.snapshotLength; i++) {arr.push(xpr.snapshotItem(i));}
  }
  return arr;
}

var i, www = $xM("//a[contains(@href, 'http://www.')]", "//a[contains(@href, 'https://www.')]"), wl=www.length,w,
re = /^https?:\/\/www\./;

for(i=0; i<wl; i++) {
w = www[i];
if(re.test(w.href)) {w.href = w.href.replace(/:\/\/www\./, '://home.');}
}