forked from curtislacy/inject-sidebar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
26 lines (24 loc) · 710 Bytes
/
Copy pathbackground.js
File metadata and controls
26 lines (24 loc) · 710 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
console.log( 'Background.html starting!' );
/*Put page action icon on all tabs*/
chrome.tabs.onUpdated.addListener(function(tabId) {
chrome.pageAction.show(tabId);
});
chrome.tabs.getSelected(null, function(tab) {
chrome.pageAction.show(tab.id);
});
/*Send request to current tab when page action is clicked*/
chrome.pageAction.onClicked.addListener(function(tab) {
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendRequest(
//Selected tab id
tab.id,
//Params inside a object data
{callFunction: "toggleSidebar"},
//Optional callback function
function(response) {
console.log(response);
}
);
});
});
console.log( 'Background.html done.' );