-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbackground.js
More file actions
35 lines (26 loc) · 833 Bytes
/
Copy pathbackground.js
File metadata and controls
35 lines (26 loc) · 833 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
29
30
31
32
var rt = (typeof browser !== 'undefined') ? browser : chrome;
/** store the edit urls for the current tabs */
editlinks = {};
/** receive messages from the content script */
(rt.runtime || rt.extension).onMessage.addListener(function (request, sender) {
// store the link
editlinks[sender.tab.id] = request.href;
// Enable the page action icon.
rt.pageAction.setTitle(
{
tabId: sender.tab.id,
title: request.title
}
);
rt.pageAction.show(sender.tab.id);
});
/** remove stored urls again, when the tab is closed */
rt.tabs.onRemoved.addListener(function (tabId) {
editlinks[tabId] = null;
});
/** handle clicks on the page icon */
rt.pageAction.onClicked.addListener(function (tab) {
rt.tabs.update(tab.id, {
url: editlinks[tab.id]
});
});