From 29abffd4643321fab6a1d167598aaf5650804591 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Mon, 22 Mar 2021 14:48:48 -0400 Subject: [PATCH] Added the "Unclickable" Exploit. --- src/Exploits/Exploit.ts | 4 +++- src/Exploits/unclickable.ts | 24 ++++++++++++++++++++++++ src/engine.jsx | 1 + src/index.html | 2 ++ src/ui/CharacterInfo.tsx | 2 +- 5 files changed, 31 insertions(+), 2 deletions(-) create mode 100644 src/Exploits/unclickable.ts diff --git a/src/Exploits/Exploit.ts b/src/Exploits/Exploit.ts index 2e687b862..deb0dc5e1 100644 --- a/src/Exploits/Exploit.ts +++ b/src/Exploits/Exploit.ts @@ -12,10 +12,11 @@ Source-File minus 1 is extremely weak because it can be fully level up quickly. export enum Exploit { UndocumentedFunctionCall = 'UndocumentedFunctionCall', + Unclickable = 'Unclickable', PrototypeTampering = 'PrototypeTampering', // To the players reading this. Yes you're supposed to add EditSaveFile by // editing your save file, yes you could add them all, no we don't care - // that's not the point + // that's not the point. EditSaveFile = 'EditSaveFile' } @@ -25,6 +26,7 @@ const names: { 'UndocumentedFunctionCall': 'by looking beyond the documentation.', 'EditSaveFile': 'by editing your save file.', 'PrototypeTampering': 'by tampering with Numbers prototype.', + 'Unclickable': 'by clicking the unclickable.', } diff --git a/src/Exploits/unclickable.ts b/src/Exploits/unclickable.ts new file mode 100644 index 000000000..0ee7cd696 --- /dev/null +++ b/src/Exploits/unclickable.ts @@ -0,0 +1,24 @@ +import { Player } from "../Player"; +import { Exploit } from "./Exploit"; + +(function() { + function clickTheUnclickable(event: MouseEvent) { + if(!event.target || !(event.target instanceof Element)) return; + const display = window.getComputedStyle(event.target as Element).display; + if(display === 'none' && event.isTrusted) + Player.giveExploit(Exploit.Unclickable); + } + + + function targetElement() { + const elem = document.getElementById('unclickable'); + if(elem == null) { + console.error('Could not find the unclickable elem for the related exploit.'); + return; + } + elem.addEventListener("click", clickTheUnclickable); + document.removeEventListener('DOMContentLoaded', targetElement); + } + + document.addEventListener('DOMContentLoaded', targetElement); +})(); \ No newline at end of file diff --git a/src/engine.jsx b/src/engine.jsx index 2cf46009b..4dbf9910b 100644 --- a/src/engine.jsx +++ b/src/engine.jsx @@ -102,6 +102,7 @@ import { exceptionAlert } from "../utils/helpers/exceptionAlert"; import { removeLoadingScreen } from "../utils/uiHelpers/removeLoadingScreen"; import { KEY } from "../utils/helpers/keyCodes"; import "./Exploits/tampering"; +import "./Exploits/unclickable"; import React from "react"; import ReactDOM from "react-dom"; diff --git a/src/index.html b/src/index.html index d6858f0ad..d932d1652 100644 --- a/src/index.html +++ b/src/index.html @@ -603,6 +603,8 @@ if (htmlWebpackPlugin.options.googleAnalytics.trackingId) { %>

If the game fails to load, consider killing all scripts

+ + diff --git a/src/ui/CharacterInfo.tsx b/src/ui/CharacterInfo.tsx index 35c089683..414f40190 100644 --- a/src/ui/CharacterInfo.tsx +++ b/src/ui/CharacterInfo.tsx @@ -78,7 +78,7 @@ export function CharacterInfo(p: IPlayer): React.ReactElement { if(SourceFileFlags[5] > 0 && r.length > 2 && r[1] != r[2]) { return ({numeralWrapper.formatPercentage(r[2])}) } - return undefined; + return <>; } return <>