-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoptions.js
30 lines (27 loc) · 1.1 KB
/
options.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
window.addEventListener("load", function(){
console.log('page load');
// const markLikedVideo = document.querySelector('#liked_video');
const enterFullscreen = document.querySelector('#enterFullscreen');
const playAudioOnFocus = document.querySelector('#playAudioOnFocus');
const feedback = document.querySelector('.feedback');
const form = document.querySelector('#optionsForm');
const defaultPreferences = { enterFullscreen: true, playAudioOnFocus: true }
// read saved state on page load
chrome.storage.local.get(defaultPreferences, function(result) {
enterFullscreen.checked = result.enterFullscreen;
playAudioOnFocus.checked = result.playAudioOnFocus;
});
form.addEventListener('submit', function(event){
event.preventDefault();
const userPreferences = {
enterFullscreen: enterFullscreen.checked,
playAudioOnFocus: playAudioOnFocus.checked
};
chrome.storage.local.set(userPreferences);
feedback.innerHTML = 'saved successfully!'
feedback.classList.add('visible')
setTimeout(function(){
feedback.classList.remove('visible')
}, 3000);
});
});