From f4a94bed13a8595ec8a15e3ea8315aeb5aecc744 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Sat, 9 Mar 2024 08:57:59 +0530 Subject: A lot of changes :) --- src/scripts/captcha.ts | 20 -------- src/scripts/login.ts | 112 +++++++++++++++++++++++++++++-------------- src/scripts/stop-blocking.ts | 26 +++++----- 3 files changed, 90 insertions(+), 68 deletions(-) delete mode 100644 src/scripts/captcha.ts (limited to 'src/scripts') diff --git a/src/scripts/captcha.ts b/src/scripts/captcha.ts deleted file mode 100644 index 453443c..0000000 --- a/src/scripts/captcha.ts +++ /dev/null @@ -1,20 +0,0 @@ -const autofillCaptcha = () => { - const captchas = Array.from(document.querySelectorAll("#captchaText")) as HTMLInputElement[]; - - for (const captcha of captchas) { - const captchaParentElement = captcha.parentElement!; - - if (captchaParentElement.id === "drawTextSpan") { - const captchaInput = captchaParentElement.parentElement!.querySelector("#drawText1") as HTMLInputElement | null; - - if (captchaInput) { - captchaInput.value = captcha.value.replaceAll(" ", ""); - captchaParentElement.parentElement!.style.display = "none"; - } - } - } - - setTimeout(autofillCaptcha, 1000); -}; - -autofillCaptcha(); diff --git a/src/scripts/login.ts b/src/scripts/login.ts index d2e7594..6302cd3 100644 --- a/src/scripts/login.ts +++ b/src/scripts/login.ts @@ -1,46 +1,88 @@ +import { interceptPost, interceptGet } from "@/shared/intercept-jquery-ajax"; + document.addEventListener("DOMContentLoaded", () => { const proxiedPost = $.post; + const proxiedGet = $.get; - $.post = function() { - if (arguments[0].endsWith("viewLoginAreaAction")) { + interceptPost("viewLoginAreaAction", args => { + const callback = args[1]; + args[1] = (html: any) => { + callback(html); + const captchaValueElement = document.getElementById("txtCaptcha") as HTMLInputElement; + const captchaInputElement = document.getElementById("txtInput") as HTMLInputElement; + captchaValueElement.value = "FFFFFF"; + captchaInputElement.value = "FFFFFF"; (window as any).DrawLoginCaptcha = () => {}; - const callback = arguments[1]; - arguments[1] = (html: any) => { - callback(html); - const captchaValueElement = document.getElementById("txtCaptcha") as HTMLInputElement; - const captchaInputElement = document.getElementById("txtInput") as HTMLInputElement; - captchaValueElement.value = "ffffff"; - captchaInputElement.value = "ffffff"; - captchaValueElement.style.display = "none"; - captchaInputElement.style.display = "none"; - (document.querySelector(".captcharefresh") as HTMLElement).style.display = "none"; - } - } else if (arguments[0].endsWith("viewPasswordRecoveryArea")) { + (window as any).validateLoginCaptcha = () => true; + captchaValueElement.style.display = "none"; + captchaInputElement.style.display = "none"; + (document.querySelector(".captcharefresh") as HTMLElement).style.display = "none"; + } + }); + interceptPost("viewPasswordRecoveryArea", args => { + const callback = args[1]; + args[1] = (html: any) => { + callback(html); + const captchaInputElement = document.getElementById("dText") as HTMLInputElement; + const captchaValueElement = document.getElementById("captaText") as HTMLInputElement; + captchaValueElement.value = "FFFFFF"; + captchaInputElement.value = "FFFFFF"; (window as any).Captcha = () => {}; - const callback = arguments[1]; - arguments[1] = (html: any) => { - callback(html); - const captchaInputElement = document.getElementById("dText") as HTMLInputElement; - const captchaValueElement = document.getElementById("captaText") as HTMLInputElement; - captchaValueElement.value = "ffffff"; - captchaInputElement.value = "ffffff"; - captchaValueElement.style.display = "none"; - captchaInputElement.style.display = "none"; - (document.getElementById("captchaRef") as HTMLElement).style.display = "none"; + captchaValueElement.style.display = "none"; + captchaInputElement.style.display = "none"; + (document.getElementById("captchaRef") as HTMLElement).style.display = "none"; + } + }); + interceptPost("login.action", args => { + const callback = args[2]; + args[2] = (data: any) => { + if (!data.exception && data.checkmsg === "success") { + window.localStorage.setItem("loginData", btoa(JSON.stringify(args[1]))); } - } else if (arguments[0].endsWith("login.action")) { - const callback = arguments[2]; - arguments[2] = (data: any) => { - if (!data.exception && data.checkmsg === "success") { - window.localStorage.setItem("loginData", btoa(JSON.stringify(arguments[1]))); - } - callback(data); - }; + callback(data); + (document.getElementById("txtInput") as HTMLInputElement).value = "FFFFFF"; + }; + }); + interceptPost("changePassword.action", args => { + const callback = args[2]; + args[2] = (data: any) => { + callback(data); + (document.getElementById("txtInput") as HTMLInputElement).value = "FFFFFF"; + }; + }); + interceptGet("viewRegistrationAreaAction", args => { + const callback = args[1]; + args[1] = (html: any) => { + callback(html); + const captchaInputElement = document.getElementById("regInputCaptcha") as HTMLInputElement; + const captchaValueElement = document.getElementById("regCaptcha") as HTMLInputElement; + captchaValueElement.value = "FFFFFF"; + captchaInputElement.value = "FFFFFF"; + (document.querySelector("#registrationForm > div > div:nth-child(5) > div:nth-child(3)") as HTMLElement).style.display = "none"; + (document.querySelector("#registrationForm > div > div:nth-child(5) > div:nth-child(4)") as HTMLElement).style.display = "none"; + (document.querySelector("#registrationForm > div > div:nth-child(5) > div:nth-child(5)") as HTMLElement).style.display = "none"; + (window as any).DrawRegistrationCaptcha = () => {}; + (window as any).validateRegistrationCaptcha = () => true; } - - return proxiedPost.apply(this, Array.from(arguments) as any); - }; + }); + interceptGet("logout", args => { + window.localStorage.removeItem("loginData"); + }); + interceptGet("viewChangePasswordAction", args => { + const callback = args[1]; + args[1] = (html: any) => { + callback(html); + const captchaValueElement = document.getElementById("txtCaptcha") as HTMLInputElement; + const captchaInputElement = document.getElementById("txtInput") as HTMLInputElement; + captchaValueElement.value = "FFFFFF"; + captchaInputElement.value = "FFFFFF"; + (window as any).DrawLoginCaptcha = () => {}; + captchaValueElement.style.display = "none"; + captchaInputElement.style.display = "none"; + (document.querySelector(".captcharefresh") as HTMLElement).style.display = "none"; + } + }); setInterval(() => { let loginData = window.localStorage.getItem("loginData"); diff --git a/src/scripts/stop-blocking.ts b/src/scripts/stop-blocking.ts index f418f66..bf9ae4e 100644 --- a/src/scripts/stop-blocking.ts +++ b/src/scripts/stop-blocking.ts @@ -1,22 +1,22 @@ -const proxiedBind = $.prototype.bind; +document.addEventListener("DOMContentLoaded", () => { + const proxiedBind = $.prototype.bind; -$.prototype.bind = function() { - if (arguments[0].trim() === "cut copy paste") { - arguments[1] = (e: any) => {}; - } + $.prototype.bind = function() { + if (arguments[0].trim() === "cut copy paste") { + arguments[1] = (e: any) => {}; + } - return proxiedBind.apply(this, Array.from(arguments) as any); -} + return proxiedBind.apply(this, Array.from(arguments) as any); + } -const proxiedKeydown = $.prototype.keydown; + const proxiedKeydown = $.prototype.keydown; -$.prototype.keydown = function() { - arguments[0] = (e: any) => true; + $.prototype.keydown = function() { + arguments[0] = (e: any) => true; - return proxiedKeydown.apply(this, Array.from(arguments) as any); -} + return proxiedKeydown.apply(this, Array.from(arguments) as any); + } -document.addEventListener("DOMContentLoaded", () => { $.prototype.bind = proxiedBind; $.prototype.keydown = proxiedKeydown; document.oncontextmenu = new Function("return true") as any; -- cgit v1.2.3