aboutsummaryrefslogtreecommitdiff
path: root/ext/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js')
-rw-r--r--ext/js/background/backend.js6
-rw-r--r--ext/js/background/offscreen-proxy.js2
-rw-r--r--ext/js/background/profile-conditions-util.js2
-rw-r--r--ext/js/data/permissions-util.js72
-rw-r--r--ext/js/dictionary/dictionary-data-util.js2
-rw-r--r--ext/js/dom/dom-text-scanner.js6
-rw-r--r--ext/js/language/ja/japanese.js6
-rw-r--r--ext/js/language/translator.js2
-rw-r--r--ext/js/pages/permissions-main.js4
9 files changed, 55 insertions, 47 deletions
diff --git a/ext/js/background/backend.js b/ext/js/background/backend.js
index 8ab56232..e246f0bb 100644
--- a/ext/js/background/backend.js
+++ b/ext/js/background/backend.js
@@ -437,7 +437,7 @@ export class Backend {
/** @type {import('api').ApiHandler<'requestBackendReadySignal'>} */
_onApiRequestBackendReadySignal(_params, sender) {
- // tab ID isn't set in background (e.g. browser_action)
+ // Tab ID isn't set in background (e.g. browser_action)
/** @type {import('application').ApiMessage<'applicationBackendReady'>} */
const data = {action: 'applicationBackendReady'};
if (typeof sender.tab === 'undefined') {
@@ -1547,7 +1547,7 @@ export class Backend {
return (
isObject(chrome.action) &&
typeof chrome.action.getTitle === 'function' ?
- new Promise((resolve) => chrome.action.getTitle({}, resolve)) :
+ new Promise((resolve) => { chrome.action.getTitle({}, resolve); }) :
Promise.resolve('')
);
}
@@ -2601,7 +2601,7 @@ export class Backend {
const match = /^\d+/.exec(version);
if (match === null) { return; }
- const versionNumber = Number.parseInt(match[0]);
+ const versionNumber = Number.parseInt(match[0], 10);
if (!(Number.isFinite(versionNumber) && versionNumber >= 77)) { return; }
await navigator.storage.persist();
diff --git a/ext/js/background/offscreen-proxy.js b/ext/js/background/offscreen-proxy.js
index 085048c1..5a79f41a 100644
--- a/ext/js/background/offscreen-proxy.js
+++ b/ext/js/background/offscreen-proxy.js
@@ -85,7 +85,7 @@ export class OffscreenProxy {
*/
async _hasOffscreenDocument() {
const offscreenUrl = chrome.runtime.getURL('offscreen.html');
- if (!chrome.runtime.getContexts) { // chrome version below 116
+ if (!chrome.runtime.getContexts) { // Chrome version below 116
// Clients: https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerGlobalScope/clients
// @ts-expect-error - Types not set up for service workers yet
const matchedClients = await clients.matchAll();
diff --git a/ext/js/background/profile-conditions-util.js b/ext/js/background/profile-conditions-util.js
index e2d58725..4e4e38d7 100644
--- a/ext/js/background/profile-conditions-util.js
+++ b/ext/js/background/profile-conditions-util.js
@@ -229,7 +229,7 @@ function createSchemaPopupLevelGreaterThanOrEqual(value) {
};
}
-// url schema creation functions
+// URL schema creation functions
/**
* @param {string} value
diff --git a/ext/js/data/permissions-util.js b/ext/js/data/permissions-util.js
index 097fe34d..1ccc630f 100644
--- a/ext/js/data/permissions-util.js
+++ b/ext/js/data/permissions-util.js
@@ -40,14 +40,16 @@ function ankiFieldMarkerMayUseClipboard(marker) {
* @returns {Promise<boolean>}
*/
export function hasPermissions(permissions) {
- return new Promise((resolve, reject) => chrome.permissions.contains(permissions, (result) => {
- const e = chrome.runtime.lastError;
- if (e) {
- reject(new Error(e.message));
- } else {
- resolve(result);
- }
- }));
+ return new Promise((resolve, reject) => {
+ chrome.permissions.contains(permissions, (result) => {
+ const e = chrome.runtime.lastError;
+ if (e) {
+ reject(new Error(e.message));
+ } else {
+ resolve(result);
+ }
+ });
+ });
}
/**
@@ -58,22 +60,26 @@ export function hasPermissions(permissions) {
export function setPermissionsGranted(permissions, shouldHave) {
return (
shouldHave ?
- new Promise((resolve, reject) => chrome.permissions.request(permissions, (result) => {
- const e = chrome.runtime.lastError;
- if (e) {
- reject(new Error(e.message));
- } else {
- resolve(result);
- }
- })) :
- new Promise((resolve, reject) => chrome.permissions.remove(permissions, (result) => {
- const e = chrome.runtime.lastError;
- if (e) {
- reject(new Error(e.message));
- } else {
- resolve(!result);
- }
- }))
+ new Promise((resolve, reject) => {
+ chrome.permissions.request(permissions, (result) => {
+ const e = chrome.runtime.lastError;
+ if (e) {
+ reject(new Error(e.message));
+ } else {
+ resolve(result);
+ }
+ });
+ }) :
+ new Promise((resolve, reject) => {
+ chrome.permissions.remove(permissions, (result) => {
+ const e = chrome.runtime.lastError;
+ if (e) {
+ reject(new Error(e.message));
+ } else {
+ resolve(!result);
+ }
+ });
+ })
);
}
@@ -81,14 +87,16 @@ export function setPermissionsGranted(permissions, shouldHave) {
* @returns {Promise<chrome.permissions.Permissions>}
*/
export function getAllPermissions() {
- return new Promise((resolve, reject) => chrome.permissions.getAll((result) => {
- const e = chrome.runtime.lastError;
- if (e) {
- reject(new Error(e.message));
- } else {
- resolve(result);
- }
- }));
+ return new Promise((resolve, reject) => {
+ chrome.permissions.getAll((result) => {
+ const e = chrome.runtime.lastError;
+ if (e) {
+ reject(new Error(e.message));
+ } else {
+ resolve(result);
+ }
+ });
+ });
}
/**
diff --git a/ext/js/dictionary/dictionary-data-util.js b/ext/js/dictionary/dictionary-data-util.js
index a2a106cc..a90668f4 100644
--- a/ext/js/dictionary/dictionary-data-util.js
+++ b/ext/js/dictionary/dictionary-data-util.js
@@ -286,7 +286,7 @@ export function isNonNounVerbOrAdjective(wordClasses) {
case 'vs':
isVerbOrAdjective = true;
isSuruVerb = true;
- // falls through
+ // Falls through
case 'n':
isNoun = true;
break;
diff --git a/ext/js/dom/dom-text-scanner.js b/ext/js/dom/dom-text-scanner.js
index 5b3ea564..e263d9f3 100644
--- a/ext/js/dom/dom-text-scanner.js
+++ b/ext/js/dom/dom-text-scanner.js
@@ -551,10 +551,10 @@ export class DOMTextScanner {
case 'block':
case 'flex':
case 'grid':
- case 'list': // list-item
- case 'table': // table, table-*
+ case 'list': // Also includes: list-item
+ case 'table': // Also includes: table, table-*
return true;
- case 'ruby': // ruby-*
+ case 'ruby': // Also includes: ruby-*
return (pos >= 0);
default:
return false;
diff --git a/ext/js/language/ja/japanese.js b/ext/js/language/ja/japanese.js
index 818daa0b..2c9a1f7f 100644
--- a/ext/js/language/ja/japanese.js
+++ b/ext/js/language/ja/japanese.js
@@ -557,17 +557,17 @@ export function convertHalfWidthKanaToFullWidth(text, sourceMap = null) {
let index = 0;
switch (text.charCodeAt(i + 1)) {
- case 0xff9e: // dakuten
+ case 0xff9e: // Dakuten
index = 1;
break;
- case 0xff9f: // handakuten
+ case 0xff9f: // Handakuten
index = 2;
break;
}
let c2 = mapping[index];
if (index > 0) {
- if (c2 === '-') { // invalid
+ if (c2 === '-') { // Invalid
index = 0;
c2 = mapping[0];
} else {
diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js
index 2ba1ce0d..b2342e8d 100644
--- a/ext/js/language/translator.js
+++ b/ext/js/language/translator.js
@@ -1609,7 +1609,7 @@ export class Translator {
sequence: rawSequence,
rules
} = databaseEntry;
- // cast is safe because getDeinflections filters out deinflection definitions
+ // Cast is safe because getDeinflections filters out deinflection definitions
const contentDefinitions = /** @type {import('dictionary-data').TermGlossaryContent[]} */ (definitions);
const reading = (rawReading.length > 0 ? rawReading : term);
const {index: dictionaryIndex, priority: dictionaryPriority} = this._getDictionaryOrder(dictionary, enabledDictionaryMap);
diff --git a/ext/js/pages/permissions-main.js b/ext/js/pages/permissions-main.js
index 17169c12..3be97b78 100644
--- a/ext/js/pages/permissions-main.js
+++ b/ext/js/pages/permissions-main.js
@@ -43,14 +43,14 @@ async function setupEnvironmentInfo(api) {
* @returns {Promise<boolean>}
*/
async function isAllowedIncognitoAccess() {
- return await new Promise((resolve) => chrome.extension.isAllowedIncognitoAccess(resolve));
+ return await new Promise((resolve) => { chrome.extension.isAllowedIncognitoAccess(resolve); });
}
/**
* @returns {Promise<boolean>}
*/
async function isAllowedFileSchemeAccess() {
- return await new Promise((resolve) => chrome.extension.isAllowedFileSchemeAccess(resolve));
+ return await new Promise((resolve) => { chrome.extension.isAllowedFileSchemeAccess(resolve); });
}
/**