1

I created an add-on that manipulates a speicfic site’s HTML based on the settings the user chooses in the add-on’s 'popup' (the settings are saved with ‘chrome.storage.local’, I just ported my code from chrome and it worked).

When the user opens a specific website, the add-on is supposed to run a continuous (interval) content script that changes the HTML, the problem is that it doesn’t, it requires the user to load the site, then open the add-on 'popup', then return to the site, and then the script starts working.

How can I fix that? How do I make the script run when the user opens the site? This is a problem only on android, not chrome or desktop firefox

Here's the manifest.json-

{
    "name": "9gag post filter",
    "description": "A post filter for 9GAG.com",
    "version": "1.1.2",
    "browser_specific_settings": {
        "gecko": {
          "id": "amitbokodev@gmail.com",
          "strict_min_version": "42.0"
        }
    },
    "manifest_version": 3,
    "permissions": [
        "storage"
    ],
    "action": {
      "default_popup": "index.html"
    },
    "content_scripts": [{
        "css": ["assets/css/content.css"],
        "js": ["assets/js/jquery_slim_mini.js","assets/js/content.js"],
        "matches": ["https://9gag.com/*"]
      }]
}

And the whole source code (it's open source)

AmitAM
  • 41
  • 2
  • 8
  • Can you show us the manifest.json? It's hard to get someone to help you because the communication of Addon parts is a special thing... Only the background script runs continously (in version 2) The content scripts reload on every page load in same site? (depents...). The popup script loads every time the user opens the popup... So look in popup.js to see what piese of code execute on opening it... and how this affects cotent-script. – ΑΓΡΙΑ ΠΕΣΤΡΟΦΑ Feb 12 '23 at 13:01
  • I see you are using version 3 and although I have read... but I have no experience with it. However, there doesn't seem to be anything wrong with the manifest file, so you need to check the communication of popub with the other parts, since as you describe, once you open it and then go to the page, everything is fine... Good job – ΑΓΡΙΑ ΠΕΣΤΡΟΦΑ Feb 13 '23 at 17:27
  • @ΑΓΡΙΑΠΕΣΤΡΟΦΑ That's the weird thing, there is no communication between the popup and the content script, from my understanding, the add-on is always 'active', any time a page is loaded the browser checks if it matches the manifest's "matches", and if so loads the content scripts. I don't think the popup should have anything with the content script loading. I suspect It's specifically a Firefox Nightly problem, for example on Kiwi (an Android chrome browser with extensions enabled) everything works fine, and it's the exact same code. – AmitAM Feb 14 '23 at 19:21

1 Answers1

0

The only solution I've found to this is to edit the manifest and go back to Manifest v2 (using mv2 examples like the old the Beastify demo). Of course that is less than desirable since it breaks compatibility with Chromium-based browsers, but it's worth mentioning I guess.