Brave now lets you inject custom JavaScript to tweak websites
3 mins read

Brave now lets you inject custom JavaScript to tweak websites

Brave Browser is getting a new feature called ‘custom scriptlets’ that lets advanced users inject their own JavaScript into websites, allowing deep customization and control over their browsing experience.

The new feature is coming in Brave Browser version 1.75 for the desktop and is very similar to the popular TamperMonkey and GreaseMonkey browser extensions, which allow users to create “user scripts” that modify the functionality of specific websites.

“Starting with desktop version 1.75, advanced Brave users will be able to write and inject their own scriptlets into a page, allowing for better control over their browsing experience,” explained Brave in the announcement.

Brave says that the feature was initially created to debug the browser’s adblock feature but felt it was too valuable not to share with users.

Brave’s custom scriptlets feature can be used to modify webpages for a wide variety of privacy, security, and usability purposes.

For privacy-related changes, users write scripts that block JavaScript-based trackers, randomize fingerprinting APIs, and substitute Google Analytics scripts with a dummy version.

In terms of customization and accessibility, the scriptlets could be used for hiding sidebars, pop-ups, floating ads, or annoying widgets, force dark mode even on sites that don’t support it, expand content areas, force infinite scrolling, adjust text colors and font size, and auto-expand hidden content.

For example, the script below will remove sidebars from a particular website.

Brave Browser custom scriptlet
Brave Browser custom scriptlet

For performance and usability, the scriptlets can block video autoplay, lazy-load images, auto-fill forms with predefined data, enable custom keyboard shortcuts, bypass right-click restrictions, and automatically click confirmation dialogs.

The possible actions achievable by injected JavaScript snippets are virtually endless. However, caution is advised, as running untrusted custom scriptlets may cause issues or even introduce some risk.

How to use Brave scriptlets

Brave says the scriptlets are powerful tools in the hands of knowledgeable users. At the same time, there’s a risk that custom JavaScript can cause website problems.

For this reason, it has placed the new feature behind a Developer mode flag in Shields Content filtering

You can access the new feature by going to “brave://settings/shields/filters,” enabling “Developer mode,” and then clicking on the “Add new scriptlet” button.

Enabling the new feature
Enabling the new feature

A box will appear warning the user they should not paste code they don’t understand as this could result in privacy risks.

Adding a new scriptlet
Adding a new scriptlet

Brave’s custom scriptlet feature follows filter rule syntax similar to ad-blocking rules in uBlock Origin or AdGuard. For more information on that, check here.

Those interested in experimenting with Brave’s new feature should only use their own code or those of people they trust, strictly avoiding anything that hasn’t been thoroughly scrutinized.

It is also possible to subscribe to existing adblock filter lists, so that their rules are automatically used in Brave.

Leave a Reply

Your email address will not be published. Required fields are marked *