IndieGala - Gift Fetch & Copy

Reveal all steam keys or gift links of the bundle and copy them all to clipboard

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         IndieGala - Gift Fetch & Copy
// @icon         https://www.indiegala.com/favicon.ico
// @namespace    Royalgamer06
// @author       Royalgamer06
// @version      1.1.1
// @description  Reveal all steam keys or gift links of the bundle and copy them all to clipboard
// @include      https://www.indiegala.com/gift?gift_id=*
// @grant        GM_setClipboard
// @grant        unsafeWindow
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js
// ==/UserScript==

this.$ = this.jQuery = jQuery.noConflict(true);
$.fn.innerText = function() {
    return $(this).contents().filter(function() {
        return this.nodeType == 3;
    }).text();
};
$(document).ready(function() {
    unsafeWindow.confirm = function() {
        return true;
    };
    var waiter = setInterval(function() {
        if ($("#this_your_gift").length > 0) {
            clearInterval(waiter);
            $("#steam-key-games .left").append('&nbsp;&nbsp;<input type="button" class="button" value="Fetch All Steam Keys" id="fetchSteamKeys"></input>');
            $("#steam-key-games .left").append('&nbsp;&nbsp;<input type="button" class="button" value="Fetch All Gift Links" id="fetchGiftLinks"></input>');
            $("#fetchSteamKeys").click(fetchSteamKeys);
            $("#fetchGiftLinks").click(fetchGiftLinks);
        }
    }, 100);
});
function listSteamKeys() {
    var list = "";
    $(".game-key-string:not(:contains(Give this link to your friend!))").each(function() {
        list += $(this).find(".game-steam-url").innerText().trim() + "\t" + $(this).find(".keys").val() + "\r\n";
    });
    console.log(list);
    GM_setClipboard(list);
}
function listGiftLinks() {
    var list = "";
    $(".game-key-string:contains(Give this link to your friend!)").each(function() {
        list += $(this).find(".game-steam-url").innerText().trim() + "\t" + $(this).find("[class*=give-gift-link] a").attr("href") + "\r\n";
    });
    console.log(list);
    GM_setClipboard(list);
}
function fetchSteamKeys() {
    $(".order-button-profile").each(function() {
        unsafeWindow.globalAjaxSemaphore = false;
        $(this).click();
    });
    $("#fetchGiftLinks").hide();
    $("#fetchSteamKeys").val("Copy All Steam Keys").click(listSteamKeys);
}
function fetchGiftLinks() {
    $("[name=steambutton]").each(function() {
        unsafeWindow.globalAjaxSemaphore = false;
        $(this).click();
    });
    $("#fetchSteamKeys").hide();
    $("#fetchGiftLinks").val("Copy All Gift Links").click(listGiftLinks);
}