mirror of
https://git.mirrors.martin98.com/https://github.com/cilame/v_jstools
synced 2025-07-05 16:15:12 +08:00
34 lines
898 B
JavaScript
34 lines
898 B
JavaScript
document.querySelectorAll("input").forEach(function(v){
|
|
chrome.storage.local.get([v.dataset.key], function (result) {
|
|
if (v.type == 'checkbox'){
|
|
v.checked = result[v.dataset.key];
|
|
}
|
|
if (v.type == 'text'){
|
|
v.value = result[v.dataset.key] || '';
|
|
}
|
|
})
|
|
v.addEventListener("change", function (e) {
|
|
if (v.type == 'checkbox'){
|
|
chrome.storage.local.set({
|
|
[e.target.dataset.key]: e.target.checked
|
|
})
|
|
}
|
|
if (v.type == 'text'){
|
|
chrome.storage.local.set({
|
|
[e.target.dataset.key]: e.target.value
|
|
})
|
|
}
|
|
})
|
|
})
|
|
|
|
document.getElementById('showoptions').addEventListener('click', function(e){
|
|
function closePopup() {
|
|
window.close();
|
|
document.body.style.opacity = 0;
|
|
setTimeout(function() { history.go(0); }, 300);
|
|
}
|
|
closePopup()
|
|
chrome.tabs.create({
|
|
url: chrome.extension.getURL('options.html')
|
|
});
|
|
}) |