aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--package.json3
-rw-r--r--src/scripts.json2
-rw-r--r--src/scripts/optimize.ts (renamed from src/scripts/block-unnecessary.ts)16
-rw-r--r--yarn.lock5
4 files changed, 7 insertions, 19 deletions
diff --git a/package.json b/package.json
index 7b0fb5f..2085ef6 100644
--- a/package.json
+++ b/package.json
@@ -18,7 +18,6 @@
"ts-loader": "^9.4.2",
"typescript": "^4.9.5",
"webpack": "^5.75.0",
- "webpack-cli": "^5.0.1",
- "webpack-virtual-modules": "^0.5.0"
+ "webpack-cli": "^5.0.1"
}
}
diff --git a/src/scripts.json b/src/scripts.json
index 8e8d0bd..ee042b2 100644
--- a/src/scripts.json
+++ b/src/scripts.json
@@ -1,6 +1,6 @@
{
"before": {
- "block-unnecessary.ts": "*"
+ "optimize.ts": "*"
},
"injected": {
"stop-blocking.js": "*"
diff --git a/src/scripts/block-unnecessary.ts b/src/scripts/optimize.ts
index 65d610a..3994333 100644
--- a/src/scripts/block-unnecessary.ts
+++ b/src/scripts/optimize.ts
@@ -1,25 +1,19 @@
-let replace: (any[] | undefined)[] = [
+const replace: (any[] | undefined)[] = [
["head > script:nth-child(34)", { src: "" }],
- ["head > script:nth-child(35)", { src: "https://code.jquery.com/jquery-1.12.4.min.js", crossorigin: "anonymous" }],
["head > script:nth-child(43)", { src: "" }]
];
let count = 0;
-let notDone = true;
const observer = new MutationObserver(() => {
- if (notDone) {
- const meta = document.querySelector("head > meta:nth-child(2)");
- if (meta) {
- meta.setAttribute("http-equiv", "Content-Security-Policy");
- meta.setAttribute("content", "default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *");
- notDone = false;
- }
- }
for (let i = 0; i < replace.length; i++) {
if (replace[i]) {
const element = document.querySelector(replace[i]![0]) as HTMLElement | null;
if (element) {
const attributes = replace[i]![1];
+ if (attributes.innerHTML) {
+ element.innerHTML = attributes.innerHTML;
+ }
+ attributes.innerHTML = undefined;
for (const attribute in attributes) {
element.setAttribute(attribute, attributes[attribute]);
}
diff --git a/yarn.lock b/yarn.lock
index 1f6f21a..6179dc9 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1057,11 +1057,6 @@ webpack-sources@^3.2.3:
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-3.2.3.tgz#2d4daab8451fd4b240cc27055ff6a0c2ccea0cde"
integrity sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==
-webpack-virtual-modules@^0.5.0:
- version "0.5.0"
- resolved "https://registry.yarnpkg.com/webpack-virtual-modules/-/webpack-virtual-modules-0.5.0.tgz#362f14738a56dae107937ab98ea7062e8bdd3b6c"
- integrity sha512-kyDivFZ7ZM0BVOUteVbDFhlRt7Ah/CSPwJdi8hBpkK7QLumUqdLtVfm/PX/hkcnrvr0i77fO5+TjZ94Pe+C9iw==
-
webpack@^5.75.0:
version "5.75.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.75.0.tgz#1e440468647b2505860e94c9ff3e44d5b582c152"