jordwest / news-feed-eradicator

A browser extension that deletes your news feed and replaces it with a nice quote
MIT License
1.22k stars 283 forks source link

[FR} firefox android nightly support #142

Open jroitgrund opened 3 years ago

jroitgrund commented 3 years ago

Hi all,

I recently found out that Firefox Nightly on Android lets you install any add-on if you add it to a custom collection (see https://blog.mozilla.org/addons/2020/09/29/expanded-extension-support-in-firefox-for-android-nightly/). I tried to do this with News Feed Eradicator but unfortunately the settings page where you pick which sites to enable the add-on on doesn't work (tapping only highlights an entry, and it's impossible to toggle any of the sites on). It'd be great to get this working so mobile users can benefit from this add-on too,

P.S. much love for all the work on this, it's made my browsing significantly better.

louisabraham commented 3 years ago

Hi, I'm interested in this as well, how can I help?

louisabraham commented 3 years ago

I have tried to use the settings page on android and I can reproduce. I think I know what the root cause is: when you click on those buttons on Desktop, it prompts the user to enable the addon to access the website in question.

This feature probably doesn't exist on mobile. The easiest way to circumvent this is to simply request permission to access all website data from the beginning.

louisabraham commented 3 years ago

Using the debugging console on my computer, I tried the following:

document.body.onclick = () => {console.log("clicked"); console.log("request", browser.permissions.request({
        permissions: [],
        origins: ['http://www.facebook.com/*',],
    }).then(r => console.log("resolved", r)).catch(r => console.log("error", r)))}

The click gets recorded. If I don't put any url, the request is accepted and returns true. If I put one, the promise never ends.

This means that firefox does not prompt the user for permissions. The bug is reported there: https://github.com/mozilla-mobile/fenix/issues/16912

I think the best is to create another version that puts these permissions as mandatory. This seems to work, as reported by @M-Reimer in this comment

A new Makefile target patches in a new Add-on ID (to make an independent clone of my Add-on) and then merges "permissions" with "optional_permissions" in this clone.

Basically, this only involves modifying manifest.json to merge optional_permissions with permissions:

https://github.com/jordwest/news-feed-eradicator/blob/645ee25e327cd54bc361b635aa101be08a010fd6/src/manifest.json#L6-L28

I am not sure what happens if one requests permissions that are not optional, so you might also want to set success to true here:

https://github.com/jordwest/news-feed-eradicator/blob/645ee25e327cd54bc361b635aa101be08a010fd6/src/store/effects.ts#L134-L137

Could you try publishing a mobile version with those changes @jordwest ?

louisabraham commented 3 years ago

I applied the fixes described above in e6a9f40 and tested on Android. It seems to work on websites that are supported, ie those that don't have a specific mobile version (https://news.ycombinator.com). I could disable and re-enable the blocking without any issue.

There are 3 things to work on:

luca-demma commented 2 years ago

any update on the subject? I would be very interested to use also in android :smiley:

PatMyron commented 1 year ago

https://github.com/jordwest/news-feed-eradicator/issues/67