IGG Games download links all contain multiple forwarders before you get the actual download link. This automatically re-formats each available download link to be direct.
当前为
// ==UserScript==
// @name IGG Games Direct Downloads
// @namespace http://tampermonkey.net/
// @version 1.0.3
// @description IGG Games download links all contain multiple forwarders before you get the actual download link. This automatically re-formats each available download link to be direct.
// @author MooreR
// @include http://igg-games.com/*
// @run-at document-idle
// ==/UserScript==
(function() {
'use strict';
var interval = setInterval(function(){
var didLoad = document.getElementsByClassName('padPreload').length;
if(didLoad == 1){
didLoad = 0;
var allLinks = $('a[rel*=\'nofollow\']');
if(allLinks.length > 1){
makeDirectLinks(allLinks);
}
clearInterval(interval);
}
},2000);
function makeDirectLinks(allLinks) {
if(allLinks.length > 50){
alert('There are a lot of links for this game! This script will more than likely fail. Maybe choose a different source for now.');
} else {
var xmlReq = [];
var i = 0;
for (i = 0; i < allLinks.length; i++) {
(function(i) {
xmlReq[i] = new XMLHttpRequest();
xmlReq[i].timeout = 2000;
xmlReq[i].open("GET", allLinks[i].href, true);
xmlReq[i].onreadystatechange = function (oEvent) {
if (xmlReq[i].readyState === 4) {
var resp = xmlReq[i].responseText.split('xurl=');
if(resp.length > 1){
var test = resp[resp.length - 1].split('"')[0];
allLinks[i].setAttribute('href', test.split(':')[1]);
}
}
};
xmlReq[i].send(null);
})(i);
}
}
}
})();