From a4715935cb4d910f5b13b398ca4742cf30c8f784 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Fri, 2 Jul 2021 22:12:02 -0400 Subject: [PATCH] More CssStyleApplier updates (#1785) * Update eslint rules for css-style-applier.js * Don't use chrome.runtime.getURL * Update CSP to allow inline styles --- .eslintrc.json | 3 +++ dev/data/manifest-variants.json | 2 +- ext/js/dom/css-style-applier.js | 2 +- ext/manifest.json | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index 736a4c0b..9d47b369 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -112,6 +112,7 @@ "ext/js/core.js", "ext/js/data/anki-note-data-creator.js", "ext/js/display/structured-content-generator.js", + "ext/js/dom/css-style-applier.js", "ext/js/language/dictionary-data-util.js", "ext/js/templates/template-renderer.js" ], @@ -125,6 +126,7 @@ "ext/js/core.js", "ext/js/data/anki-note-data-creator.js", "ext/js/display/structured-content-generator.js", + "ext/js/dom/css-style-applier.js", "ext/js/language/dictionary-data-util.js", "ext/js/templates/template-renderer.js" ], @@ -155,6 +157,7 @@ "ext/js/yomichan.js", "ext/js/data/anki-note-data-creator.js", "ext/js/display/structured-content-generator.js", + "ext/js/dom/css-style-applier.js", "ext/js/language/dictionary-data-util.js", "ext/js/templates/template-renderer.js" ], diff --git a/dev/data/manifest-variants.json b/dev/data/manifest-variants.json index 089b85c4..ca08c09c 100644 --- a/dev/data/manifest-variants.json +++ b/dev/data/manifest-variants.json @@ -73,7 +73,7 @@ "pages": [ "template-renderer.html" ], - "content_security_policy": "sandbox allow-scripts; default-src 'self'; script-src 'self' 'unsafe-eval'" + "content_security_policy": "sandbox allow-scripts; default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'unsafe-inline'" }, "permissions": [ "", diff --git a/ext/js/dom/css-style-applier.js b/ext/js/dom/css-style-applier.js index 32d7ef0f..593e7a46 100644 --- a/ext/js/dom/css-style-applier.js +++ b/ext/js/dom/css-style-applier.js @@ -83,7 +83,7 @@ class CssStyleApplier { // Private async _fetchJsonAsset(url) { - const response = await fetch(chrome.runtime.getURL(url), { + const response = await fetch(url, { method: 'GET', mode: 'no-cors', cache: 'default', diff --git a/ext/manifest.json b/ext/manifest.json index a5c70ebd..73cbbe05 100644 --- a/ext/manifest.json +++ b/ext/manifest.json @@ -72,7 +72,7 @@ "pages": [ "template-renderer.html" ], - "content_security_policy": "sandbox allow-scripts; default-src 'self'; script-src 'self' 'unsafe-eval'" + "content_security_policy": "sandbox allow-scripts; default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'unsafe-inline'" }, "permissions": [ "",