diff options
Diffstat (limited to 'ext')
| -rw-r--r-- | ext/js/application.js | 17 | ||||
| -rw-r--r-- | ext/js/dom/style-util.js | 2 | ||||
| -rw-r--r-- | ext/js/extension/web-extension.js | 16 | 
3 files changed, 17 insertions, 18 deletions
| diff --git a/ext/js/application.js b/ext/js/application.js index 227e9d5e..d7ab6725 100644 --- a/ext/js/application.js +++ b/ext/js/application.js @@ -76,14 +76,6 @@ export class Application extends EventDispatcher {              // NOP          } -        /** @type {?string} */ -        this._extensionUrlBase = null; -        try { -            this._extensionUrlBase = this._webExtension.getUrl('/'); -        } catch (e) { -            // NOP -        } -          /** @type {?boolean} */          this._isBackground = null;          /** @type {API} */ @@ -148,15 +140,6 @@ export class Application extends EventDispatcher {          this._webExtension.sendMessagePromise({action: 'applicationReady'});      } -    /** -     * Checks whether or not a URL is an extension URL. -     * @param {string} url The URL to check. -     * @returns {boolean} `true` if the URL is an extension URL, `false` otherwise. -     */ -    isExtensionUrl(url) { -        return this._extensionUrlBase !== null && url.startsWith(this._extensionUrlBase); -    } -      /** */      triggerStorageChanged() {          this.trigger('storageChanged', {}); diff --git a/ext/js/dom/style-util.js b/ext/js/dom/style-util.js index e5046e5c..c2c620f6 100644 --- a/ext/js/dom/style-util.js +++ b/ext/js/dom/style-util.js @@ -62,7 +62,7 @@ function setInjectedStylesheet(id, parentNode, value) {   * @throws {Error}   */  export async function loadStyle(application, id, type, value, useWebExtensionApi = false, parentNode = null) { -    if (useWebExtensionApi && application.isExtensionUrl(window.location.href)) { +    if (useWebExtensionApi && application.webExtension.isExtensionUrl(window.location.href)) {          // Permissions error will occur if trying to use the WebExtension API to inject into an extension page          useWebExtensionApi = false;      } diff --git a/ext/js/extension/web-extension.js b/ext/js/extension/web-extension.js index 2aafbe92..bdc9b1b3 100644 --- a/ext/js/extension/web-extension.js +++ b/ext/js/extension/web-extension.js @@ -26,6 +26,13 @@ export class WebExtension extends EventDispatcher {          super();          /** @type {boolean} */          this._unloaded = false; +        /** @type {?string} */ +        this._extensionBaseUrl = null; +        try { +            this._extensionBaseUrl = this.getUrl('/'); +        } catch (e) { +            // NOP +        }      }      /** @type {boolean} */ @@ -105,4 +112,13 @@ export class WebExtension extends EventDispatcher {          this._unloaded = true;          this.trigger('unloaded', {});      } + +    /** +     * Checks whether or not a URL is an extension URL. +     * @param {string} url The URL to check. +     * @returns {boolean} `true` if the URL is an extension URL, `false` otherwise. +     */ +    isExtensionUrl(url) { +        return this._extensionBaseUrl !== null && url.startsWith(this._extensionBaseUrl); +    }  } |