This repository has been archived by the owner on Aug 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ai-dungeon-farmer.js
167 lines (159 loc) · 6.33 KB
/
ai-dungeon-farmer.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/* jshint esversion: 11 */
var EnableFastMode = false;
console.log("<[>AI Dungeon Farmer<]>");
var NOHTML = false;
var HTML_SubText = null;
var HTML_WatchAdBtn = null;
var HTML_ActionText = null;
var AUTHTOKEN = null;
var USERAGENT = null;
(async () => {
var isNodeJS = false;
try {
isNodeJS = !!require;
} catch { isNodeJS = false; }
if (isNodeJS) {
console.log("Running in Node.js environment.");
_aidfuck_fetch = require("node-fetch");
rl = require("readline").createInterface(process.stdin, process.stdout);
prompt = async (q) => await new Promise((r) => rl.question(q, r));
AUTHTOKEN = process.argv[2] || await prompt("Enter your authtoken: ");
USERAGENT = process.argv[3] || (await prompt("Enter your useragent: ")).toLowerCase();
NOHTML = true;
postInit();
} else {
console.log("Running in DevTools environment.");
HTML_SubText = $("[style=\"color: rgb(153, 153, 153); font-family: HelveticaNeue-Light, Helvetica, sans-serif, Classic, alegreya_regular; font-size: 20px;\"]");
HTML_WatchAdBtn = $$("div[dir=auto]").find((x) => x.innerText == "WATCH AN AD");
HTML_ActionText = $$("div[dir=auto]").find((x) => x.innerText.startsWith("You have"));
if (!HTML_SubText || !HTML_WatchAdBtn || !HTML_ActionText) throw "Couldn't find a required HTML element.";
HTML_SubText.innerHTML = '<center>Welcome to AI Dungeon Farmer!<br>Made in a few boring hours by Alluseri<br><i><small>Ads were such a bad idea...<br>Now everyone gets to enjoy the ad-free experience.</small></i></center>';
HTML_SubText.parentElement.style.alignSelf = "center";
HTML_WatchAdBtn.innerText = "INITIALIZE FARMER";
_aidfuck_fetch = fetch;
fetch = async function (n, capture) {
var auth = capture.headers?.authorization;
if (auth && !AUTHTOKEN) {
AUTHTOKEN = auth;
}
};
var uni = function ($, getEventListeners) {
if (AUTHTOKEN) postInit($, getEventListeners);
else setTimeout(uni, 1000, $, getEventListeners);
};
uni = function ($, getEventListeners) {
if (AUTHTOKEN) postInit($, getEventListeners);
else setTimeout(uni, 1000, $, getEventListeners);
};
// ^ I'm afraid of js so double declaration just in case
// I know I could just setInterval & self clear
uni($, getEventListeners);
}
})();
function fuckgraphql(eventName, clientInfo) { // it's so gay istg
return {
"operationName": "EventHookSendUserEvent",
"variables": {
"input": {
"eventName": eventName,
"variation": "web",
"clientInfo": clientInfo
}
},
"query": "mutation EventHookSendUserEvent($input: EventInput) {\n sendUserEvent(input: $input)\n}\n"
};
}
async function easy(query) {
return await (await _aidfuck_fetch("https://api.aidungeon.io/graphql", {
"method": "POST",
"body": JSON.stringify(query),
"headers": {
"authorization": AUTHTOKEN,
"content-type": "application/json",
"accept": "*/*"
}
})).json();
}
async function postInit($, getEventListeners) {
console.log("Pre-init routine complete.");
if (NOHTML) {
while (true) {
var repeat = 1;
try {
repeat = Number.parseInt(await prompt("How much actions to add * 10?"));
} catch {}
var clientInfo = {
"os": "web",
"model": USERAGENT,
"version": "unknown"
};
var Query1 = fuckgraphql("ad_reward_button_press", clientInfo);
var Query2 = fuckgraphql("ad_rewarded_reward_earned", clientInfo);
var Query3 = {
"operationName": "IncreaseAdCounterAdContext",
"variables": {},
"query": "mutation IncreaseAdCounterAdContext($addActions: Int) {\n increaseAdCountdown(addActions: $addActions)\n}\n"
};
var Query4 = {
"operationName": "UserContextGetAdCountdown",
"variables": {},
"query": "query UserContextGetAdCountdown {\n adCountdown {\n id\n currentCount\n enforceAds\n shouldAutoplayAds\n __typename\n }\n}\n"
};
for (var i = 0;i < repeat;i++) {
if (EnableFastMode) {
easy(Query1);
easy(Query2);
easy(Query3);
} else {
await easy(Query1);
await easy(Query2);
await easy(Query3);
}
console.log("Now you have " + (await easy(Query4)).data.adCountdown.currentCount + " actions." + (EnableFastMode ? " Info may be outdated due to Fast Mode." : ""));
}
}
} else {
setTimeout(($) => {
console.log($);
$("[style='align-items: center; display: flex; height: auto; justify-content: center; -webkit-box-align: center; -webkit-box-pack: center;']").parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.remove();
}, 200, $);
HTML_SubText.innerHTML = "<center><b>Refresh</b> the page after you're done farming.<br><i><small>Powered by catgirl supremacy</small></i></center>";
HTML_WatchAdBtn.innerText = "+10 ACTIONS";
$("#root").removeEventListener("click", getEventListeners($("#root")).click[0].listener);
_backup = async function () {
HTML_WatchAdBtn.parentElement.parentElement.onclick = null;
HTML_WatchAdBtn.innerText = "PLEASE WAIT...";
var clientInfo = {
"os": "web",
"model": navigator.userAgent.toLowerCase(),
"version": "unknown"
};
var Query1 = fuckgraphql("ad_reward_button_press", clientInfo);
var Query2 = fuckgraphql("ad_rewarded_reward_earned", clientInfo);
var Query3 = {
"operationName": "IncreaseAdCounterAdContext",
"variables": {},
"query": "mutation IncreaseAdCounterAdContext($addActions: Int) {\n increaseAdCountdown(addActions: $addActions)\n}\n"
};
var Query4 = {
"operationName": "UserContextGetAdCountdown",
"variables": {},
"query": "query UserContextGetAdCountdown {\n adCountdown {\n id\n currentCount\n enforceAds\n shouldAutoplayAds\n __typename\n }\n}\n"
};
if (EnableFastMode) {
easy(Query1);
easy(Query2);
easy(Query3);
} else {
await easy(Query1);
await easy(Query2);
await easy(Query3);
}
HTML_ActionText.innerHTML = "You have " + (await easy(Query4)).data.adCountdown.currentCount + " Actions" + (EnableFastMode ? "<br>Fast mode enabled: Info may be outdated." : "");
HTML_WatchAdBtn.parentElement.parentElement.onclick = _backup;
HTML_WatchAdBtn.innerText = "+10 ACTIONS";
};
HTML_WatchAdBtn.parentElement.parentElement.onclick = _backup;
}
}
// "haven't seen worse code in my entire life" - (C) Someone, definitely