-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
35 lines (29 loc) · 1.01 KB
/
background.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
var nativePort = browser.runtime.connectNative("haley_alias_manager");
var contentPort;
nativePort.onMessage.addListener(function(response) {
console.log(response);
contentPort.postMessage(response);
});
function connected(port) {
contentPort = port;
contentPort.onMessage.addListener(function(message) {
console.log(message);
nativePort.postMessage(message);
});
}
browser.runtime.onConnect.addListener(connected);
let gettingAllCommands = browser.commands.getAll();
gettingAllCommands.then((commands) => {
for (let command of commands) {
// Note that this logs to the Add-on Debugger's console: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Debugging
// not the regular Web console.
console.log(command);
}
});
// console.log("LOADED");
browser.commands.onCommand.addListener(function(command) {
if (command == "fill-forms") {
browser.tabs.executeScript({file: "main.js"});
console.log("toggling the feature!");
}
});