Greasy Fork

来自缓存

Greasy Fork is available in English.

Redeem itch.io

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

当前为 2019-01-07 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Redeem itch.io
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  自动激活itch.io key链接和免费itch.io游戏
// @author       HCLonely
// @include      *://*.com/giveaway.php?id=*
// @include      *://*itch.io/*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

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

    /***************************检测itch.io key链接***************************/
    if (/^https?:\/\/[\w]{1,}.com\/giveaway\.php\?id\=[\d]{0,}/i.test(url)){
        $("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){
            /(link)|(claim)/gim.test($(e).text())&&(e.click());
            return 1;
        });
        ((/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?:\/\/[\w\W]{0,}itch\.io\/[\w\W]{0,}\/purchase$/.test(url)){         //点击No thanks...
        /No thanks\, just take me to the downloads/i.test($("a.direct_download_btn").text())&&($("a.direct_download_btn")[0].click());
    }else{                                                                             //加载No thanks...页面
        /0\.00/gim.test($(".button_message").eq(0).find(".dollars[itemprop]").text())&&(window.open(url+"/purchase","_self"))
    }

    /************************限时免费游戏包*****************************/
    if(/https?:\/\/itch.io\/s\/[\d]{1,}\/[\w\W]{1,}/.test(url)){
        var 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");
            }
        }
    }
})();