Greasy Fork is available in English.

Redeem itch.io

自动激活itch.io key链接和免费itch.io游戏

Versione datata 28/03/2020. Vedi la nuova versione l'ultima versione.

// ==UserScript==
// @name         Redeem itch.io
// @namespace    http://tampermonkey.net/
// @version      1.0.8
// @description  自动激活itch.io key链接和免费itch.io游戏
// @author       HCLonely
// @include      *://gamecode.win/giveaway/*
// @include      *://*itch.io/*
// @supportURL   https://blog.hclonely.com/posts/578f9be7/
// @homepage     https://blog.hclonely.com/posts/578f9be7/
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    var closeWindow=true;//激活完成后自动关闭页面,改为'false'则为不自动关闭
    var url = location.href;

    /***************************检测itch.io key链接***************************/
    if (url.includes("gamecode.win")){
        $("div.panel-body").append('<div class="col-md-6">' + '<h4 class="text-center">' +
                                   '<button id="redeemItch" style="width: 160px;" class="btn btn-danger btn-sm">' +
                                   '<i class="fa fa-gamepad">' + '</i>' + '激活' + '</button></h4></div>');
        var redeemurl=document.getElementsByClassName("text-center");
        for(var c=0;c<redeemurl.length;c++){
            var redeemurl1=redeemurl[c].innerHTML;
            if (/https:\/\/[\w]{1,}\.itch\.io\/[\w]{1,}(-[\w]{1,}){0,}\/download\/[\d\w]{1,}(-[\d\w]{1,}){1,}/i.test(redeemurl1)){
                if (confirm("检测到itch.io激活链接,是否前往激活?")) window.open(redeemurl1, "_blank");
                break;
            }
            if (/No more keys left sorry \:\([ ]{0,}/.test(redeemurl1)){
                if (confirm("没有key了,是否关闭?")) window.close();
                break;
            }
        }
        jQuery('#redeemItch').click(function(){
            window.open(redeemurl1,"_blank");
        });
    }

    /***************************自动激活itch.io游戏链接***************************/
    if (/^https?:\/\/[\w\W]{1,}\.itch\.io\/[\w]{1,}(-[\w]{1,}){0,}\/download\/[\w\W]{0,}/i.test(url)){
        $("button.button").map(function(i,e){
            if(/(link)|(claim)/gim.test($(e).text())) e.click();
        });
        if((/This page is linked/gim.test($("div.inner_column").text())||$("a.button.download_btn[data-upload_id]").length>0)&&closeWindow==1) window.close();
    }

    /***********************领取免费itch.io游戏***************************/
    if(/^https?:\/\/.*?itch\.io\/.*?\/purchase(\?.*?)?$/.test(url)&&/No thanks\, just take me to the downloads/i.test($("a.direct_download_btn").text())){
        $("a.direct_download_btn")[0].click();
    }else if(/0\.00/gim.test($(".button_message").eq(0).find(".dollars[itemprop]").text())||/Name your own price/gim.test($(".button_message").eq(0).find(".buy_message").text())){
        window.open(url+"/purchase","_self")
    }

    /************************限时免费游戏包*****************************/
    if(/https?:\/\/itch.io\/s\/[\d]{1,}\/[\w\W]{1,}/.test(url)){
        let gameLink=document.getElementsByClassName("thumb_link game_link");
        for(var x=0,y=gameLink.length;x<y;x++){
            if(x!==y-1){
                window.open(gameLink[x].href+"/purchase","_blank");
            }else{
                window.open(gameLink[x].href+"/purchase","_self");
            }
        }
    }
})();