Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Content scripts are still broken in sidebars #251

Open
trickypr opened this issue May 13, 2023 · 2 comments
Open

Content scripts are still broken in sidebars #251

trickypr opened this issue May 13, 2023 · 2 comments

Comments

@trickypr
Copy link
Member

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:

WebExtension context not found! ExtensionParent.jsm:1296
    getContextById resource://gre/modules/ExtensionParent.jsm:1296
    recvAPICall resource://gre/modules/ExtensionParent.jsm:1133
    _recv resource://gre/modules/ConduitsChild.jsm:84
    receiveMessage resource://gre/modules/ConduitsParent.jsm:466
TypeError: browser is null BrowserElementParent.sys.mjs:21:21
    receiveMessage resource://gre/actors/BrowserElementParent.sys.mjs:21

Sidenote: linkhandler is throwing errors as well. Probably a good idea to think about fixing that

@surapunoyousei
Copy link
Contributor

surapunoyousei commented Sep 4, 2023

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);
    }

@surapunoyousei
Copy link
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants