-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
28 lines (17 loc) · 751 Bytes
/
background.js
File metadata and controls
28 lines (17 loc) · 751 Bytes
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
console.log("background is live")
browser.runtime.onMessage.addListener(action);
function action(message) {
console.log("background recieved msg: " + message.clean_link)
let clean_link = message.clean_link
// get current tab id
// https://stackoverflow.com/questions/43695817/tabs-getcurrent-result-is-undefined
browser.tabs.query({ active: true, windowId: browser.windows.WINDOW_ID_CURRENT })
.then(tabs => browser.tabs.get(tabs[0].id))
.then(tab => {
console.info(tab);
let tab_id = tab.id
console.log(tab_id)
// send message to content
browser.tabs.sendMessage(tab_id, { "location": "from popup", "clean_link": clean_link });
});
}