From 3b29d138bee5e98c9536d3606de3e4b5378338f0 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> Date: Thu, 23 Mar 2023 14:26:18 +0530 Subject: Some minor changes. --- .../create-manifest-webpack-plugin/index.js | 12 ++++++------ .../get-injection-code.js | 2 +- config/webpack/utils/format-scripts.js | 2 -- src/scripts.json | 7 ++++--- src/scripts/autofill-captcha.ts | 8 ++++++-- src/scripts/autofill-otps.ts | 22 ---------------------- src/scripts/autofill-otps/grievance-application.ts | 22 ++++++++++++++++++++++ src/scripts/show-plot-information.ts | 11 +++++++++++ 8 files changed, 50 insertions(+), 36 deletions(-) delete mode 100644 src/scripts/autofill-otps.ts create mode 100644 src/scripts/autofill-otps/grievance-application.ts create mode 100644 src/scripts/show-plot-information.ts diff --git a/config/webpack/plugins/create-manifest-webpack-plugin/index.js b/config/webpack/plugins/create-manifest-webpack-plugin/index.js index 8705039..f571986 100644 --- a/config/webpack/plugins/create-manifest-webpack-plugin/index.js +++ b/config/webpack/plugins/create-manifest-webpack-plugin/index.js @@ -23,8 +23,10 @@ class CreateManifestPlugin { for (const scriptPath in scripts) { for (const scriptType in scripts[scriptPath]) { const matches = [`*://banglarbhumi.gov.in/BanglarBhumi/${scriptPath}`]; - if (scriptPath !== "*") + + if (scriptPath === "Home") matches.push(`*://banglarbhumi.gov.in/BanglarBhumi/${scriptPath}.action`); + manifest.content_scripts.push({ matches, js: [`scripts/${getFileNameHash(scriptPath)}/${scriptType}.js`], @@ -35,17 +37,15 @@ class CreateManifestPlugin { const resources = []; - for (const assetName in assets) { - if (/^assets\/.*\.(jpg|png|gif)$/.test(assetName)) { + for (const assetName in assets) + if (/^assets\/.*\.(jpg|png|gif)$/.test(assetName)) resources.push(assetName); - } - } if (resources.length > 0) { manifest.web_accessible_resources = [ { resources, - matches: [ "" ] + matches: [""] } ]; } diff --git a/config/webpack/plugins/inject-script-webpack-plugin/get-injection-code.js b/config/webpack/plugins/inject-script-webpack-plugin/get-injection-code.js index 90a1cb7..6f3c9b3 100644 --- a/config/webpack/plugins/inject-script-webpack-plugin/get-injection-code.js +++ b/config/webpack/plugins/inject-script-webpack-plugin/get-injection-code.js @@ -1 +1 @@ -module.exports = code => `const o=new MutationObserver(()=>{let t=document.querySelector("head > script:nth-child(54)");if(t){let e=\`(()=>{${code.replaceAll("`","\\`")}})();\`;null==t.getAttribute("data-replaced")?(t.innerHTML=e,t.setAttribute("data-replaced","")):t.innerHTML+=e,o.disconnect()}});o.observe(document,{childList:!0,subtree:!0});`; +module.exports = code => `(()=>{const o=new MutationObserver(()=>{let t=document.querySelector("head > script:nth-child(54)");if(t){let e=\`(()=>{${code.replaceAll("`","\\`")}})();\`;null==t.getAttribute("data-replaced")?(t.innerHTML=e,t.setAttribute("data-replaced","")):t.innerHTML+=e,o.disconnect()}});o.observe(document,{childList:!0,subtree:!0});})();`; diff --git a/config/webpack/utils/format-scripts.js b/config/webpack/utils/format-scripts.js index cfa11bc..0961674 100644 --- a/config/webpack/utils/format-scripts.js +++ b/config/webpack/utils/format-scripts.js @@ -11,7 +11,5 @@ module.exports.formatScripts = scripts => { } } - - return _scripts; }; diff --git a/src/scripts.json b/src/scripts.json index c2ccf24..f5611fe 100644 --- a/src/scripts.json +++ b/src/scripts.json @@ -5,12 +5,13 @@ }, "injected": { "stop-blocking.js": "*", - "autofill-otps.ts": "*", - "auto-login.ts": "*" + "auto-login.ts": "*", + "autofill-otps/grievance-application.ts": "GrievAppViewAction.action", + "show-plot-information.ts": "KnowYourProperty.action" }, "loaded": { "autofill-captcha.ts": "*", "optimize/home-page/styles.ts": "Home", - "fix-application-receipt.ts": "Apprecrep" + "fix-application-receipt.ts": "Apprecrep.action" } } diff --git a/src/scripts/autofill-captcha.ts b/src/scripts/autofill-captcha.ts index 8caac1c..f290fda 100644 --- a/src/scripts/autofill-captcha.ts +++ b/src/scripts/autofill-captcha.ts @@ -1,4 +1,4 @@ -setInterval(() => { +const autofillCaptcha = () => { let captchas = Array.from(document.querySelectorAll("#txtCaptcha")) as HTMLInputElement[]; for (const captcha of captchas) { @@ -21,4 +21,8 @@ setInterval(() => { } } } -}, 5000); + + setTimeout(autofillCaptcha, 1000); +}; + +autofillCaptcha(); diff --git a/src/scripts/autofill-otps.ts b/src/scripts/autofill-otps.ts deleted file mode 100644 index 140504c..0000000 --- a/src/scripts/autofill-otps.ts +++ /dev/null @@ -1,22 +0,0 @@ -document.addEventListener("DOMContentLoaded", () => { - const proxiedPost = $.post; - - $.post = function() { - let element: HTMLInputElement | null = null; - if (arguments[0].endsWith("MISPetitionSmsSend.action")) { - element = document.querySelector("input[name=mobile_Code]") as HTMLInputElement; - } else if (arguments[0].endsWith("MISPetitionEmailSend.action")) { - element = document.querySelector("input[name=txtemail_Code]") as HTMLInputElement; - } - - if (element) { - const callback = arguments[2]; - arguments[2] = (data: any) => { - element!.value = data?.messageShow || ""; - callback(data); - }; - } - - return proxiedPost.apply(this, Array.from(arguments) as any); - }; -}); diff --git a/src/scripts/autofill-otps/grievance-application.ts b/src/scripts/autofill-otps/grievance-application.ts new file mode 100644 index 0000000..140504c --- /dev/null +++ b/src/scripts/autofill-otps/grievance-application.ts @@ -0,0 +1,22 @@ +document.addEventListener("DOMContentLoaded", () => { + const proxiedPost = $.post; + + $.post = function() { + let element: HTMLInputElement | null = null; + if (arguments[0].endsWith("MISPetitionSmsSend.action")) { + element = document.querySelector("input[name=mobile_Code]") as HTMLInputElement; + } else if (arguments[0].endsWith("MISPetitionEmailSend.action")) { + element = document.querySelector("input[name=txtemail_Code]") as HTMLInputElement; + } + + if (element) { + const callback = arguments[2]; + arguments[2] = (data: any) => { + element!.value = data?.messageShow || ""; + callback(data); + }; + } + + return proxiedPost.apply(this, Array.from(arguments) as any); + }; +}); diff --git a/src/scripts/show-plot-information.ts b/src/scripts/show-plot-information.ts new file mode 100644 index 0000000..aec56d6 --- /dev/null +++ b/src/scripts/show-plot-information.ts @@ -0,0 +1,11 @@ +declare function loadKhatian(): void; + +document.addEventListener("DOMContentLoaded", () => { + (window as any).customLoadKhatian = () => { + loadKhatian(); + setTimeout(() => { + (document.querySelector("#khdetails > table > tbody > tr > td:nth-child(1) > div:nth-child(5) > table > tbody") as any).style.height = "auto"; + }, 1000); + }; + document.querySelector("#khbutton")!.setAttribute("onclick", "customLoadKhatian()"); +}); -- cgit v1.2.3