-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
30 lines (21 loc) · 744 Bytes
/
background.js
File metadata and controls
30 lines (21 loc) · 744 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
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
console.log(request);
if (request.clicked) {
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(tabs[0].id, {file: 'inject.js'});
//send request to content script
chrome.tabs.sendRequest(tabs[0].id, {monitor: true},
function(response) {
//send playbackRate back to popup for display
if (response) sendResponse({playbackRate: response.playbackRate});
}
);
}
);
return true;
}
else if (request.found) {
//inject.js found media elements on webpage
chrome.runtime.sendMessage(request);
}
});