bethylamine / soupcan

A cross-browser extension for Twitter to bring @WhatIsAWomanBot features into your browser.
GNU General Public License v3.0
19 stars 2 forks source link

Grant host permissions on mobile from options page #118

Closed INSANEMODE closed 6 months ago

INSANEMODE commented 6 months ago

On Firefox for android, permissions cannot be granted or denied by the user through the settings, including host permissions. Due to this limitation, content scripts cannot load without clicking the extension icon, every time you refresh the page or go to another tab.

This option will request the host permissions from the extension itself, allowing the user to allow/deny host permissions. The option is redundant on desktop browsers, so it could potentially be hidden if it isn't relevant to the platform.

On Chromium browsers, this permission can't be revoked after granting it, through the extension.

I do not know if this is a problem on mobile browsers like kiwi, because i couldn't get the extensions page to load properly on my device, or my emulator, with the current version available on the play store.

Video of problem, and feature in use: https://www.youtube.com/watch?v=HW7CY-SXvnI

bethylamine commented 6 months ago

Instead of being an option, can you make it prompt for permission on any twitter page load if it doesn't have permissions? I feel like this option will be non-discoverable. This will also make it more obvious for Firefox users that additional permissions are required.

INSANEMODE commented 6 months ago

Sure, I'll take a look at it after I get off work.

INSANEMODE commented 6 months ago

If you do not want the changes to the setup flow, it can be reverted or changed easily.

On Firefox for android, permissions.request was only added in version 120, so if gecko_android gets added to your manifest in the future to support android(probably after figuring out context menu alternatives and reports window scrolling), that should probably be your strict_min_version.

Also, permissions.request can only be called through a user input handler, so it can't just directly prompt a user from a background script. That is the reason i added it to the start page.

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/permissions/request

https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/User_actions

bethylamine commented 6 months ago

Thanks, it looks good! I'll test it when I'm at my desk and merge in when I can.

bethylamine commented 6 months ago

I made the process a bit more streamlined, would you like to give it a go and make sure it still works on all the platforms you're targeting?

INSANEMODE commented 6 months ago

Sure, I'll be home soon, and I can test it within the hour.

INSANEMODE commented 6 months ago

Clean up looks good, and looks to be working correctly on chrome desktop, firefox desktop, and firefox for android.

The check for the twitter Oauth tab to prevent opening the permissions tab works.

Denying the permissions on firefox shows that you denied them, and asks you to grant them again.

Revoking the permissions after the setup screen causes you to be asked to grant the permissions again when visiting twitter.com /x.com