only add styles if the page requested it

This commit is contained in:
Florian Dold 2017-04-26 03:14:31 +02:00
parent 79a2eed558
commit a787cf2f6c
No known key found for this signature in database
GPG Key ID: D2E4F00F29D02A4B

View File

@ -256,15 +256,19 @@ function init() {
window.setTimeout(init, 200);
return;
}
initStyle();
setStyles(true);
if (document.documentElement.getAttribute("data-taler-nojs")) {
initStyle();
setStyles(true);
}
registerHandlers();
// Hack to know when the extension is unloaded
let port = chrome.runtime.connect();
port.onDisconnect.addListener(() => {
logVerbose && console.log("chrome runtime disconnected, removing handlers");
setStyles(false);
if (document.documentElement.getAttribute("data-taler-nojs")) {
setStyles(false);
}
for (let handler of handlers) {
document.removeEventListener(handler.type, handler.listener);
}