diff options
Diffstat (limited to 'src/webview')
-rw-r--r-- | src/webview/contextMenuBuilder.ts | 7 | ||||
-rw-r--r-- | src/webview/lib/Userscript.ts | 9 | ||||
-rw-r--r-- | src/webview/recipe.ts | 17 |
3 files changed, 18 insertions, 15 deletions
diff --git a/src/webview/contextMenuBuilder.ts b/src/webview/contextMenuBuilder.ts index 6d904eee3..d18bc56f9 100644 --- a/src/webview/contextMenuBuilder.ts +++ b/src/webview/contextMenuBuilder.ts | |||
@@ -52,8 +52,8 @@ function translatePopup(res, isError: boolean = false) { | |||
52 | z-index: 999999; | 52 | z-index: 999999; |
53 | ${ | 53 | ${ |
54 | isError | 54 | isError |
55 | ? `background: rgb(255 37 37);` | 55 | ? 'background: rgb(255 37 37);' |
56 | : `background: rgb(131 131 131);` | 56 | : 'background: rgb(131 131 131);' |
57 | } | 57 | } |
58 | border-radius: 8px; | 58 | border-radius: 8px; |
59 | top: 5%; | 59 | top: 5%; |
@@ -148,7 +148,7 @@ const contextMenuStringTable: ContextMenuStringTable = { | |||
148 | paste: () => 'Paste', | 148 | paste: () => 'Paste', |
149 | pasteAndMatchStyle: () => 'Paste and match style', | 149 | pasteAndMatchStyle: () => 'Paste and match style', |
150 | searchWith: ({ searchEngine }) => `Search with ${searchEngine}`, | 150 | searchWith: ({ searchEngine }) => `Search with ${searchEngine}`, |
151 | translate: () => `Translate to ...`, | 151 | translate: () => 'Translate to ...', |
152 | quickTranslate: ({ translatorLanguage }) => | 152 | quickTranslate: ({ translatorLanguage }) => |
153 | `Translate to ${translatorLanguage}`, | 153 | `Translate to ${translatorLanguage}`, |
154 | translateLanguage: ({ translatorLanguage }) => `${translatorLanguage}`, | 154 | translateLanguage: ({ translatorLanguage }) => `${translatorLanguage}`, |
@@ -798,6 +798,7 @@ export class ContextMenuBuilder { | |||
798 | callback: { | 798 | callback: { |
799 | (dataURL: any): void; | 799 | (dataURL: any): void; |
800 | (dataURL: any): void; | 800 | (dataURL: any): void; |
801 | // eslint-disable-next-line @typescript-eslint/unified-signatures | ||
801 | (arg0: string): void; | 802 | (arg0: string): void; |
802 | }, | 803 | }, |
803 | outputFormat: string = 'image/png', | 804 | outputFormat: string = 'image/png', |
diff --git a/src/webview/lib/Userscript.ts b/src/webview/lib/Userscript.ts index b0e4fb805..5adc1ac3a 100644 --- a/src/webview/lib/Userscript.ts +++ b/src/webview/lib/Userscript.ts | |||
@@ -32,7 +32,7 @@ export default class Userscript { | |||
32 | * | 32 | * |
33 | * @param {*} settings | 33 | * @param {*} settings |
34 | */ | 34 | */ |
35 | // eslint-disable-next-line camelcase | 35 | |
36 | internal_setSettings(settings: any) { | 36 | internal_setSettings(settings: any) { |
37 | // This is needed to get a clean JS object from the settings itself to provide better accessibility | 37 | // This is needed to get a clean JS object from the settings itself to provide better accessibility |
38 | // Otherwise this will be a mobX instance | 38 | // Otherwise this will be a mobX instance |
@@ -45,7 +45,7 @@ export default class Userscript { | |||
45 | * @param {number} indirect Indirect messages | 45 | * @param {number} indirect Indirect messages |
46 | */ | 46 | */ |
47 | setBadge(direct: number = 0, indirect: number = 0) { | 47 | setBadge(direct: number = 0, indirect: number = 0) { |
48 | if (this.recipe && this.recipe.setBadge) { | 48 | if (this.recipe?.setBadge) { |
49 | this.recipe.setBadge(direct, indirect); | 49 | this.recipe.setBadge(direct, indirect); |
50 | } | 50 | } |
51 | } | 51 | } |
@@ -55,7 +55,7 @@ export default class Userscript { | |||
55 | * @param {*} title Dialog title | 55 | * @param {*} title Dialog title |
56 | */ | 56 | */ |
57 | setDialogTitle(title: string) { | 57 | setDialogTitle(title: string) { |
58 | if (this.recipe && this.recipe.setDialogTitle) { | 58 | if (this.recipe?.setDialogTitle) { |
59 | this.recipe.setDialogTitle(title); | 59 | this.recipe.setDialogTitle(title); |
60 | } | 60 | } |
61 | } | 61 | } |
@@ -66,7 +66,7 @@ export default class Userscript { | |||
66 | * @param {...string} files | 66 | * @param {...string} files |
67 | */ | 67 | */ |
68 | injectCSSFiles(...files: string[]) { | 68 | injectCSSFiles(...files: string[]) { |
69 | if (this.recipe && this.recipe.injectCSS) { | 69 | if (this.recipe?.injectCSS) { |
70 | // @ts-expect-error A spread argument must either have a tuple type or be passed to a rest parameter. | 70 | // @ts-expect-error A spread argument must either have a tuple type or be passed to a rest parameter. |
71 | this.recipe.injectCSS(...files); | 71 | this.recipe.injectCSS(...files); |
72 | } | 72 | } |
@@ -99,6 +99,7 @@ export default class Userscript { | |||
99 | * @param {string} key | 99 | * @param {string} key |
100 | * @return Value of the key | 100 | * @return Value of the key |
101 | */ | 101 | */ |
102 | // eslint-disable-next-line consistent-return | ||
102 | get(key: string) { | 103 | get(key: string) { |
103 | const ferdiumUserKey = window.localStorage.getItem(`ferdium-user-${key}`); | 104 | const ferdiumUserKey = window.localStorage.getItem(`ferdium-user-${key}`); |
104 | 105 | ||
diff --git a/src/webview/recipe.ts b/src/webview/recipe.ts index 0d18e4347..76615d234 100644 --- a/src/webview/recipe.ts +++ b/src/webview/recipe.ts | |||
@@ -1,6 +1,6 @@ | |||
1 | /* eslint-disable global-require */ | 1 | /* eslint-disable global-require */ |
2 | /* eslint-disable import/no-dynamic-require */ | 2 | /* eslint-disable import/no-dynamic-require */ |
3 | /* eslint-disable import/first */ | 3 | |
4 | import { noop, debounce } from 'lodash'; | 4 | import { noop, debounce } from 'lodash'; |
5 | import { contextBridge, ipcRenderer } from 'electron'; | 5 | import { contextBridge, ipcRenderer } from 'electron'; |
6 | import { join } from 'path'; | 6 | import { join } from 'path'; |
@@ -52,7 +52,7 @@ import Service from '../models/Service'; | |||
52 | // This will cause the service to fail loading | 52 | // This will cause the service to fail loading |
53 | // As the message API is not actually needed, we'll add this shim sendMessage | 53 | // As the message API is not actually needed, we'll add this shim sendMessage |
54 | // function in order for darkreader to continue working | 54 | // function in order for darkreader to continue working |
55 | // @ts-ignore | 55 | // @ts-expect-error Fix this |
56 | window.chrome.runtime.sendMessage = noop; | 56 | window.chrome.runtime.sendMessage = noop; |
57 | 57 | ||
58 | const debug = require('../preload-safe-debug')('Ferdium:Plugin'); | 58 | const debug = require('../preload-safe-debug')('Ferdium:Plugin'); |
@@ -143,9 +143,9 @@ class RecipeController { | |||
143 | service: Service; | 143 | service: Service; |
144 | } = { | 144 | } = { |
145 | overrideSpellcheckerLanguage: false, | 145 | overrideSpellcheckerLanguage: false, |
146 | // @ts-ignore | 146 | // @ts-expect-error Fix this |
147 | app: DEFAULT_APP_SETTINGS, | 147 | app: DEFAULT_APP_SETTINGS, |
148 | // @ts-ignore | 148 | // @ts-expect-error Fix this |
149 | service: { | 149 | service: { |
150 | isDarkModeEnabled: false, | 150 | isDarkModeEnabled: false, |
151 | spellcheckerLanguage: '', | 151 | spellcheckerLanguage: '', |
@@ -233,6 +233,7 @@ class RecipeController { | |||
233 | const modulePath = join(recipe.path, 'webview.js'); | 233 | const modulePath = join(recipe.path, 'webview.js'); |
234 | debug('module path', modulePath); | 234 | debug('module path', modulePath); |
235 | // Delete module from cache | 235 | // Delete module from cache |
236 | // eslint-disable-next-line @typescript-eslint/no-dynamic-delete | ||
236 | delete require.cache[require.resolve(modulePath)]; | 237 | delete require.cache[require.resolve(modulePath)]; |
237 | try { | 238 | try { |
238 | this.recipe = new RecipeWebview( | 239 | this.recipe = new RecipeWebview( |
@@ -311,7 +312,7 @@ class RecipeController { | |||
311 | debug('translatorEngine', this.settings.app.translatorEngine); | 312 | debug('translatorEngine', this.settings.app.translatorEngine); |
312 | debug('translatorLanguage', this.settings.app.translatorLanguage); | 313 | debug('translatorLanguage', this.settings.app.translatorLanguage); |
313 | 314 | ||
314 | if (this.userscript && this.userscript.internal_setSettings) { | 315 | if (this.userscript?.internal_setSettings) { |
315 | this.userscript.internal_setSettings(this.settings); | 316 | this.userscript.internal_setSettings(this.settings); |
316 | } | 317 | } |
317 | 318 | ||
@@ -339,7 +340,7 @@ class RecipeController { | |||
339 | 'Darkmode enabled?', | 340 | 'Darkmode enabled?', |
340 | this.settings.service.isDarkModeEnabled, | 341 | this.settings.service.isDarkModeEnabled, |
341 | 'Dark theme active?', | 342 | 'Dark theme active?', |
342 | // @ts-ignore | 343 | // @ts-expect-error Fix this |
343 | this.settings.app.isDarkThemeActive, | 344 | this.settings.app.isDarkThemeActive, |
344 | ); | 345 | ); |
345 | 346 | ||
@@ -356,7 +357,7 @@ class RecipeController { | |||
356 | debug('Enable dark mode'); | 357 | debug('Enable dark mode'); |
357 | 358 | ||
358 | // Check if recipe has a custom dark mode handler | 359 | // Check if recipe has a custom dark mode handler |
359 | if (this.recipe && this.recipe.darkModeHandler) { | 360 | if (this.recipe?.darkModeHandler) { |
360 | debug('Using custom dark mode handler'); | 361 | debug('Using custom dark mode handler'); |
361 | 362 | ||
362 | // Remove other dark mode styles if they were already loaded | 363 | // Remove other dark mode styles if they were already loaded |
@@ -399,7 +400,7 @@ class RecipeController { | |||
399 | debug('Remove dark mode'); | 400 | debug('Remove dark mode'); |
400 | debug('DarkMode disabled - removing remaining styles'); | 401 | debug('DarkMode disabled - removing remaining styles'); |
401 | 402 | ||
402 | if (this.recipe && this.recipe.darkModeHandler) { | 403 | if (this.recipe?.darkModeHandler) { |
403 | // Remove other dark mode styles if they were already loaded | 404 | // Remove other dark mode styles if they were already loaded |
404 | if (this.hasUpdatedBeforeRecipeLoaded) { | 405 | if (this.hasUpdatedBeforeRecipeLoaded) { |
405 | this.hasUpdatedBeforeRecipeLoaded = false; | 406 | this.hasUpdatedBeforeRecipeLoaded = false; |