-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathoptions.js
More file actions
23 lines (20 loc) · 799 Bytes
/
options.js
File metadata and controls
23 lines (20 loc) · 799 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function sanitizeHost(h) {
return (h || "").trim().replace(/^https?:\/\//i,"").replace(/\/+$/,"");
}
async function load() {
const { defaultHost } = await chrome.storage.local.get("defaultHost");
document.getElementById('host').value = defaultHost || "google.com";
}
async function save() {
const cleaned = sanitizeHost(document.getElementById('host').value);
await chrome.storage.local.set({ defaultHost: cleaned });
const s = document.getElementById('status');
s.textContent = '✔ shranjeno';
s.className = 'ok';
setTimeout(() => { s.textContent = ''; s.className=''; }, 1200);
}
// Brez inline onload/onClick — vse prek addEventListener
document.addEventListener('DOMContentLoaded', () => {
load();
document.getElementById('save').addEventListener('click', save);
});