aboutsummaryrefslogtreecommitdiff
path: root/ext/js/accessibility
diff options
context:
space:
mode:
authortoasted-nutbread <toasted-nutbread@users.noreply.github.com>2023-12-27 09:48:35 -0500
committerGitHub <noreply@github.com>2023-12-27 14:48:35 +0000
commit623e056fe6322c1d0f07554aea2fabf2f834e8a5 (patch)
tree6040ee8396363f00b0d2fbf05ca9de2b611e0b5f /ext/js/accessibility
parent860374fdab25fce3161ee835be0e141a341b9b9b (diff)
Script manager cleanup (#456)
* Remove unused functions * Remove fallback code * Simplify injectStylesheet * Simplify unregisterContentScript * Merge functions * Simplify registration details * Simplify injectScript * Remove class wrapper * Remove unused injectScript
Diffstat (limited to 'ext/js/accessibility')
-rw-r--r--ext/js/accessibility/accessibility-controller.js17
1 files changed, 5 insertions, 12 deletions
diff --git a/ext/js/accessibility/accessibility-controller.js b/ext/js/accessibility/accessibility-controller.js
index 8250b369..2b352948 100644
--- a/ext/js/accessibility/accessibility-controller.js
+++ b/ext/js/accessibility/accessibility-controller.js
@@ -16,19 +16,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
+import {isContentScriptRegistered, registerContentScript, unregisterContentScript} from '../background/script-manager.js';
import {log} from '../core.js';
/**
* This class controls the registration of accessibility handlers.
*/
export class AccessibilityController {
- /**
- * Creates a new instance.
- * @param {import('../background/script-manager.js').ScriptManager} scriptManager An instance of the `ScriptManager` class.
- */
- constructor(scriptManager) {
- /** @type {import('../background/script-manager.js').ScriptManager} */
- this._scriptManager = scriptManager;
+ constructor() {
/** @type {?import('core').TokenObject} */
this._updateGoogleDocsAccessibilityToken = null;
/** @type {?Promise<void>} */
@@ -90,19 +85,17 @@ export class AccessibilityController {
const id = 'googleDocsAccessibility';
try {
if (forceGoogleDocsHtmlRenderingAny) {
- if (await this._scriptManager.isContentScriptRegistered(id)) { return; }
+ if (await isContentScriptRegistered(id)) { return; }
/** @type {import('script-manager').RegistrationDetails} */
const details = {
allFrames: true,
- matchAboutBlank: true,
matches: ['*://docs.google.com/*'],
- urlMatches: '^[^:]*://docs\\.google\\.com/[\\w\\W]*$',
runAt: 'document_start',
js: ['js/accessibility/google-docs.js']
};
- await this._scriptManager.registerContentScript(id, details);
+ await registerContentScript(id, details);
} else {
- await this._scriptManager.unregisterContentScript(id);
+ await unregisterContentScript(id);
}
} catch (e) {
log.error(e);