Add UserScript and DevTools supports to Chrome using Xposed framework
We hook the onUpdateUrl
function in UserScript.kt,
add URL comparison there and evaluate JavaScript using the javascript:
scheme.
Chromium based browsers, Bromite, Thorium, Mulch, and Brave are also fully supported. Due to different design ideas, supports for the following browsers are not perfect:
DevTools
front end is removed by its authors;Developer options
menu is removed by its authors.Currently, this project requires Xposed framework installed, such as LSPosed for root users. For non-root users, unfortunately LSPatch is technically not supported yet due to isolated process issue; we are working on it.
Pick up the latest built APK from my repo's GitHub Action and install it. The author uploads releases to Xposed-Modules-Repo when needed, but not that frequently.
You can then install UserScripts from popular sources: URLs that ends with .user.js
.
However, this fails for scripts from some domains like raw.githubusercontent.com
.
For them, one can download those scripts using the download button on the top of Chrome's three dot menu, and
then open your downloaded scripts in Chrome. The installation prompt should show up again.
Alternatively, it is possible to use the Install UserScript
page menu if you simply want to install it
without further editing.
Currently, ChromeXt supports almost all Tampermonkey APIs:
Resources
panel of eruda), GM_unregisterMenuCommand, GM_download, unsafeWindow (= window)These APIs are implemented differently from the official ones, see the source file LocalScripts.kt if you have doubts or questions.
To manage scripts installed by ChromeXt
, here are a simple front end hosted on github.io and two mirrors of it (in case that you have connection issues): onrender.com, netlify.app.
If you cancel the prompt of installing a new UserScript, then you can edit it directly in Chrome.
Use the Install UserScript
page menu to install your modified UserScript.
A valid UserScript fails if the following two conditions hold at the same time:
script-src 'unsafe-eval';
by Content Security Policy;To deal with this extremely rare case, one should
use multiple scripts of normal sizes instead of a giant script
From three dots page menu, ChromeXt offers you
Developer tools
in the UserScript manager front end,Eruda console
in other pages.For Edge
browser, these menus are moved to the page info menu,
which locates at the left corner inside the URL input bar.
The history forward gesture of Chrome is now available near the vertical center of screen.
On other areas, only the system gesture is available.
One can disable it through the Developer options
menu.
(Tap seven times on the Chrome version from the Chrome settings, you will see the Developer options
menu.)
ChromeXt adds a book icon in the page menu to enable reader mode manually.
For blocking network requests, I recommend to use AdAway
or any proxy AD Blocker such as clash
.
A content cosmetic blocker is embedded into ChromeXt with the help of eruda.
Open the Eruda console
from the page menu.
In the Elements
panel, one can use the pointer
icon to select elements on the page.
After clicking the delete
icon for a selected element, a corresponding filter will be saved to the Resources
panel,
where one can manage previous added filters.
These filters are saved in the browser even after clearing the site's data.
Another way to block ADs is using the Content-Security-Policy to block some scripts from loading. See the official Content-Security-Policy Blocker UserScript.
One can edit the User-Agent from the Info
panel of Eruda console
.
A valid User-Agent should contain only ASCII characters.
Currently, ChromeXt only changes the User-Agent
HTTP header, which
works well but is deprecated.
When the User-Agent spoofing is not working, refresh the page using the reload button in the page menu. (By contrast, a swipe refresh might be insufficient.)
Note that the DevTools can also change User-Agent.
Before you submit your pull-requests, please ensure that the command
./gradlew build
or gradlew.bat build
produces no warnings and no errors.
Here are corresponding files you might want / need to change:
file
schemeOpen in Chrome
functionGM_info
adb forward
to support non-root usersorg.matrix.chromext
Release Type: Stable
5/18/2023, 1:16:00 PM