Midora/extension/options.js

28 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-07-17 23:35:00 +02:00
var browser = browser || chrome;
browser.storage.local.get(['theme'], obj => {
var theme = obj.theme || 'green-red';
var themeSettingsContainer = document.getElementById('theme-settings');
[
'green-red',
'purple-yellow',
'cyan-orange',
].map(x => {
themeSettingsContainer.insertAdjacentHTML('beforeend', `
<label class="shinigami-eyes-theme shinigami-eyes-theme-${x}">
<input type="radio" name="selected-theme" ${x == theme ? 'checked' : ''} data-theme="${x}">
<span class="assigned-label-t-friendly">T-Friendly</span>,
<span class="assigned-label-transphobic">Anti-trans</span>,
<span class="assigned-label-unknown" title="Using Facebook as an example for unknown links.">Unknown (fb)</span>
</label>
`);
});
});
document.getElementById('save-button').addEventListener('click', async () => {
var theme = [...document.querySelectorAll('.shinigami-eyes-theme input')]
.filter(x => x.checked)[0].dataset.theme;
browser.runtime.sendMessage({ closeCallingTab: true, setTheme: theme }, () => { });
});
document.getElementById('cancel-button').addEventListener('click', async () => {
browser.runtime.sendMessage({ closeCallingTab: true }, () => { });
});