1
0
mirror of https://github.com/kkapsner/CanvasBlocker synced 2024-12-22 21:00:23 +01:00

Fixed options standalone detection.

This commit is contained in:
kkapsner 2018-08-18 22:35:52 +02:00
parent dfc613db04
commit 635912c8b9
2 changed files with 38 additions and 23 deletions

View File

@ -34,30 +34,44 @@
}
};
if (window === window.top){
let head = document.createElement("header");
let heading = document.createElement("h1");
heading.textContent = browser.i18n.getMessage("options");
head.appendChild(heading);
let introduction = document.createElement("div");
introduction.textContent = browser.i18n.getMessage("optionsIntroduction");
head.appendChild(introduction);
if (window.location.search){
let noticeName = window.location.search.substr(1).trim() + "Notice";
let notice = browser.i18n.getMessage(noticeName);
if (notice){
let bookmarkingNotice = document.createElement("div");
bookmarkingNotice.className = noticeName + " bookmarkNotice";
bookmarkingNotice.textContent = notice;
head.appendChild(bookmarkingNotice);
new Promise(function(resolve){
const port = browser.runtime.connect();
port.onMessage.addListener(function(data){
if (data.hasOwnProperty("tabId")){
logging.notice("my tab id is", data.tabId);
port.disconnect();
resolve(data.tabId);
}
}
});
}).then(function(tabId){
return browser.tabs.get(tabId);
}).then(function(tab){
let head = document.createElement("header");
document.body.insertBefore(head, document.body.firstChild);
document.body.appendChild(head);
document.body.classList.add("standalone");
}
if (tab.url === window.location.href){
let heading = document.createElement("h1");
heading.textContent = browser.i18n.getMessage("options");
head.appendChild(heading);
let introduction = document.createElement("div");
introduction.textContent = browser.i18n.getMessage("optionsIntroduction");
head.appendChild(introduction);
if (window.location.search){
let noticeName = window.location.search.substr(1).trim() + "Notice";
let notice = browser.i18n.getMessage(noticeName);
if (notice){
let bookmarkingNotice = document.createElement("div");
bookmarkingNotice.className = noticeName + " bookmarkNotice";
bookmarkingNotice.textContent = notice;
head.appendChild(bookmarkingNotice);
}
}
document.body.classList.add("standalone");
}
});
var table = document.createElement("table");
table.className = "settings " + (settings.displayDescriptions? "display": "hide") + "Descriptions";

View File

@ -6,7 +6,8 @@ Version 0.5.3:
- display version in options page
fixes:
-
- CSP did not work properly for worker-src
- detection if the options page was displayed in a separate tab did not work reliably
known issues:
- if a data URL is blocked the page action button does not appear