diff options
| author | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2023-03-24 11:36:54 +0530 |
|---|---|---|
| committer | Arpit Chakladar <54011232+arpitchakladar@users.noreply.github.com> | 2023-03-24 11:36:54 +0530 |
| commit | feac7acb91a78b117241abdd0a5d80f778e15f06 (patch) | |
| tree | ebee27b43105aeed1048e86afb1e6e3d2b7e1075 /config/webpack/plugins/inject-script-webpack-plugin/get-injection-code.js | |
| parent | a9f2d88e1e5b1c7ddf524db8b5b185b8485f8d48 (diff) | |
| download | banglar-bhumi-utils-feac7acb91a78b117241abdd0a5d80f778e15f06.tar.gz banglar-bhumi-utils-feac7acb91a78b117241abdd0a5d80f778e15f06.zip | |
Overriding the javascript on the page instead of locally replacing it.
Diffstat (limited to 'config/webpack/plugins/inject-script-webpack-plugin/get-injection-code.js')
| -rw-r--r-- | config/webpack/plugins/inject-script-webpack-plugin/get-injection-code.js | 18 |
1 files changed, 0 insertions, 18 deletions
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 deleted file mode 100644 index 2993c44..0000000 --- a/config/webpack/plugins/inject-script-webpack-plugin/get-injection-code.js +++ /dev/null @@ -1,18 +0,0 @@ -module.exports.getInjectionCode = code => { - const escapeSequences = [["\b", "\\b"], - ["\f", "\\f"], - ["\n", "\\n"], - ["\r", "\\r"], - ["\t", "\\t"], - ["\v", "\\v"] - ]; - let finalCode = code.replaceAll("`","\\`"); - - for (const escapeSequence of escapeSequences) { - finalCode = finalCode - .replaceAll(escapeSequence[1], "\\" + escapeSequence[1]) - .replaceAll(escapeSequence[0], escapeSequence[1]); - } - - return `(()=>{const o=new MutationObserver(()=>{let t=document.querySelector("head > script:nth-child(54)");if(t){let e=\`(()=>{${finalCode}})();\`;null==t.getAttribute("data-replaced")?(t.innerHTML=e,t.setAttribute("data-replaced","")):t.innerHTML+=e,o.disconnect()}});o.observe(document,{childList:!0,subtree:!0});})();`; -}; |
