diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2024-02-01 10:00:59 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-01 15:00:59 +0000 |
commit | dfd42bad0b46845ad88d1fdc5fa82b4f03bab0f3 (patch) | |
tree | 04686b943b84b33b8927238be17e4bc0dda7eb62 /ext/js/dom | |
parent | 2356223942a21d1683ac38eed8e7b9485f453d87 (diff) |
Application refactor (#591)
* Rename Yomitan class to Application, change initialization style
* Rename file
* Update init
* Update config
* Remove dead code
Diffstat (limited to 'ext/js/dom')
-rw-r--r-- | ext/js/dom/style-util.js | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/ext/js/dom/style-util.js b/ext/js/dom/style-util.js index ac20e655..e5046e5c 100644 --- a/ext/js/dom/style-util.js +++ b/ext/js/dom/style-util.js @@ -15,8 +15,6 @@ * along with this program. If not, see <https://www.gnu.org/licenses/>. */ -import {yomitan} from '../yomitan.js'; - /** @type {Map<string, ?HTMLStyleElement|HTMLLinkElement>} */ const injectedStylesheets = new Map(); /** @type {WeakMap<Node, Map<string, ?HTMLStyleElement|HTMLLinkElement>>} */ @@ -54,6 +52,7 @@ function setInjectedStylesheet(id, parentNode, value) { } /** + * @param {import('../application.js').Application} application * @param {string} id * @param {'code'|'file'|'file-content'} type * @param {string} value @@ -62,8 +61,8 @@ function setInjectedStylesheet(id, parentNode, value) { * @returns {Promise<?HTMLStyleElement|HTMLLinkElement>} * @throws {Error} */ -export async function loadStyle(id, type, value, useWebExtensionApi = false, parentNode = null) { - if (useWebExtensionApi && yomitan.isExtensionUrl(window.location.href)) { +export async function loadStyle(application, id, type, value, useWebExtensionApi = false, parentNode = null) { + if (useWebExtensionApi && application.isExtensionUrl(window.location.href)) { // Permissions error will occur if trying to use the WebExtension API to inject into an extension page useWebExtensionApi = false; } @@ -79,7 +78,7 @@ export async function loadStyle(id, type, value, useWebExtensionApi = false, par } if (type === 'file-content') { - value = await yomitan.api.getStylesheetContent(value); + value = await application.api.getStylesheetContent(value); type = 'code'; useWebExtensionApi = false; } @@ -91,7 +90,7 @@ export async function loadStyle(id, type, value, useWebExtensionApi = false, par } setInjectedStylesheet(id, parentNode, null); - await yomitan.api.injectStylesheet(type, value); + await application.api.injectStylesheet(type, value); return null; } |