aboutsummaryrefslogtreecommitdiffstats
path: root/config/webpack/utils
diff options
context:
space:
mode:
Diffstat (limited to 'config/webpack/utils')
-rw-r--r--config/webpack/utils/filename-hash.js15
-rw-r--r--config/webpack/utils/get-injection-code.js33
-rw-r--r--config/webpack/utils/script-runtime.js2
3 files changed, 13 insertions, 37 deletions
diff --git a/config/webpack/utils/filename-hash.js b/config/webpack/utils/filename-hash.js
index bd66647..e0d8a6d 100644
--- a/config/webpack/utils/filename-hash.js
+++ b/config/webpack/utils/filename-hash.js
@@ -1,10 +1,19 @@
const crypto = require("crypto");
-module.exports.getFileNameHash = (fileName, prefix) => {
- const hash = crypto
+module.exports.getFileNameHash = (fileName, prefix, justHash = false) => {
+ let hash = crypto
.createHash("md5")
.update(`${prefix}-${fileName}`)
.digest("hex");
- return production ? hash : `${fileName}-${hash.substring(16)}`;
+ if (production) {
+ return hash;
+ } else {
+ hash = hash.substring(16);
+ if (justHash) {
+ return hash;
+ } else {
+ return `${fileName}-${hash}`;
+ }
+ }
};
diff --git a/config/webpack/utils/get-injection-code.js b/config/webpack/utils/get-injection-code.js
deleted file mode 100644
index 0a57ef9..0000000
--- a/config/webpack/utils/get-injection-code.js
+++ /dev/null
@@ -1,33 +0,0 @@
-const insertAtIndex = (str, substring, index) => str.slice(0, index) + substring + str.slice(index);
-
-module.exports.getInjectionCode = (code, front) => {
- let finalCode = code
- .replaceAll("\\", "\\\\")
- .replaceAll("`","\\`")
- .replaceAll("${", "\\${");
-
- let i = 0;
-
- while (true) {
- i = finalCode.indexOf("chrome.runtime", i);
-
- if (i < 0) {
- break;
- }
-
- finalCode = insertAtIndex(finalCode, "\"${", i);
- i = finalCode.indexOf(")", i) + 1;
-
- if (i <= 0) {
- break;
- }
-
- finalCode = insertAtIndex(finalCode, "}\"", i);
- }
-
- const concatenationCode = front
- ? "t.innerHTML=i+t.innerHTML"
- : "t.innerHTML+=i";
-
- return `(()=>{let e=new MutationObserver(()=>{let t=document.querySelector("head > script:nth-child(54)");if(t){let i=\`${finalCode}\`;${concatenationCode},e.disconnect()}});e.observe(document,{childList:!0,subtree:!0})})();`;
-};
diff --git a/config/webpack/utils/script-runtime.js b/config/webpack/utils/script-runtime.js
index f424168..a89d4b8 100644
--- a/config/webpack/utils/script-runtime.js
+++ b/config/webpack/utils/script-runtime.js
@@ -1,7 +1,7 @@
module.exports.getScriptRuntimeFromType = scriptType => {
switch (scriptType) {
case "before":
- case "injected":
+ case "injected-after":
case "injected-before":
return "document_start";