Open trickypr opened 1 year ago
I found the way to allow run addon on web panel.
webpanelElem.setAttribute("src", "chrome://browser/content/browser.xhtml");
Services.prefs.setStringPref("floorp.browser.sidebar2.start.url", webpanelURL);
// Browser Manager Sidebar embedded check
let embedded = Services.prefs.getStringPref("floorp.browser.sidebar2.start.url");
if (embedded != "" && embedded !== false && embedded != undefined) {
if(gBrowser){
loadBMSURI();
} else {
window.setTimeout(loadBMSURI, 1000);
}
}
function loadBMSURI(){
gBrowser.loadURI(Services.io.newURI(embedded), {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
});
document.getElementById("main-window").setAttribute("chromehidden", "toolbar", "menubar directories extrachrome");
document.getElementById("main-window").setAttribute("BSM-window", "true");
Services.prefs.clearUserPref("floorp.browser.sidebar2.start.url");
Services.prefs.setBoolPref("floorp.browser.sidebar2.addons.window.start", false);
// Load CSS
const BMSSyleElement = document.createElement("style");
BMSSyleElement.textContent = `
@import url("chrome://browser/content/browser-bms-window.css");
`
document.head.appendChild(BMSSyleElement);
}
Briefly, chrome://browser/content/browser.xhtml is embedded as a browser window, and the window inside the web panel is recognized as a web panel window by using the pref condition classification.
This allows the add-on to run inside the web panel as if it were one more window.
As noted in #238, there are still a significant number of ads that are present in the sidebar. My best guess is that content scripts are not loading correctly because they are missing some supporting objects. Probably should look into these error messages:
Sidenote: linkhandler is throwing errors as well. Probably a good idea to think about fixing that