a11y-outline

web extension to navigate document outlines easily
git clone https://git.ce9e.org/a11y-outline.git

commit
963c4585cf71ef984b10de2c745f1dad4a619167
parent
9c6f41196c57c7ed87d59f08c6aa9e71b09e8051
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2023-07-17 21:21
use activeTab instead of <all_urls> permission

Diffstat

M bg.js 30 ++++++++++++++++++++++++++++--
M manifest.json 10 +---------

2 files changed, 29 insertions, 11 deletions


diff --git a/bg.js b/bg.js

@@ -1,9 +1,35 @@
   -1     1 /* global chrome */
   -1     2 
   -1     3 var wrap = function(fn) {
   -1     4 	return function(...args) {
   -1     5 		return new Promise((resolve) => {
   -1     6 			fn(...args, result => {
   -1     7 				resolve(result);
   -1     8 			});
   -1     9 		});
   -1    10 	};
   -1    11 };
   -1    12 
   -1    13 var executeScript = wrap(chrome.tabs.executeScript);
   -1    14 
   -1    15 var injectCode = function() {
   -1    16 	return Promise.all([
   -1    17 		executeScript({file: '/vendor/aria.js'}),
   -1    18 		executeScript({file: '/treeview.js'}),
   -1    19 		executeScript({file: '/outline.js'}),
   -1    20 	]);
   -1    21 };
   -1    22 
    1    23 chrome.browserAction.onClicked.addListener(function(tab) {
    2    -1 	chrome.tabs.sendMessage(tab.id, 'showA11yOutline');
   -1    24 	injectCode().then(() => {
   -1    25 		chrome.tabs.sendMessage(tab.id, 'showA11yOutline');
   -1    26 	});
    3    27 });
    4    28 
    5    29 chrome.commands.onCommand.addListener(function(command) {
    6    30 	chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
    7    -1 		chrome.tabs.sendMessage(tabs[0].id, command);
   -1    31 		injectCode().then(() => {
   -1    32 			chrome.tabs.sendMessage(tabs[0].id, command);
   -1    33 		});
    8    34 	});
    9    35 });

diff --git a/manifest.json b/manifest.json

@@ -16,14 +16,6 @@
   16    16     "scripts": ["bg.js"],
   17    17     "persistent": false
   18    18   },
   19    -1   "content_scripts": [{
   20    -1     "matches": ["<all_urls>"],
   21    -1     "js": [
   22    -1       "vendor/aria.js",
   23    -1       "treeview.js",
   24    -1       "outline.js"
   25    -1     ]
   26    -1   }],
   27    19   "web_accessible_resources": [
   28    20     "outline.css"
   29    21   ],
@@ -50,7 +42,7 @@
   50    42     }
   51    43   },
   52    44   "permissions": [
   53    -1     "<all_urls>"
   -1    45     "activeTab"
   54    46   ],
   55    47   "browser_specific_settings": {
   56    48     "gecko": {