-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontent_script.js
More file actions
28 lines (23 loc) · 1.01 KB
/
content_script.js
File metadata and controls
28 lines (23 loc) · 1.01 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
// inject a script from the extension's files
// into the execution environment of the main page
var s = document.createElement('script');
s.src = chrome.extension.getURL("myapi.js");
document.documentElement.appendChild(s);
document.addEventListener('espnSWIDRequest', function(event) {
chrome.runtime.sendMessage({type: "espnSWIDRequest"}, function(response) {
var fetchResponse = new CustomEvent('espnSWIDResponse', {"detail":response});
document.dispatchEvent(fetchResponse);
});
});
document.addEventListener('espnS2Request', function(event) {
chrome.runtime.sendMessage({type: "espnS2Request"}, function(response) {
var fetchResponse = new CustomEvent('espnS2Response', {"detail":response});
document.dispatchEvent(fetchResponse);
});
});
document.addEventListener('espnKeyRequest', function(event) {
chrome.runtime.sendMessage({type: "espnKeyRequest"}, function(response) {
var fetchResponse = new CustomEvent('espnKeyResponse', {"detail":response});
document.dispatchEvent(fetchResponse);
});
});