-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
44 lines (41 loc) · 1.18 KB
/
background.js
File metadata and controls
44 lines (41 loc) · 1.18 KB
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
// Called when the user clicks on the browser action.
chrome.browserAction.onClicked.addListener(function(tab) {
chrome.tabs.sendMessage(tab.id, {action : 'open-sociocaster-overlay' , tab : tab}, function(response) {
console.log(response.farewell);
});
});
/**
// Inject code from the first element of the content script list
var injectButtonCode = function (id) {
var scripts = chrome.manifest.content_scripts[0].js;
// Programmatically inject each script
scripts.forEach(function (script) {
chrome.tabs.executeScript(id, {
file: script
});
});
};
chrome.runtime.onInstalled.addListener(function(details){
if (details.reason == "install"){
chrome.windows.getAll({
populate: true
}, function (windows) {
windows.forEach(function (currentWindow) {
currentWindow.tabs.forEach(function (currentTab) {
// Skip chrome:// and https:// pages
if( ! currentTab.url.match(/(chrome|https):\/\//gi) ) {
injectButtonCode(currentTab.id);
}
});
});
// Open the guide
chrome.tabs.create({
url: 'https://sociocaster.com/extra/chrome',
active: true
});
});
} else if (details.reason == "update"){
// Nothing to do here, yet...
}
});
**/