Addons are not being attached to newly installed apps

RESOLVED INVALID

Status

RESOLVED INVALID
3 years ago
3 years ago

People

(Reporter: madrid.crespo, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
User Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0
Build ID: 20151030030236

Steps to reproduce:

I am coding a simple Adblocker for Firefox OS. So far, it simply removes all the images at any URL because it matches ["<all_urls>"]:
https://github.com/CodingFree/FXOS-Adblocker/

I can't target the browser, since each new URL looks like a new app installed in the device: http://imgur.com/M0gOsmH.png

So, If I want to remove any advertisement, I need to check whenever there is a new webpage opened in the system and then, attach the addon to the webpage and remove the images.


Actual results:

The addons can only target to any existing app, they are not being attached to any new app installed in the device.

So If for example, you have an Addon for Twitter, If you install and enable the addon and after that, you install the client for Twitter, the addon won't be enabled for that app., which doesn't make any sense because it matches the regex for that addon.

In this case, because of that, If I open a new webpage, the addon won't run in that new webpage; It will only work in any webpage opened before enabling the addon. Thus, an Adblocker could never work on Firefox OS so far.

The only way to enable the Adblocker for any new webpage is to disable and enable again manually.



Expected results:

I expected that any new app that matches the regex for that Addon, would be attached to the addon automatically.
Your injected script needs to wait for the dom to be loaded before doing anything. If you add a simple console.log() in blocker.js I'm quite sure you will see it's loaded in every page.

A more robust way to run your code when the page's dom is ready is to do something like:

if (document.documentElement) {
  initialize();
} else {
  window.addEventListener('load', initialize);
}

function initialize() {
 ..
}
(Reporter)

Comment 2

3 years ago
Thanks Fabrice, I'll keep that in mind. Thanks a lot,Thanks Fabrice, I'll keep that in mind. Thanks a lot, it works \o/ it works \o/
Status: UNCONFIRMED → RESOLVED
Last Resolved: 3 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.