Works like jsb but preserves the 'user action' so
it can be used to open/close the sidebar, open
downloaded files etc.
Example usage:
`:bind --mode=browser <C-.> jsua browser.sidebarAction.close()`
`browser.webRequest.on*.addListener` will throw errors if
unsupported extraSpecInfo passed.
We pass the extraSpecInfo for onBeforeRequest for all events,
and add more info in previous release.
Then, some user reported onBeforeRequest event stop working.
We will pass all supported extraSpecInfo for different event
in this commit.
Original code will overwrite the whole object if the same event
is regist even in different url pattern.
E.g:
```
autocmd BeforeRequest https://*/*?handler1 e=>({cancel:true})
autocmd BeforeRequest https://*/*?handler2 e=>({cancel:true})
" this will throw an error
autocmddelete BeforeRequest https://*/*?handler1
```
Firefox's download API [0] currently does not support invalid characters
in the "saveAs" value, and the following error is thrown if download
filename contains illegal character(s). The issue has been reported to
the Firefox team, and currently it is in "WONTFIX" status [1].
"filename must not contain illegal characters"
The issue prevents Tridactyl from downloading files from URLs with
certain "illegal" characters, e.g. ":" (colon), that are valid for URLs,
but are rejected in the filenames by the underlying OS's file system.
The default behaviour for operating systems like Mac is to replace the
invalid character(s) with "space" when saving the file to the disk.
The patches here implement basic filename sanitisation support by
introducing the following three configuration parameters in config.ts:
- illegalfilenamechars
- illegalwindowsfilenames
- illegalfilenamereplacement
Essentially, if the "illegalfilenamechars" are found in the downloaded
filename, these characters are replaced by the
"illegalfilenamereplacement" value. The same logic is applied to each of
the comma-separated "illegalwindowsfilenames" values; if any of these
names matches the "saveAs" file-name, the file-name is suffixed with the
"illegalfilenamereplacement" value.
[0] https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/downloads/download
[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1390473
See also https://esbuild.github.io/content-types/#direct-eval.
Bare ("direct") eval() evaluates in the local scope where it is called
instead of the global scope, which can cause problems (which is why
esbuild complains). Our uses of it don't need local scope, so we can
safely switch to window.eval().
This makes longer invocations _much_ more tolerable, which is super
useful for things like replacing long (racy) sequences of
`autocontain` directives with stuff like the following:
```
js window.tri.config.set('autocontain', Object.fromEntries([ \
['youtube\.com', 'sreyn@goog'], \
['www\.google\.com', 'sreyn@goog'], \
" ...
].map(([k, v]) => ['^https?://[^/]*' + k + '/', v])))
```