-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
46 lines (41 loc) · 1.29 KB
/
script.js
File metadata and controls
46 lines (41 loc) · 1.29 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
function pauseSound(){
chrome.tabs.query({}, function(tabs){
for(var i = 0; i < tabs.length; i++) {
var found = tabs[i].url.search(/.*youtube.*/);
var foundFB = tabs[i].url.search(/.*facebook.*/);
//console.log(tabs[i]);
if(found != -1 ){
chrome.tabs.executeScript(tabs[i].id,
{
code:'document.getElementsByClassName("ytp-play-button")[0].click();'
},
function(results){
console.log("Callback worked")}
);
}
if (foundFB != -1) {
console.log(tabs[i].audible );
if ( tabs[i].audible ) {
chrome.tabs.executeScript(tabs[i].id,
{
file:'fb.js'
},
function(results){
console.log("Callback worked")}
);
}
}
}
});
}
var toggle = false;
chrome.browserAction.onClicked.addListener(function(tab) {
toggle = !toggle;
if(toggle){
chrome.browserAction.setIcon({path: "play.png", tabId:tab.id});
}
else{
chrome.browserAction.setIcon({path: "pause.png", tabId:tab.id});
}
pauseSound();
});