-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontent_script.js
More file actions
35 lines (31 loc) · 896 Bytes
/
content_script.js
File metadata and controls
35 lines (31 loc) · 896 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
31
32
33
34
35
function injectFile(file) {
var script = document.createElement('script');
script.src = chrome.extension.getURL(file);
script.onload = function() {
this.remove();
};
(document.head || document.documentElement).appendChild(script);
}
injectFile('utils.js');
document.addEventListener('keypress', function(e) {
e = e || window.event;
var charCode = (typeof e.which == "number") ? e.which : e.keyCode;
switch (String.fromCharCode(charCode)) {
case '1': {
injectFile('scenarios/linegraph1.js');
break;
}
case '2': {
injectFile('scenarios/linegraph2.js');
break;
}
case '3': {
injectFile('scenarios/linegraph3.js');
break;
}
case '4': {
injectFile('scenarios/boxplot1.js');
break;
}
}
});