violentmonkey / violentmonkey/violentmonkey

[Feature] default to top-level-await

Open
#2,342 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
JavaScript
Stars
8.9k
Forks
759
Avg merge
1d 2h
Merged PRs (30d)
3

Description

Motivation

while it's possible via // @top-level-await (#833), i think this behavior could be default.

Proposed Solution

make this flag the default.

Use Cases

  • it's convenient to await web APIs.
const isIncognito = await navigator.storage.getDirectory().then(() => false).catch(() => true)

(code from https://github.com/Joe12387/detectIncognito/issues/51)

  • less surprises to people new to userscript that expects valid JS syntax to work

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the existing implementation of the // @top-level-await flag and issue #833, then trace how userscripts are processed. Test the proposed default with the provided navigator.storage.getDirectory() example and existing scripts; done means top-level await works without the directive while preserving current userscript behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.