icon to reveal the “Quick Settings” sidebar.
Bookmarklets are launched each time you click a button, but should not be run automatically each time a page is loaded. Bookmarklets must have a file extension of .js
or .es
(but not .user.js
or .user.es
).
Traditional bookmarklets, because they can only be accessed via the bookmarks menu, needed to be encoded and squished onto a single line. Not so with Hermit: you can use as many lines as you want, then save as a .js
file.
For your convenience, Hermit comes with a library of User Scripts built in. Simply pick one from our pre-created User Scripts or Bookmarklets.
UserScript definitions are shared across all Lite Apps, but they can be enabled independently for each Lite App. If you make changes to the source code of any UserScript, the changes apply across all Lite Apps that use that UserScript.
Newly-added User Scripts will be available in all Lite Apps after the Lite App is re-launched.
On desktop browsers, there are multiple engines available to run User Scripts (GreaseMonkey, TamperMonkey, ViolentMonkey, etc.) Each engine supports a different subset of features & offers slightly different APIs.
For security & privacy reasons, Hermit does not support the @grant
, @require
, or @resource
tags that can run unverified JavaScript and compromise your privacy. All the code necessary for the UserScript to run must be included in the UserScript source file directly.
@grant
To make your scripts truly portable, use a polyfill such as gm4-polyfill to extend compatibility.
@require
Use a bundling tool such as Webpack to combine all relevant JavaScript dependencies into a single file.
@resource
Use resources inline directly instead of creating a @resource
definition for it.
Android WebView (based on Chromium) does not correctly follow the W3C spec for Content Security Policies, so User Scripts may not run correctly on certain sites. The W3C spec clearly says that:
Policy enforced on a resource SHOULD NOT interfere with the operation of user-agent features like addons, extensions, or bookmarklets. These kinds of features generally advance the user’s priority over page authors, as espoused in [HTML-DESIGN].
Please complain to Google by starring or commenting on this 5-year old bug.
// ==UserScript==
// @name Paint It Red!
// ==/UserScript==
(function() {
const style = document.createElement("style");
style.textContent = "h1 { background-color: red; }";
document.head.appendChild(style);
})();
// ==UserScript==
// @name Custom Fonts
// ==/UserScript==
(function() {
const style = document.createElement("style");
style.textContent = "font-family: 'Inter' !important; font-size: 1rem; line-height: 1.25rem";
document.head.appendChild(style);
})();