Easy Easter (PDA)

Detects any eggs on the page and embeds a navigator to jump to any pages. Quick and dirty in classic Kwack fashion

  1. // ==UserScript==
  2. // @name Easy Easter (PDA)
  3. // @namespace dev.kwack.torn.easy-easter
  4. // @version 1.0.3
  5. // @description Detects any eggs on the page and embeds a navigator to jump to any pages. Quick and dirty in classic Kwack fashion
  6. // @author Kwack [2190604]
  7. // @match https://www.torn.com/*
  8. // @grant GM_addStyle
  9. // @grant GM_getValue
  10. // @grant GM_setValue
  11. // @run-at document-end
  12. // ==/UserScript==
  13.  
  14. const eggRootSelector = "div#easter-egg-hunt-root";
  15. const eggButtonSelector = "button";
  16.  
  17. (async () => {
  18. const makeEggEasyMode = (egg) => egg.addClass("kw--egg-easy-mode");
  19.  
  20. addStyles();
  21. checkForEggs();
  22. addNavigator();
  23.  
  24. async function checkForEggs() {
  25. const eggRoot = $(eggRootSelector);
  26. if (!eggRoot.length) return;
  27. const eggs = await waitForEggSpawn(eggRoot);
  28. if (eggs.length) {
  29. const shouldMakeEasyMode = confirm(
  30. `${eggs.length} egg${eggs.length > 1 ? "s" : ""} detected on the current page! ` +
  31. "Do you want to enable easy mode? \n" +
  32. "Warning: this may decrease the number of spawns you receive, use at your own risk."
  33. );
  34. if (shouldMakeEasyMode) eggs.each((_, egg) => makeEggEasyMode($(egg)));
  35. } else console.error("kw--egg: eggs resolved but no eggs found");
  36. }
  37.  
  38. async function waitForEggSpawn(container) {
  39. return new Promise((resolve, reject) => {
  40. setTimeout(() => reject("kw--egg: egg spawn timeout"), 5000);
  41. let eggs = container.find(eggButtonSelector);
  42. if (eggs[0]) resolve(eggs);
  43. const observer = new MutationObserver(() => {
  44. eggs = container.find(eggButtonSelector);
  45. if (eggs[0]) {
  46. observer.disconnect();
  47. resolve(eggs);
  48. }
  49. });
  50. observer.observe(container[0], { childList: true, subtree: true });
  51. });
  52. }
  53.  
  54. function addNavigator() {
  55. class NavigationController {
  56. #urls = [];
  57. constructor(urls) {
  58. this.#urls = urls;
  59. }
  60.  
  61. get index() {
  62. const value = GM_getValue("kw--egg-url-index") || 0;
  63. if (isNaN(value)) return 0;
  64. return value % this.#urls.length;
  65. }
  66.  
  67. set index(value) {
  68. if (value < 0) throw new Error("Invalid index setter");
  69. GM_setValue("kw--egg-url-index", value % this.#urls.length);
  70. }
  71.  
  72. get nextUrl() {
  73. return this.#urls[this.index];
  74. }
  75.  
  76. handleClick() {
  77. this.index++;
  78. window.location.href = "https://www.torn.com/" + this.nextUrl;
  79. }
  80. }
  81.  
  82. const controller = new NavigationController(getAllLinks());
  83. addButton(controller.index, controller.handleClick.bind(controller));
  84.  
  85. function addButton(index, onclick) {
  86. $("<button>", { id: "kw--egg-navigator", text: `Next Page: ${++index}` })
  87. .on("click", onclick)
  88. .appendTo(document.body);
  89. }
  90. }
  91.  
  92. function addStyles() {
  93. GM_addStyle(`
  94. .kw--egg-easy-mode {
  95. position: fixed !important;
  96. top: 0 !important;
  97. bottom: 0 !important;
  98. right: 0 !important;
  99. left: 0 !important;
  100. height: 100vh !important;
  101. width: 100vw !important;
  102. z-index: 999999998;
  103. }
  104. .kw--egg-easy-mode img {
  105. height: 100% !important;
  106. width: 100% !important;
  107. }
  108.  
  109. button#kw--egg-navigator {
  110. position: fixed;
  111. bottom: 0;
  112. left: 0;
  113. margin: 1.5rem;
  114. background-color: #fff;
  115. color: #000;
  116. padding: 0.5rem;
  117. border-radius: 0.5rem;
  118. z-index: 999999999;
  119. cursor: pointer;
  120. }
  121.  
  122. body.dark-mode button#kw--egg-navigator {
  123. background-color: #000;
  124. color: #fff;
  125. }
  126. `);
  127. }
  128. })();
  129.  
  130. function getAllLinks() {
  131. // This array was pulled from Heasley's Egg Navigator, available at https://greasyfork.org/en/scripts/463484-heasley-s-egg-navigator
  132. return [
  133. "",
  134. "index.php",
  135. "city.php",
  136. "jobs.php",
  137. "gym.php",
  138. "properties.php",
  139. "page.php?sid=education",
  140. "properties.php#/p=yourProperties",
  141. "properties.php#/p=spousesProperties",
  142. "education.php",
  143. "crimes.php",
  144. "loader.php?sid=missions",
  145. "newspaper.php",
  146. "jailview.php",
  147. "hospitalview.php",
  148. "casino.php",
  149. "page.php?sid=hof",
  150. "factions.php",
  151. "competition.php",
  152. "page.php?sid=list&type=friends",
  153. "page.php?sid=list&type=enemies",
  154. "page.php?sid=list&type=targets",
  155. "messages.php",
  156. "page.php?sid=events",
  157. "awards.php",
  158. "points.php",
  159. "rules.php",
  160. "staff.php",
  161. "credits.php",
  162. "citystats.php",
  163. "committee.php",
  164. "bank.php",
  165. "donator.php",
  166. "item.php",
  167. "page.php?sid=stocks",
  168. "fans.php",
  169. "museum.php",
  170. "loader.php?sid=racing",
  171. "church.php",
  172. "dump.php",
  173. "loan.php",
  174. "page.php?sid=travel",
  175. "amarket.php",
  176. "bigalgunshop.php",
  177. "shops.php?step=bitsnbobs",
  178. "shops.php?step=cyberforce",
  179. "shops.php?step=docks",
  180. "shops.php?step=jewelry",
  181. "shops.php?step=nikeh",
  182. "shops.php?step=pawnshop",
  183. "shops.php?step=pharmacy",
  184. "pmarket.php",
  185. "shops.php?step=postoffice",
  186. "shops.php?step=super",
  187. "shops.php?step=candy",
  188. "shops.php?step=clothes",
  189. "shops.php?step=recyclingcenter",
  190. "shops.php?step=printstore",
  191. "page.php?sid=ItemMarket",
  192. "estateagents.php",
  193. "bazaar.php?userId=1",
  194. "calendar.php",
  195. "token_shop.php",
  196. "freebies.php",
  197. "bringafriend.php",
  198. "comics.php",
  199. "archives.php",
  200. "joblist.php",
  201. "newspaper_class.php",
  202. "personals.php",
  203. "newspaper.php#/archive",
  204. "profiles.php?XID=1",
  205. "bounties.php",
  206. "usersonline.php",
  207. "joblist.php?step=search#!p=corpinfo&ID=79286",
  208. "page.php?sid=log",
  209. "page.php?sid=ammo",
  210. "page.php?sid=report",
  211. "loader.php?sid=itemsMods",
  212. "displaycase.php",
  213. "trade.php",
  214. "crimes.php?step=criminalrecords",
  215. "archives.php#/",
  216. "archives.php#/TheBirthOfTorn",
  217. "archives.php#/Factions",
  218. "archives.php#/Employment",
  219. "archives.php#/TheMarkets",
  220. "archives.php#/RealEstate",
  221. "page.php?sid=factionWarfare",
  222. "page.php?sid=factionWarfare#/ranked",
  223. "page.php?sid=factionWarfare#/raids",
  224. "page.php?sid=factionWarfare#/chains",
  225. "page.php?sid=factionWarfare#/dirty-bombs",
  226. "index.php?page=fortune",
  227. "page.php?sid=bunker",
  228. "church.php?step=proposals",
  229. "dump.php#/trash",
  230. "messageinc.php",
  231. "preferences.php",
  232. "messageinc2.php#!p=main",
  233. "page.php?sid=gallery&XID=1",
  234. "personalstats.php?ID=1",
  235. "properties.php?step=rentalmarket",
  236. "properties.php?step=sellingmarket",
  237. "forums.php",
  238. "forums.php#/p=forums&f=1",
  239. "forums.php#/p=forums&f=67",
  240. "forums.php#/p=forums&f=2",
  241. "page.php?sid=slots",
  242. "page.php?sid=roulette",
  243. "page.php?sid=highlow",
  244. "page.php?sid=keno",
  245. "page.php?sid=craps",
  246. "page.php?sid=bookie",
  247. "page.php?sid=lottery",
  248. "page.php?sid=blackjack",
  249. "page.php?sid=holdem",
  250. "page.php?sid=russianRoulette",
  251. "page.php?sid=spinTheWheel",
  252. "page.php?sid=spinTheWheelLastSpins",
  253. "page.php?sid=slotsStats",
  254. "page.php?sid=slotsLastRolls",
  255. "page.php?sid=rouletteStatistics",
  256. "page.php?sid=rouletteLastSpins",
  257. "page.php?sid=highlowStats",
  258. "page.php?sid=highlowLastGames",
  259. "page.php?sid=kenoStatistics",
  260. "page.php?sid=kenoLastGames",
  261. "page.php?sid=crapsStats",
  262. "page.php?sid=crapsLastRolls",
  263. "page.php?sid=bookie#/stats/",
  264. "page.php?sid=lotteryTicketsBought",
  265. "page.php?sid=lotteryPreviousWinners",
  266. "page.php?sid=blackjackStatistics",
  267. "page.php?sid=blackjackLastGames",
  268. "page.php?sid=holdemStats",
  269. "loader.php?sid=viewRussianRouletteLastGames",
  270. "loader.php?sid=viewRussianRouletteStats",
  271. "messageinc2.php#!p=viewall",
  272. "bazaar.php#/add",
  273. "blacklist.php#p=add",
  274. "bazaar.php#/personalize",
  275. "factions.php?step=your#/tab=crimes",
  276. "staff.php#/p=helpapp",
  277. "factions.php?step=your#/tab=rank",
  278. "friendlist.php#p=add",
  279. "page.php?sid=events#onlySaved=true",
  280. "factions.php?step=your#/tab=controls",
  281. "factions.php?step=your#/tab=info",
  282. "messages.php#/p=ignorelist",
  283. "messages.php#/p=outbox",
  284. "factions.php?step=your#/tab=upgrades",
  285. "messages.php#/p=saved",
  286. "messages.php#/p=compose",
  287. "displaycase.php#add",
  288. "displaycase.php#manage",
  289. "factions.php?step=your#/tab=armoury",
  290. "bazaar.php#/manage",
  291. "companies.php",
  292. "itemuseparcel.php",
  293. "index.php?page=rehab",
  294. "index.php?page=people",
  295. "christmas_town.php",
  296. "christmas_town.php#/mymaps",
  297. "christmas_town.php#/parametereditor",
  298. "christmas_town.php#/npceditor",
  299. "page.php?sid=UserList",
  300. "index.php?page=hunting",
  301. "old_forums.php",
  302. "donatordone.php",
  303. "revive.php",
  304. "pc.php",
  305. "loader.php?sid=attackLog",
  306. "loader.php?sid=attack&user2ID=1",
  307. "loader.php?sid=crimes",
  308. "loader.php?sid=crimes#/searchforcash",
  309. "loader.php?sid=crimes#/bootlegging",
  310. "loader.php?sid=crimes#/graffiti",
  311. "loader.php?sid=crimes#/shoplifting",
  312. "loader.php?sid=crimes#/pickpocketing",
  313. "loader.php?sid=crimes#/cardskimming",
  314. "loader.php?sid=crimes#/burglary",
  315. "loader.php?sid=crimes#/hustling",
  316. "loader.php?sid=crimes#/disposal",
  317. "loader.php?sid=crimes#/cracking",
  318. "loader.php?sid=crimes#/forgery",
  319. "loader.php?sid=crimes#/scamming",
  320. "/war.php?step=rankreport&rankID=69",
  321. "/war.php?step=warreport&warID=420",
  322. "/war.php?step=raidreport&raidID=69",
  323. "/war.php?step=chainreport&chainID=69420",
  324. "loader.php?sid=slots",
  325. "loader.php?sid=slotsLastRolls",
  326. "loader.php?sid=viewSlotsStats",
  327. "loader.php?sid=roulette",
  328. "loader.php?sid=rouletteLastSpins",
  329. "loader.php?sid=rouletteStatistics",
  330. "loader.php?sid=highlow",
  331. "loader.php?sid=viewHighLowLastGames",
  332. "loader.php?sid=viewHighLowStats",
  333. "loader.php?sid=keno",
  334. "loader.php?sid=craps",
  335. "loader.php?sid=crapsLastRolls",
  336. "loader.php?sid=crapsLastRolls",
  337. "loader.php?sid=viewCrapsStats",
  338. "loader.php?sid=lottery",
  339. "loader.php?sid=viewLotteryUserStats",
  340. "loader.php?sid=viewLotteryStats",
  341. "loader.php?sid=blackjack",
  342. "loader.php?sid=viewBlackjackLastGames",
  343. "loader.php?sid=viewBlackjackStats",
  344. "page.php?sid=crimes2",
  345. "authenticate.php"
  346. ];
  347. }