Greasy Fork

Greasy Fork is available in English.

Goodreads_Giveaway_Autonomous

This script will Auto-click "Enter Giveaway".

当前为 2022-02-07 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Goodreads_Giveaway_Autonomous
// @namespace    http://greasyfork.icu/en/scripts/431707-goodreads-giveaway-autonomous
// @version      1.05
// @description  This script will Auto-click "Enter Giveaway".
// @author       Davinna Mayawen
// @icon         https://media.tenor.com/images/e5b48218f76d06c730cae7f2928ad2c7/tenor.gif
// @include      *www.goodreads.com/giveaway*
// @require      https://code.jquery.com/jquery-3.6.0.min.js
// @license      https://opensource.org/licenses/MIT
// @copyright    Davinna Mayawen 2021
//=======================================================================================
// ==/UserScript==

$(document).ready(function () {
  //document variables
  var url;
  var $giveawayButtons = [];
  let giveawayButtonTimeout = 2000; //giveawayButtonTimeout every 2 seconds
  let reloadTimeout = 60000; //reload once a minute
  let lengthTimeout = 2000; //wait for DOM to finish loading the entries 2 seconds

  //change background color
  document.body.style.backgroundColor = "gray";
  $("div.mainContent ").css("background-color", "gray");
  $("div.mainContentFloat ").css("background-color", "gray");

  //===========Auto-click "Enter Giveaway"===========
  //wait for page to load
  window.addEventListener('load', function (event) {
    setTimeout(function() {
      //create the list of "Enter Giveaway" buttons
      $giveawayButtons = $('a.Button.Button--primary.Button--small');

      //delay loop to open Enter Giveaway window
      (function delayLoop(i) {
        setTimeout(function () {
          openWin($giveawayButtons[i - 1].href);
          //  decrement i and call delayLoop again if i > 0
          if (--i) delayLoop(i);
        }, giveawayButtonTimeout); //end giveawayButtonTimeout
        //
        if (i - 1 == 0) {
          setTimeout(function () {
            confirmFunction();
          }, reloadTimeout); //end of reloadTimeout
        }//end of if
      })($giveawayButtons.length); //end of delayLoop
    }, lengthTimeout); //end of lengthTimeout
  }); //end of event listener

  //Enter giveaway actions
  giveawaySelectors('a.addressLink');
  //add a short delay in milliseconds between clicks of terms checkbox
  setInterval(function () { giveawaySelectors('#termsCheckBox'); }, 1200);
  //add a short delay in milliseconds between clicks of check box and submit button
  setInterval(function () { giveawaySelectors('#giveawaySubmitButton'); }, 1000);

  //close enty windows once completed
  url = window.location.href;
  if (url != 'https://www.goodreads.com/giveaway?sort=ending_soon&format=print' && (($(".mediumTextBottomPadded:contains('You are entered to win.')").length > 0 || $('a.gr-button').length))) {
    window.close();
  };

});//end of .ready

//search all non-zero selectors
function giveawaySelectors(selector) {
  var x = $(selector);
  if (x.length > 0) {
    x[0].click();
  }
}

//open new window
function openWin(href) {
  window.open(href, "_blank", "left=0,top=100,width=600,height=300");
}

//confirm function
function confirmFunction() {
  var r = confirm("Click 'OK' to reload Page");
  if (r == true) {
    location.reload();
  }
  else {
    return;
  }
}