Skip to content

Instantly share code, notes, and snippets.

@maddenpj
Created January 8, 2018 19:55
Show Gist options
  • Save maddenpj/ef9baf99e8428439e33c3fdc2ba96b53 to your computer and use it in GitHub Desktop.
Save maddenpj/ef9baf99e8428439e33c3fdc2ba96b53 to your computer and use it in GitHub Desktop.
HardcoreGaming101.net Old-site Domain Swap
// ==UserScript==
// @name HardcoreGaming101 DomainFix
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match http://hg101.kontek.net/*
// @include http://blog.hardcoregaming101.net/*
// @grant none
// ==/UserScript==
function switchDomain(l) {
return l.replace(RegExp('http://www\\.hardcoregaming101\\.net/(.*)'), 'http://hg101.kontek.net/$1');
}
(function() {
'use strict';
var links = document.evaluate("//a[@href]",
document,
null,
XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
null
);
for (var i=0;i<links.snapshotLength;i++) {
var thisLink = links.snapshotItem(i);
var newUrl = switchDomain(thisLink.href);
thisLink.href = newUrl;
}
var imgs = document.getElementsByTagName("img");
for(var i=0; i<imgs.length; i++) {
var im = imgs[i];
im.src = switchDomain(im.src);
}
// Your code here...
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment