forked from stefems/chromeExtension
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
20 lines (20 loc) · 811 Bytes
/
background.js
File metadata and controls
20 lines (20 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Called when the user clicks on the browser action.
console.log("background files are run from the get-go");
//Since it runs in the background, this file can be used to initialize
// state or data needed or updated in the session.
var globalState = "init";
console.log(globalState);
chrome.browserAction.onClicked.addListener(function(tab) {
alert('icon clicked!');
//This allows us to send a message to our current tab!
chrome.tabs.query({active: true, currentWindow: true}, function(tabs){
chrome.tabs.sendMessage(tabs[0].id, {action: "open_dialog_box"}, function(response) {
if (response) {
globalState = "chat";
console.log(globalState);
console.log("Hey, they got our message and sent us a response!");
console.log(response);
}
});
});
});