add greasemonkey support
This commit is contained in:
@@ -117,12 +117,34 @@ The lists are downloaded on first start and compiled into
|
||||
`:adblock-update` re-downloads them. `:adblock-toggle` switches blocking off and
|
||||
on, for when a site breaks.
|
||||
|
||||
## Greasemonkey
|
||||
|
||||
Userscripts go in `~/.local/share/att/att/greasemonkey/` as `*.js` files. They
|
||||
are loaded at startup; after changing them, run `:greasemonkey-reload` and reload
|
||||
the page. Like qutebrowser, att:
|
||||
|
||||
- runs scripts in the page's own JavaScript context (so `unsafeWindow` is just
|
||||
`window`), in iframes too unless `@noframes` is set;
|
||||
- honours `@include`, `@exclude` and `@match` (checked by QtWebEngine itself; a
|
||||
script with none of them runs everywhere), `@run-at document-start` /
|
||||
`document-end` (the default) / `document-idle`, and `@require`, which is
|
||||
downloaded once into `greasemonkey/requires/`;
|
||||
- provides `GM_info`, `GM_setValue`/`GM_getValue`/`GM_deleteValue`/`GM_listValues`,
|
||||
`GM_addStyle`, `GM_addElement`, `GM_xmlhttpRequest`, `GM_openInTab`,
|
||||
`GM_setClipboard`, `GM_log`, `GM_notification` and the promise-based `GM.*`
|
||||
versions.
|
||||
|
||||
Limits: stored values live in the site's `localStorage`, so they are per site
|
||||
rather than shared across sites. `GM_xmlhttpRequest` is a plain XHR, so it can't
|
||||
make cross-origin requests the server doesn't allow (CORS). `@resource` isn't
|
||||
supported. `GM_openInTab` does nothing until new-window requests are handled.
|
||||
|
||||
## Commands
|
||||
|
||||
`:open [-w] <url|query>` (alias `:o`; `-w`, or qutebrowser's `-t`, opens a new
|
||||
window), `:close` (alias `:tab-close`, closes this window), `:quit` (alias `:q`,
|
||||
closes all windows), `:reload`, `:back`, `:forward`, `:stop`, `:history-clear`,
|
||||
`:adblock-update`, `:adblock-toggle`.
|
||||
`:greasemonkey-reload`, `:adblock-update`, `:adblock-toggle`.
|
||||
|
||||
`:open` accepts a full URL, a bare host (`example.com` → `https://example.com`),
|
||||
an existing local path, or free text, which goes to DuckDuckGo.
|
||||
@@ -136,6 +158,7 @@ an existing local path, or free text, which goes to DuckDuckGo.
|
||||
| `src/main.cpp` | `QApplication`, CLI parsing, stylesheet |
|
||||
| `src/browserwindow` | the window, mode state machine, key dispatch, commands |
|
||||
| `src/commandline` | the `:` prompt |
|
||||
| `src/greasemonkey` | userscript loading and the GM_* API wrapper |
|
||||
| `src/history` | SQLite browsing history |
|
||||
| `src/completionview`| the `:open` completion list |
|
||||
| `src/statusbar` | mode / URL / progress line |
|
||||
|
||||
Reference in New Issue
Block a user