-
Notifications
You must be signed in to change notification settings - Fork 0
/
GreaterGood CTG AutoClicker.js
80 lines (69 loc) · 2.97 KB
/
GreaterGood CTG AutoClicker.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// ==UserScript==
// @name GreaterGood CTG AutoClicker
// @name:de GreaterGood CTG Auto-Klicker
// @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 2.1.1
// @copyright 2023+, Jan G. (Rsge)
// @license Mozilla Public License 2.0
// @icon https://http-aws.greatergood.com/img/ggc/favicon-96x96.png
// @namespace https://github.com/Rsge
// @homepageURL https://github.com/Rsge/GreaterGood-CTG-AutoClicker
// @supportURL https://github.com/Rsge/GreaterGood-CTG-AutoClicker/issues
// @updateURL https://greasyfork.org/scripts/433055-greatergood-ctg-autoclicker/code/GreaterGood%20CTG%20AutoClicker.user.js
// @downloadURL https://greasyfork.org/scripts/433055-greatergood-ctg-autoclicker/code/GreaterGood%20CTG%20AutoClicker.user.js
// @match https://greatergood.com/clicktogive/*
// @match https://greatergood.com/clickToGive/*
// @match https://*.greatergood.com/clicktogive/*
// @match https://*.greatergood.com/clickToGive/*
// @run-at document-idle
// @grant none
// ==/UserScript==
(function () {
'use strict';
// Max amount of seconds to wait before clicking button
const MAX_RANDOM_TO_CLICK_SECONDS = 3;
// Minutes between possible click-throughs
const INTERVAL_MINUTES = 120;
// On button site, click button.
let i;
let buttons = document.getElementsByTagName("BUTTON");
let buttonFound = false;
for (i = 0; i < buttons.length; i++) {
let buttonHTML = buttons[i].innerHTML;
//console.log(buttonHTML);
if (buttonHTML == "Click to Give - it's FREE!") {
buttonFound = true;
break;
}
}
if (buttonFound) {
let 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.
let links = document.getElementsByTagName("A");
for (i = 0; i < links.length; i++) {
let linkClass = links[i].className;
//console.log(linkClass);
let linkAttributes = links[i].attributes[0]
//console.log(linkAttributes);
if (linkAttributes === undefined) {
continue;
}
let linkValue = linkAttributes.value;
//console.log(linkValue);
if (linkClass.includes("-site col-4 button-to-count")
&& !linkClass.includes("click-more-clickAttempted")
&& linkValue.startsWith("/clicktogive/")) {
let link = links[i].href;
//console.log(link);
window.open(link, "_top");
return;
}
}
// Wait for specified time, then reload page to click through again.
let intervalMilliseconds = (INTERVAL_MINUTES + 1) * 60 * 1000;
setTimeout(function(){location.reload(true);}, intervalMilliseconds);
})();