-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.js
More file actions
31 lines (24 loc) · 1.05 KB
/
Copy pathsettings.js
File metadata and controls
31 lines (24 loc) · 1.05 KB
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
document.addEventListener("DOMContentLoaded", restoreOptions);
document.querySelector("form").addEventListener("submit", saveOptions);
function saveOptions(e) {
e.preventDefault();
browser.storage.local.set({
settings: {
host_to_intercept: document.querySelector("#host_to_intercept").value,
hosts_to_show_list: document.querySelector("#hosts_to_show_list").value,
hosts_to_parse_html: document.querySelector("#hosts_to_parse_html").value
}
});
}
function restoreOptions() {
function setCurrentChoice(result) {
document.querySelector("#host_to_intercept").value = result.settings.host_to_intercept || "oloadcdn.net";
document.querySelector("#hosts_to_show_list").value = result.settings.hosts_to_show_list || "dailymotion.com,openload.co";
document.querySelector("#hosts_to_parse_html").value = result.settings.hosts_to_parse_html || "dailymotion.com";
}
function onError(error) {
console.log(`Error: ${error}`);
}
var getting = browser.storage.local.get("settings");
getting.then(setCurrentChoice, onError);
}