diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..ab99fb2 --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,5 @@ +# Agent Instructions + +## Pull Requests + +- PR titles must follow conventional commit format, such as `fix: handle Safari without requestIdleCallback`. diff --git a/package.json b/package.json index ea8db47..40802d3 100755 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "transit-easy", "displayName": "TransitEasy", - "version": "2.0.0", + "version": "2.0.1", "private": "true", "description": "Chrome Extension that allows you to see transit directions for listings on StreetEasy", "license": "MIT", @@ -9,6 +9,7 @@ "scripts": { "dev": "wxt", "build": "wxt build", + "build:safari": "wxt build -b safari", "zip": "wxt zip", "lint": "oxlint", "lint:fix": "oxlint --fix", diff --git a/src/entrypoints/content/index.tsx b/src/entrypoints/content/index.tsx index 7e4cd63..2a6638d 100644 --- a/src/entrypoints/content/index.tsx +++ b/src/entrypoints/content/index.tsx @@ -50,9 +50,18 @@ export default defineContentScript({ subtree: true, }); - requestIdleCallback(mount); + const cancelInitialMount = (() => { + if (typeof window.requestIdleCallback === "function") { + const handle = window.requestIdleCallback(mount); + return () => window.cancelIdleCallback(handle); + } + + const handle = window.setTimeout(mount, 0); + return () => window.clearTimeout(handle); + })(); ctx.onInvalidated(() => { + cancelInitialMount(); observer.disconnect(); cleanup(); });