-
Notifications
You must be signed in to change notification settings - Fork 5
/
background.js
35 lines (33 loc) · 969 Bytes
/
background.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
const defaultStorage = {
bookmarks: [],
keyBindings: {
addBookmark: 87,// W
jumpToPrevBookmark: 81,// Q
jumpToNextBookmark: 69,// E
setRepeatStart: 65,// A
setRepeatEnd: 66,// B
slower: 83,// S
faster: 68,// D
loop: 82,// R
hide: 72// H
},
options:{
latency: 1.5
}
};
//每次tab更新時觸發(Youtube 切換影片必須要由這裡才偵測得到)
chrome.tabs.onUpdated.addListener(function(tabId, changeInfo, tab){
if(changeInfo && changeInfo.status == "complete"){
chrome.tabs.sendMessage(tabId, {action: "INIT"});
}
});
// 安裝好先存入預設值(只執行一次)
chrome.runtime.onInstalled.addListener(function(details){
if(details.reason == "install"){
chrome.storage.sync.set(defaultStorage, function() {
if (chrome.runtime.error) {
console.log("Runtime error.");
}
});
}
});