2021-02-28 10:32:38 +00:00
|
|
|
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'});
|
2021-02-14 17:31:00 +00:00
|
|
|
//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'});
|
2021-02-14 17:31:00 +00:00
|
|
|
//open(location).close();
|
2020-11-24 16:12:47 +00:00
|
|
|
});
|
2021-02-16 16:49:29 +00:00
|
|
|
|
|
|
|
function closeButton() {
|
|
|
|
window.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
document.getElementById("button-close").addEventListener('click', closeButton);
|