RUN JAVASCRIPT action — execute rule scripts in the sticky tab #3
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/run-javascript-action"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A rule can optionally execute user-authored JavaScript in the existing sticky tab
(with the destination URL available as
url) instead of reloading it. Rules withouta script keep today's reload behavior — fully backward compatible. The incoming tab
is still closed and the sticky tab focused exactly as before.
How it works
browser.tabs.executeScript(stickyTab.id, { code: wrapper, runAt: 'document_idle' })— top frame only. No new manifest permissions, no'unsafe-eval'CSP.const url = JSON.stringify(destUrl)— the URL is never concatenated raw, top-levelawaitworks, and errors/rejections surface as a rejected promise in the background.tabs.update(url)so navigation is never lost.action('reload'default |'script'),actionScript,snippetId(reserved for a future snippet library, stubbed).Changes
background.js:buildScriptWrapper,resolveRuleScript,executeStickyScript, sharedcloseAndFocus, dispatch inhandleNavigation; MV3-migration note abovebuildScriptWrapperoptions.html/js/css: collapsed "Advanced: Action" section per rule (action select + monospace script editor, visible only forscript)lib/acorn.min.js(vendored, MIT — Acorn 8.19.0 via terser, +acorn.LICENSE): save-time syntax validation with line/column in the error, debounced advisory outline while typing; accepts top-levelawait/returnto match the async-IIFE execution contextversionmarker bumped to0.2.0; whole rule objects round-trip via export/importdocs/misc/AMO_SUBMISSION.md(user-authored code, never fetched remotely)Testing
scripts/test-build.sh: 21/21 passweb-ext lint: 0 errors / 0 warnings / 0 noticesbrowserAPI): 25/25 — script path (close-first, no reload, focus), wrapper contract, top-levelawait,throw→ fallback reload, duplicate-URL trigger, legacy rules unchanged, empty-script treated as reloadfeature/local-rule-toggles(merge either way is clean; all checks pass on the merged integration)about:debuggingsmoke test in Firefox still recommended before release (steps in the feature plan)Notes for reviewers
eaef1dc327251fb26423c4e1f6dc896e64ae664dView command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.