Redeem itch.io

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

目前为 2019-04-14 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Redeem itch.io
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0.1
  5. // @description 自动激活itch.io key链接和免费itch.io游戏
  6. // @author HCLonely
  7. // @include *://*.com/giveaway.php?id=*
  8. // @include *://*itch.io/*
  9. // @grant none
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. var closeWindow=1;//激活完成后不自动关闭页面,改为1则为自动关闭
  17. var url = location.href;
  18.  
  19. /***************************检测itch.io key链接***************************/
  20. if (/^https?:\/\/[\w]{1,}.com\/giveaway\.php\?id\=[\d]{0,}/i.test(url)){
  21. $("div.panel-body").append('<div class="col-md-6">' + '<h4 class="text-center">' +
  22. '<button id="redeemItch" style="width: 160px;" class="btn btn-danger btn-sm">' +
  23. '<i class="fa fa-gamepad">' + '</i>' + '激活' + '</button></h4></div>');
  24. var redeemurl=document.getElementsByClassName("text-center");
  25. for(var c=0;c<redeemurl.length;c++){
  26. var redeemurl1=redeemurl[c].innerHTML;
  27. if (/https:\/\/[\w]{1,}\.itch\.io\/[\w]{1,}(-[\w]{1,}){0,}\/download\/[\d\w]{1,}(-[\d\w]{1,}){1,}/i.test(redeemurl1)){
  28. if (confirm("检测到itch.io激活链接,是否前往激活?")){
  29. window.open(redeemurl1, "_blank");
  30. }
  31. break;
  32. }
  33. if(/No more keys left sorry \:\([ ]{0,}/.test(redeemurl1)){
  34. if (confirm("没有key了,是否关闭?")){
  35. window.close();
  36. }
  37. break;
  38. }
  39. }
  40. jQuery('#redeemItch').click(function(){
  41. window.open(redeemurl1,"_blank");
  42. });
  43. }
  44.  
  45. /***************************自动激活itch.io游戏链接***************************/
  46. if (/^https?:\/\/[\w\W]{1,}\.itch\.io\/[\w]{1,}(-[\w]{1,}){0,}\/download\/[\w\W]{0,}/i.test(url)){
  47. $("button.button").map(function(i,e){
  48. /(link)|(claim)/gim.test($(e).text())&&(e.click());
  49. return 1;
  50. });
  51. ((/This page is linked/gim.test($("div.inner_column").text())||$("a.button.download_btn[data-upload_id]").length>0)&&closeWindow==1)&&(window.close());
  52. }
  53.  
  54. /***********************领取免费itch.io游戏***************************/
  55. if(/^https?:\/\/.*?itch\.io\/.*?\/purchase(\?.*?)?$/.test(url)){ //点击No thanks...
  56. /No thanks\, just take me to the downloads/i.test($("a.direct_download_btn").text())&&($("a.direct_download_btn")[0].click());
  57. }else{ //加载No thanks...页面
  58. /0\.00/gim.test($(".button_message").eq(0).find(".dollars[itemprop]").text())&&(window.open(url+"/purchase","_self"))
  59. }
  60.  
  61. /************************限时免费游戏包*****************************/
  62. if(/https?:\/\/itch.io\/s\/[\d]{1,}\/[\w\W]{1,}/.test(url)){
  63. var gameLink=document.getElementsByClassName("thumb_link game_link");
  64. for(var x=0,y=gameLink.length;x<y;x++){
  65. if(x!=y-1){
  66. window.open(gameLink[x].href+"/purchase","_blank");
  67. }else{
  68. window.open(gameLink[x].href+"/purchase","_self");
  69. }
  70. }
  71. }
  72. })();