From dfd42bad0b46845ad88d1fdc5fa82b4f03bab0f3 Mon Sep 17 00:00:00 2001 From: toasted-nutbread Date: Thu, 1 Feb 2024 10:00:59 -0500 Subject: Application refactor (#591) * Rename Yomitan class to Application, change initialization style * Rename file * Update init * Update config * Remove dead code --- ext/js/dom/style-util.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'ext/js/dom') 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 . */ -import {yomitan} from '../yomitan.js'; - /** @type {Map} */ const injectedStylesheets = new Map(); /** @type {WeakMap>} */ @@ -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} * @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; } -- cgit v1.2.3