brave / brave-ios

Brave iOS Browser
https://brave.com
Mozilla Public License 2.0
1.7k stars 440 forks source link

Manage individual scripts rather than having js on or off #3363

Open adam-ahern opened 3 years ago

adam-ahern commented 3 years ago

Description:

Is it possible to allow the user to manage which scripts run more granularly i.e. allow one script to run on a page but not another.

Device details: iOS 14

Additional Information

Opening this issue as I am just curious as to wether this is possible or not. I'm aware that iOS 14/webkit has the ability to block js totally, but is there an API to block individual scripts.

iccub commented 3 years ago

It is not possible at the moment and not easy to do technically, for global scripts toggle we simply use one flag from Apple api https://developer.apple.com/documentation/webkit/wkpreferences/1536203-javascriptenabled

But it is a good feature request, we should keep this ticket open and visible

Emasoft commented 3 years ago

I know for certain that you can run js extensions (like tampermonkey scripts, etc.) on ios browsers. There are at least two browsers that does allow to install extensions that activates on certain websites: GEAR ALOOK You should add the web extensions panel to the ios version of the BRAVE browser.

iccub commented 3 years ago

This is another topic but you are correct @Emasoft, adding custom scripts to WKWebView is actually easier than detecting and managing website-side scripts one by one, we inject few scripts already, for reader mode, webauth

This is related ticket I believe https://github.com/brave/brave-ios/issues/2684