Skip to content
Snippets Groups Projects
Unverified Commit 4a7940a7 authored by Jan's avatar Jan Committed by GitHub
Browse files

Update to new site look + more flexibility

- Fixes #1 - Works for the new site layout now
- Also removed the const list of options, replacing it with a lookup of the link value which is unique for default buttons
- Changed from 4 to 2 spaces indentation
- Added periods to comment sentences
parent ce157d27
No related branches found
No related tags found
No related merge requests found
...@@ -4,8 +4,8 @@ ...@@ -4,8 +4,8 @@
// @description Automatically clicks through all the buttons on all subsites of the GreaterGood ClickToGive program every two hours. // @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. // @description:de Klickt sich automatisch alle zwei Std. durch alle Buttons auf allen Seiten des GreaterGood-ClickToGive-Programms.
// @version 1.4.3 // @version 2.0.0
// @copyright 2021+, Jan G. (Rsge) // @copyright 2023+, Jan G. (Rsge)
// @license Mozilla Public License 2.0 // @license Mozilla Public License 2.0
// @icon https://http-aws.greatergood.com/img/ggc/favicon-96x96.png // @icon https://http-aws.greatergood.com/img/ggc/favicon-96x96.png
...@@ -25,54 +25,50 @@ ...@@ -25,54 +25,50 @@
// ==/UserScript== // ==/UserScript==
(function () { (function () {
'use strict'; 'use strict';
// Max amount of seconds to wait before clicking button // Max amount of seconds to wait before clicking button
const MAX_RANDOM_TO_CLICK_SECONDS = 3; const MAX_RANDOM_TO_CLICK_SECONDS = 3;
// Minutes between possible click-throughs // Minutes between possible click-throughs
// Set to at least 1 min more than minimum time because of random button click delay const INTERVAL_MINUTES = 120;
const INTERVAL_MINUTES = 121;
// Click-To-Give site options // On button site, click button.
const SITES = [" Hunger", " Breast Cancer", " Animals", " Veterans", " Autism", " Alzheimer's", var i;
" Diabetes", " Literacy", " Rainforest", " GreaterGood"]; var buttons = document.getElementsByTagName("BUTTON");
var buttonFound = false;
for (i = 0; i < buttons.length; i++) {
// On button site, click button var buttonHTML = buttons[i].innerHTML;
var i; //console.log(buttonHTML);
var buttons = document.getElementsByTagName("BUTTON"); if (buttonHTML == "Click to Give - it's FREE!") {
var buttonFound = false; buttonFound = true;
for (i = 0; i < buttons.length; i++) { break;
var buttonHTML = buttons[i].innerHTML;
//console.log(buttonHTML);
if (buttonHTML == "Click to Give - it's FREE!") {
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;
} }
}
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 // On thanks site, choose new site if not all are already clicked.
var divs = document.getElementsByTagName("DIV"); var links = document.getElementsByTagName("A");
for (i = 0; i < divs.length; i++) { for (i = 0; i < links.length; i++) {
var divClass = divs[i].className; var linkClass = links[i].className;
//console.log(divClass); //console.log(linkClass);
if (divClass.includes("-site col-xs-4 button-to-count") && var linkValue = links[i].attributes[0].value;
!divClass.includes("click-more-clickAttempted") && //console.log(linkValue);
SITES.includes(divs[i].innerText)) { if (linkClass.includes("-site col-4 button-to-count")
var link = divs[i].firstElementChild.href; && !linkClass.includes("click-more-clickAttempted")
//console.log(link); && linkValue.startsWith("/clicktogive/")) {
window.open(link, "_top"); var link = links[i].href;
return; //console.log(link);
} window.open(link, "_top");
return;
} }
}
// Wait for 2 h, then reload page to click through again // Wait for 2 h, then reload page to click through again.
var intervalMilliseconds = INTERVAL_MINUTES * 60 * 1000; var intervalMilliseconds = (INTERVAL_MINUTES + 1) * 60 * 1000;
setTimeout(function(){location.reload(true);}, intervalMilliseconds); setTimeout(function(){location.reload(true);}, intervalMilliseconds);
})(); })();
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