Merge pull request #4188 from GHolk/master

Fix #4158: bookmarklet execution bug
This commit is contained in:
Oliver Blanthorn 2022-04-25 11:39:31 +02:00 committed by GitHub
commit bcad918899
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1326,14 +1326,8 @@ export async function open(...urlarr: string[]) {
// Open URLs that firefox won't let us by running `firefox <URL>` on the command line
return nativeopen(url)
} else if (/^javascript:/.exec(url)) {
const bookmarklet = url.replace(/^javascript:/, "")
document.body.append(
html`
<script>
${bookmarklet}
</script>
`,
)
const escapeUrl = url.replace(/[\\"]/g, "\\$&")
window.eval(`window.location.href = "${escapeUrl}"`)
} else {
const tab = await ownTab()
return openInTab(tab, {}, urlarr)