forked from thangdc/autoscroll
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
45 lines (39 loc) · 1.24 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
let startEle = document.getElementById('btnStart');
let timeoutEle = document.getElementById('tbxTimeout');
//let shortcutEle = document.getElementById('tbxShortcut');
var isStart = false;
var timeout = 25;
var shortcut = 'z';
chrome.storage.sync.set({shortcut: shortcut});
chrome.storage.sync.get('timeout', function(data) {
timeoutEle.value = data.timeout;
timeout = data.timeout;
});
chrome.storage.sync.get('shortcut', function(data) {
//shortcutEle.setAttribute('value', data.shortcut);
shortcut = data.shortcut;
});
timeoutEle.onchange = function(element) {
timeout = element.target.value;
chrome.storage.sync.set({timeout: timeout});
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(
tabs[0].id,
{
code: 'ThangDC = window.ThangDC || {}; ThangDC.timeout = '+ timeout +';'
}
);
});
}
/*shortcutEle.onchange = function(element) {
shortcut = element.target.value;
chrome.storage.sync.set({shortcut: shortcut});
chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
chrome.tabs.executeScript(
tabs[0].id,
{
code: 'ThangDC = window.ThangDC || {}; ThangDC.shortcut = \''+ shortcut +'\';'
}
);
});
}*/