-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAutoCookieClick.user.js
57 lines (55 loc) · 1.8 KB
/
AutoCookieClick.user.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
// ==UserScript==
// @id zunsthy-auto-cookie-click
// @name Auto Cookie Click
// @icon https://orteil.dashnet.org/cookieclicker/img/favicon.ico
// @category utils
// @version 0.1.1
// @updateURL https://raw.githubusercontent.com/zunsthy/userscripts/master/AutoCookieClick.meta.js
// @downloadURL https://raw.githubusercontent.com/zunsthy/userscripts/master/AutoCookieClick.user.js
// @author ZunSThy <zunsthy@gmail.com>
// @description auto click cookie button when offscreen
// @namespace https://github.com/zunsthy
// @match https://orteil.dashnet.org/cookieclicker/
// @include https://orteil.dashnet.org/cookieclicker/
// @grant none
// ==/UserScript==
(() => {
const bigCookieClick = () => {
const btn = document.getElementById('bigCookie');
btn.click();
};
const shimmerCookieClick = () => {
const container = document.getElementById('shimmers');
const btns = container.querySelectorAll('.shimmer');
if (btns.length > 1) {
btns.forEach((btn, i) => {
if (btn.style.opacity > 0.9 && i < 3) {
btn.click();
}
});
} else if (btns.length === 1) {
const btn = btns[0];
if (btn.style.opacity > 0.99999) {
btn.click();
}
}
};
const defaultOption = {
interval: 500,
bigCookieClick: false,
shimmerCookieClick: true,
};
window._startCheat = (option = defaultOption) => {
const opt = Object.assign({}, defaultOption, option);
if (typeof window._stopCheat === 'function') {
window._stopCheat();
}
const k = setInterval(() => {
opt.bigCookieClick && bigCookieClick();
opt.shimmerCookieClick && shimmerCookieClick();
}, opt.interval || defaultOption.interval);
};
window._stopCheat = () => {
clearInterval(k);
};
})();