Skip to content
Snippets Groups Projects
Commit 0cd19176 authored by Jan's avatar Jan Committed by Rsge
Browse files

Added random delay before click & changed to match

- Added random delay before clicking the button after opening page
- Changed from [at]include to [at]match ([at]include seems to be more or less deprecated)
- Added configurable times in human readable format as constants on top
parent c78622ed
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@
// @description Automatically clicks through all the buttons on all subsites of the GreaterGood ClickToGive program every two hours.
// @description:de Klickt sich automatisch alle zwei Std. durch alle Buttons auf allen Seiten des GreaterGood-ClickToGive-Programms.
// @version 1.2
// @version 1.3
// @author Rsge
// @copyright 2021+, Jan G. (Rsge)
// @license Mozilla Public License 2.0
......@@ -14,9 +14,10 @@
// @homepageURL https://github.com/Rsge/GreaterGood-CTG-AutoClicker
// @supportURL https://github.com/Rsge/GreaterGood-CTG-AutoClicker/issues
// @include https://greatergood.com/clicktogive/*
// @include https://*.greatergood.com/clicktogive/*
// @match https://greatergood.com/clicktogive/*
// @match https://greatergood.com/ClickToGive/*
// @match https://*.greatergood.com/clicktogive/*
// @match https://*.greatergood.com/ClickToGive/*
// @grant none
// ==/UserScript==
......@@ -24,20 +25,35 @@
(function () {
'use strict';
const sites = [" Hunger", " Breast Cancer", " Animals", " Veterans", " Autism", " Alzheimer's",
" Diabetes", " Literacy", " Rainforest", " GreaterGood"]
// Max amount of seconds to wait before clicking button
const MAX_RANDOM_TO_CLICK_SECONDS = 3;
// Minutes between possible click-throughs
// Set to at least 1 min more than minimum time because of random button click delay
const INTERVAL_MINUTES = 121;
// Click-To-Give site options
const SITES = [" Hunger", " Breast Cancer", " Animals", " Veterans", " Autism", " Alzheimer's",
" Diabetes", " Literacy", " Rainforest", " GreaterGood"];
// On button site, click button
var i;
var buttons = document.getElementsByTagName("BUTTON");
var buttonFound = false
for (i = 0; i < buttons.length; i++) {
var buttonHTML = buttons[i].innerHTML;
//console.log(buttonHTML);
if (buttonHTML == "Click to Give - it's FREE!") {
buttons[i].click();
return;
buttonFound = true
break
}
}
if (buttonFound) {
var millisecondsToClick = (Math.floor(Math.random() * MAX_RANDOM_TO_CLICK_SECONDS) + 1) * 1000;
setTimeout(function(){buttons[i].click()}, millisecondsToClick);
return;
}
// On thanks site, choose new site if not all are already clicked
var divs = document.getElementsByTagName("DIV");
......@@ -46,7 +62,7 @@
//console.log(divClass);
if (divClass.includes("-site col-xs-3 col-sm-4 button-to-count") &&
!divClass.includes("click-more-clickAttempted") &&
sites.includes(divs[i].innerText)) {
SITES.includes(divs[i].innerText)) {
var link = divs[i].firstElementChild.href;
//console.log(link);
window.open(link, "_top");
......@@ -55,5 +71,6 @@
}
// Wait for 2 h, then reload page to click through again
setTimeout(function(){location.reload(true);}, 7260000);
var intervalMilliseconds = INTERVAL_MINUTES * 60 * 1000;
setTimeout(function(){location.reload(true);}, intervalMilliseconds);
})();
......@@ -4,4 +4,4 @@ It automatically clicks through all the buttons on all subsites of the *GreaterG
It starts on any of the subsites and works through the complete list, starting at the top left to the bottom right, leaving out the two changing external links besides the main *GreaterGood* site link.
It uses the *click*-action on the buttons, so they're correctly counted as clicked, and also works in the background.
It uses the *click*-action on the button with a random delay after page loads, so they're correctly counted as clicked, and also works in the background.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment