-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (33 loc) · 1.08 KB
/
index.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
document.addEventListener('DOMContentLoaded', ()=>{
const input = document.querySelector('input')
chrome.storage.local.get(["playbackRate"]).then((result)=> {
const defaultValue = result.playbackRate
input.value = parseFloat(String(defaultValue)) || 1
input.focus()
input.addEventListener('input', (event) => {
updatePlaybackRate(event.target.value)
})
input.addEventListener('keypress', (e) => {
if (e.key === 'Enter') {
window.close()
}
});
})
} )
function updatePlaybackRate (playbackRate) {
console.log(chrome.storage.local, chrome.tabs)
chrome.tabs.query({
active: true,
currentWindow: true
}, ([currentTab]) => {
console.log(currentTab);
chrome.storage.local.set({
playbackRate: playbackRate
}, ()=> {
chrome.scripting.executeScript({
target: {tabId: currentTab.id, allFrames: true},
files: ['scripts/content.js'],
});
});
});
}