libredirect/pages/options/options.js

39 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-10-07 13:59:31 +02:00
'use strict';
let nitterInstance = document.querySelector('#nitterInstance');
let invidiousInstance = document.querySelector('#invidiousInstance');
2020-02-01 04:17:51 +01:00
let bibliogramInstance = document.querySelector('#bibliogramInstance');
let disableNitter = document.querySelector('#disableNitter');
let disableInvidious = document.querySelector('#disableInvidious');
let disableBibliogram = document.querySelector('#disableBibliogram');
2019-10-07 13:59:31 +02:00
chrome.storage.sync.get(
2020-02-01 04:17:51 +01:00
[
'nitterInstance',
'invidiousInstance',
'bibliogramInstance',
'disableNitter',
'disableInvidious',
'disableBibliogram'
],
2020-01-14 10:48:37 +01:00
result => {
2019-10-07 13:59:31 +02:00
nitterInstance.value = result.nitterInstance || '';
invidiousInstance.value = result.invidiousInstance || '';
2020-02-01 04:17:51 +01:00
bibliogramInstance.value = result.bibliogramInstance || '';
disableNitter.checked = !result.disableNitter;
disableInvidious.checked = !result.disableInvidious;
disableBibliogram.checked = !result.disableBibliogram;
2019-10-07 13:59:31 +02:00
}
);
document.querySelector('#save').addEventListener('click', () => {
chrome.storage.sync.set({
2020-02-01 04:17:51 +01:00
nitterInstance: nitterInstance.value,
invidiousInstance: invidiousInstance.value,
bibliogramInstance: bibliogramInstance.value,
2019-10-07 13:59:31 +02:00
disableNitter: !disableNitter.checked,
disableInvidious: !disableInvidious.checked,
2020-02-01 04:17:51 +01:00
disableBibliogram: !disableBibliogram.checked
2019-10-07 13:59:31 +02:00
});
window.close();
});