IGG Games Direct Downloads

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.

目前為 2017-04-26 提交的版本,檢視 最新版本

// ==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 iDidIt = document.getElementsByClassName('padPreload').length;
        if(iDidIt == 1){
            iDidIt = 0;
            var allLinks = $('a[rel*=\'nofollow\']');
            if(allLinks.length > 1){
               makeDirectLinks(allLinks);
            }
            clearInterval(interval);
        }
    },1000);

    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);
            }
        }
    }
})();
长期地址
遇到问题?请前往 GitHub 提 Issues。