// ==UserScript== // @name Goodreads_Giveaway_Autonomous // @namespace https://greasyfork.org/en/scripts/431707-goodreads-giveaway-autonomous // @version 1.0 // @description This script will Auto-click "Enter Giveaway". Then open the entry in a // pop-up window auto-click the entry and close when complete. It also changes background // color to gray by default. To adjust to the changes in the website there is a 1 minute // delay before the page is reloaded to view the next set of entries. // @author Davinna // @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 2021 Davinna //=================================================================== // TODO namespace URL // @downloadURL none // ==/UserScript== $(document).ready(function () { //document variables let delayTime_ms = 2000; //delayloop 2 seconds var url; let delayTime_2_ms = 60000; //reload once a minute //change background color document.body.style.backgroundColor = "gray"; $("div.mainContent ").css("background-color", "gray"); $("div.mainContentFloat ").css("background-color", "gray"); //===========Auto-click "Enter Giveaway"=========== //create the list of "Enter Giveaway" buttons let $giveawayButtons = $('a.Button.Button--primary.Button--small'); //wait for page to load window.addEventListener('load', function (event) { console.log('giveawayButtons.length: ' + $giveawayButtons.length); //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); }, delayTime_ms); //end of setTimeout // if (i - 1 == 0) { setTimeout(function () { confirm("Click 'OK' to reload Page").closed(location.reload()); }, delayTime_2_ms); //end of setTimeout_2 }//end of if })($giveawayButtons.length); //end of delayLoop }); //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=1300,top=100,width=500,height=600"); }