bypass-paywalls-firefox-clean/options/popup.js

43 lines
1.6 KiB
JavaScript
Raw Normal View History

var ext_api = (typeof browser === 'object') ? browser : chrome;
2020-11-05 21:21:41 +00:00
2021-02-17 18:11:27 +00:00
function popup_show_toggle(domain, enabled) {
2020-11-05 21:21:41 +00:00
if (domain) {
var site_switch_span = document.getElementById('site_switch_span');
let labelEl = document.createElement('label');
labelEl.setAttribute('class', 'switch');
let inputEl = document.createElement('input');
inputEl.setAttribute('id', 'site_switch');
inputEl.setAttribute('type', 'checkbox');
2021-02-17 18:11:27 +00:00
if (enabled)
2020-11-05 21:21:41 +00:00
inputEl.setAttribute('checked', true);
labelEl.appendChild(inputEl);
let spanEl = document.createElement('span');
spanEl.setAttribute('class', 'slider round');
spanEl.setAttribute('title', 'en/disable current site in BPC');
labelEl.appendChild(spanEl);
site_switch_span.appendChild(labelEl);
document.getElementById("site_switch").addEventListener('click', function () {
2021-02-17 18:11:27 +00:00
ext_api.runtime.sendMessage({request: 'site_switch'});
//open(location).close();
2020-11-05 21:21:41 +00:00
});
}
};
2021-02-17 18:11:27 +00:00
ext_api.runtime.sendMessage({request: 'popup_show_toggle'});
ext_api.runtime.onMessage.addListener(function (message, sender) {
if (message.msg === 'popup_show_toggle' && message.data) {
popup_show_toggle(message.data.domain, message.data.enabled)
}
});
2020-11-05 21:21:41 +00:00
document.getElementById("clear_cookies").addEventListener('click', function () {
2021-02-17 18:11:27 +00:00
ext_api.runtime.sendMessage({request: 'clear_cookies'});
//open(location).close();
});
function closeButton() {
window.close();
}
document.getElementById("button-close").addEventListener('click', closeButton);