-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
46 lines (39 loc) · 1.16 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
36
37
38
39
40
41
42
43
44
45
46
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
function getMessage(message) {
if (message.selection == "current") {
// Navigate to the URL in the current tab
browser.tabs.update({
active: true,
url: message.url
})
} else if (message.selection == "tab") {
// Navigate to the URL in a new tab
browser.tabs.create({
active: true,
// openerTabId: XX, # Wait for Firefox 57, see bug 1238314
url: message.url
})
} else if (message.selection == "window") {
// Navigate to the URL in a new window
browser.windows.create({
url: message.url
})
}
}
// function getActiveTab() {
// return browser.tabs.query({
// active: true,
// currentWindow: true
// });
// }
// function gotPlatformInfo(info) {
// getActiveTab().then((tabs) => {
// browser.tabs.sendMessage(tabs[0].id, {
// platform: info.os
// })
// })
// }
browser.runtime.onMessage.addListener(getMessage);
// browser.runtime.getPlatformInfo().then(gotPlatformInfo);