IndieGala - Gift Fetch & Copy

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);
}