-
Notifications
You must be signed in to change notification settings - Fork 0
/
popup.js
53 lines (49 loc) · 1.76 KB
/
popup.js
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
45
46
47
48
49
50
51
52
53
function requestVideoQualitySizeChange(event) {
var f = document.getElementsByTagName("select")[0];
var player_type = f.options[f.selectedIndex].getAttribute("value");
chrome.tabs.query({
active: true,
currentWindow: true
}, function(tabs) {
chrome.tabs.sendRequest(tabs[0].id, { action: 'player_type_change', 'player_type': player_type }, function(response) {
//foo
});
});
savePlayerType(player_type);
}
function savePlayerType(player_type) {
chrome.extension.sendRequest({ 'action': 'playertype_save', 'player_type': player_type },
function(o) {
//foo
}
);
}
function adjustOptions(player_type) {
var a, si;
a = document.getElementsByTagName("select")[0];
for (var i = 0; i < a.length; i++) {
if (a[i].getAttribute("value") == player_type) {
si = i;
break;
}
}
a.selectedIndex = si;
document.getElementsByTagName("select")[0].addEventListener("change", requestVideoQualitySizeChange, true);
}
function askPlayerType() {
chrome.extension.sendRequest({ 'action': 'playertype_ask' },
function(o) {
adjustOptions(o['player_type']);
}
);
}
document.addEventListener("DOMContentLoaded",function(event){
document.getElementById("owindow").addEventListener("click",function(event){
event.preventDefault();
chrome.runtime.sendMessage({ 'action': 'gkn_ask_popup' },
function(o) {
//foo
}
);
},false);;
},false);