{"id":13479202,"url":"https://github.com/refined-github/github-url-detection","last_synced_at":"2026-04-05T18:03:02.432Z","repository":{"id":38142407,"uuid":"261611752","full_name":"refined-github/github-url-detection","owner":"refined-github","description":"Which GitHub page are you on? Is it an issue? Is it a list? Perfect for your WebExtension or userscript.","archived":false,"fork":false,"pushed_at":"2026-01-21T17:45:14.000Z","size":2428,"stargazers_count":133,"open_issues_count":8,"forks_count":30,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-01-22T05:31:25.075Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://npm.im/github-url-detection","language":"TypeScript","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/refined-github.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":".github/funding.yml","license":"license","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},"funding":{"github":"fregante","custom":["paypal.me/fregante","www.buymeacoffee.com/fregante"]}},"created_at":"2020-05-06T00:15:00.000Z","updated_at":"2026-01-21T17:45:18.000Z","dependencies_parsed_at":"2022-07-14T23:30:46.848Z","dependency_job_id":"24689090-1a43-4bcb-8315-255c6768de22","html_url":"https://github.com/refined-github/github-url-detection","commit_stats":{"total_commits":630,"total_committers":107,"mean_commits":5.88785046728972,"dds":0.6857142857142857,"last_synced_commit":"a359e5bac4b63d321704f2cde61a2c352ea7aeb3"},"previous_names":["fregante/github-url-detection"],"tags_count":84,"template":false,"template_full_name":null,"purl":"pkg:github/refined-github/github-url-detection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refined-github%2Fgithub-url-detection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refined-github%2Fgithub-url-detection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refined-github%2Fgithub-url-detection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refined-github%2Fgithub-url-detection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/refined-github","download_url":"https://codeload.github.com/refined-github/github-url-detection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/refined-github%2Fgithub-url-detection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28968718,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-01T04:44:20.970Z","status":"ssl_error","status_checked_at":"2026-02-01T04:44:19.994Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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":"2024-07-31T16:02:11.357Z","updated_at":"2026-04-05T18:03:02.419Z","avatar_url":"https://github.com/refined-github.png","language":"TypeScript","readme":"# \u003cimg width=\"438\" align=\"right\" src=\"https://user-images.githubusercontent.com/1402241/81425503-01b4d800-9158-11ea-9406-484a1ff37968.png\"\u003e github-url-detection\n\n\u003e Which GitHub page are you on? Is it an issue? Is it a list? Perfect for your WebExtension or userscript.\n\nBattle-tested in [Refined GitHub](https://github.com/sindresorhus/refined-github) extension.\n\n- Try the live [demo](https://refined-github.github.io/github-url-detection/)\n- See the code and expected URLs for [every detection](https://github.com/refined-github/github-url-detection/blob/main/index.ts)\n\n## Install\n\n```sh\nnpm install github-url-detection\n```\n\n```js\n// This package is pure ESM\nimport * as pageDetect from 'github-url-detection';\n```\n\n## Usage\n\n```js\nconst href = 'https://github.com/refined-github/github-url-detection/issues/1';\nif (pageDetect.isIssue(new URL(href))) { // Pass the URL as an `URL` object\n\talert('The passed URL is of an issue!')\n}\n\nif (pageDetect.isRepo()) { // Uses `window.location.href` by default\n\talert('You’re looking at a repo!')\n}\n\nif (pageDetect.isIssueOrPRList()) {\n\talert('You’re looking at a issues and PRs list!')\n}\n```\n\n## API\n\nMost detections are URL-based while others need access to the current `document`. You can determine which ones are URL-based by looking at their signature: URL-based functions have a `url` parameter.\n\n### URL-based detections\n\nBy default, URL-based detections use the `location` global if you don't pass a `url` argument.\n\n```js\nif (pageDetect.isIssueOrPRList()) {\n\talert('You’re looking at a issues or PRs list!')\n}\n```\n\n```js\nif (pageDetect.isIssueOrPRList(new URL('https://github.com/refined-github/github-url-detection/pulls'))) {\n\talert('You’re looking at a issues or PRs list!')\n}\n```\n\nNotice that the `url` parameter is not a plain string but it has to be a proper `URL` or `location` object.\n\n### Document-based detections\n\nBy default, `document`-based detections use the `document` global, which means they can only be used if you have the whole page, you can't just test any random URL string.\n\n```js\nif (pageDetect.isOrganizationProfile()) {\n\talert('You’re on an organization profile, like https://github.com/babel')\n}\n```\n\n### Async detections with `waitFor`\n\nThe `waitFor` helper function allows you to wait for a detection to become true by repeatedly checking it on each animation frame. This is useful for DOM-based detections that need to wait for elements to appear before the document is fully loaded.\n\n```js\nimport {utils, isOrganizationProfile} from 'github-url-detection';\n\nasync function init() {\n\t// Wait for the detection to return true or for the document to be complete\n\tif (!await utils.waitFor(isOrganizationProfile)) {\n\t\treturn; // Not an organization profile\n\t}\n\n\t// The page is now confirmed to be an organization profile\n\tconsole.log('On organization profile!');\n}\n```\n\nThe `waitFor` function:\n- Repeatedly calls the detection function on each animation frame\n- Stops when the detection returns `true` or when `document.readyState` is `'complete'`\n- Returns the final result of the detection\n- Works with any detection function that returns a boolean\n\n## Related\n\n- [github-reserved-names](https://github.com/Mottie/github-reserved-names) - Get a list, or check if a user or organization name is reserved by GitHub.\n- [shorten-repo-url](https://github.com/fregante/shorten-repo-url) - Shorten GitHub links like GitHub shortens Issues and Commit links.\n\n## License\n\nMIT © [Federico Brigante](https://fregante.com)\n","funding_links":["https://github.com/sponsors/fregante","paypal.me/fregante","www.buymeacoffee.com/fregante"],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefined-github%2Fgithub-url-detection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frefined-github%2Fgithub-url-detection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frefined-github%2Fgithub-url-detection/lists"}