{"id":43893852,"url":"https://github.com/binki/binki-userscript-when-event-dispatched-async","last_synced_at":"2026-02-06T17:13:13.261Z","repository":{"id":324075053,"uuid":"783083239","full_name":"binki/binki-userscript-when-event-dispatched-async","owner":"binki","description":"Utility to turn an event into an awaitable Promise for userscripts","archived":false,"fork":false,"pushed_at":"2025-11-13T16:25:28.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-13T18:19:20.081Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/binki.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-04-06T22:26:20.000Z","updated_at":"2025-11-13T16:25:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/binki/binki-userscript-when-event-dispatched-async","commit_stats":null,"previous_names":["binki/binki-userscript-when-event-dispatched-async"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/binki/binki-userscript-when-event-dispatched-async","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binki%2Fbinki-userscript-when-event-dispatched-async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binki%2Fbinki-userscript-when-event-dispatched-async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binki%2Fbinki-userscript-when-event-dispatched-async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binki%2Fbinki-userscript-when-event-dispatched-async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/binki","download_url":"https://codeload.github.com/binki/binki-userscript-when-event-dispatched-async/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/binki%2Fbinki-userscript-when-event-dispatched-async/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29169394,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T16:33:35.550Z","status":"ssl_error","status_checked_at":"2026-02-06T16:33:30.716Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-06T17:13:11.544Z","updated_at":"2026-02-06T17:13:13.254Z","avatar_url":"https://github.com/binki.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Usage\n\nInclude this in your userscript using [`@require`](https://wiki.greasespot.net/Metadata_Block#.40require). It is recommended to [use a permalink](https://docs.github.com/repositories/working-with-files/using-files/getting-permanent-links-to-files) instead of referring to `master`.\n\n```js\n// ==UserScript==\n// @name example\n// @version 1.0\n// @require ttps://github.com/binki/binki-userscript-when-event-dispatched-async/raw/master/binki-userscript-when-event-dispatched-async.js\n// ==UserScript==\n\n(async () =\u003e {\n  while (true) {\n    await whenEventDispatchedAsync(window, 'hashchange');\n    console.log(`The URI is now ${window.location.href}`);\n  }\n})();\n```\n\n# API\n\n```js\nwhenEventDispatchedAsync(eventTarget, type, handleEvent, options);\n```\n\nParameters:\n\n* `eventTarget` is the [`EventTarget`](https://dom.spec.whatwg.org/#interface-eventtarget) whose [`addEventListener`](https://dom.spec.whatwg.org/#dom-eventtarget-addeventlistener) and [`removeEventListener`](https://dom.spec.whatwg.org/#dom-eventtarget-removeeventlistener) methods are called.\n* `type` is the name of the event.\n* `handleEvent` (optional) is a function. If supplied, this is passed the event. The function can return `false` to indicate that the wait should continue. Since the `Event` object may only be inspected when handling the event, this must be done here.\n* `options` (optional) is an [`AddEventListenerOptions`](https://dom.spec.whatwg.org/#dictdef-addeventlisteneroptions) object. This can be used to specify things like [`capture`](https://dom.spec.whatwg.org/#dom-eventlisteneroptions-capture). [`passive`](https://dom.spec.whatwg.org/#dom-addeventlisteneroptions-passive) is automatically set to `true` if no `eventHandler` is supplied. [`signal`](https://dom.spec.whatwg.org/#dom-addeventlisteneroptions-signal) is supported and will result in the returned `Promise` being rejected if the signal is fired.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinki%2Fbinki-userscript-when-event-dispatched-async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbinki%2Fbinki-userscript-when-event-dispatched-async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbinki%2Fbinki-userscript-when-event-dispatched-async/lists"}