aboutsummaryrefslogtreecommitdiff
path: root/ext/js/background
diff options
context:
space:
mode:
authorCashew <52880648+cashewnuttynuts@users.noreply.github.com>2024-04-09 17:52:37 +0900
committerGitHub <noreply@github.com>2024-04-09 08:52:37 +0000
commit11e58d616cffbadc5a0c6ab72e5fc803f8c4e70b (patch)
tree947111c2e8567db869b700a0687b16a67b26f1dc /ext/js/background
parent0663774b02faeb108d4b18d8f8a7e6e93e277313 (diff)
Fix duplicated title (#735)
* fix duplicated title * add comment * fix lint * change to use action.default_title --------- Co-authored-by: StefanVukovic99 <stefanvukovic44@gmail.com>
Diffstat (limited to 'ext/js/background')
-rw-r--r--ext/js/background/backend.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index 6cae9cea..569cb53d 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -253,7 +253,7 @@ export class Backend {
this._prepareInternalSync();
this._permissions = await getAllPermissions();
- this._defaultBrowserActionTitle = await this._getBrowserIconTitle();
+ this._defaultBrowserActionTitle = this._getBrowserIconTitle();
this._badgePrepareDelayTimer = setTimeout(() => {
this._badgePrepareDelayTimer = null;
this._updateBadge();
@@ -1616,15 +1616,18 @@ export class Backend {
}
/**
- * @returns {Promise<string>}
+ * Returns the action's default title.
+ * @throws {Error}
+ * @returns {string}
*/
_getBrowserIconTitle() {
- return (
- isObjectNotArray(chrome.action) &&
- typeof chrome.action.getTitle === 'function' ?
- new Promise((resolve) => { chrome.action.getTitle({}, resolve); }) :
- Promise.resolve('')
- );
+ const manifest = /** @type {chrome.runtime.ManifestV3} */ (chrome.runtime.getManifest());
+ const action = manifest.action;
+ if (typeof action === 'undefined') { throw new Error('Failed to find action'); }
+ const defaultTitle = action.default_title;
+ if (typeof defaultTitle === 'undefined') { throw new Error('Failed to find default_title'); }
+
+ return defaultTitle;
}
/**