diff --git a/index.ts b/index.ts index 04f94a5..343af75 100644 --- a/index.ts +++ b/index.ts @@ -61,17 +61,19 @@ TEST: addTests('isCompareWikiPage', [ 'https://github.com/brookhong/Surfingkeys/wiki/Color-Themes/_compare/8ebb46b1a12d16fc1af442b7df0ca13ca3bb34dc...80e51eeabe69b15a3f23880ecc36f800b71e6c6d', ]); +/** + * @deprecated Use `isHome` and/or `isFeed` instead + */ export const isDashboard = (url: URL | HTMLAnchorElement | Location = location): boolean => !isGist(url) && /^$|^(orgs\/[^/]+\/)?dashboard(-feed)?(\/|$)/.test(getCleanPathname(url)); TEST: addTests('isDashboard', [ 'https://github.com///', 'https://github.com//', 'https://github.com/', 'https://github.com', - 'https://github.com/orgs/test/dashboard', + 'https://github.com/orgs/refined-github/dashboard', 'https://github.com/dashboard/index/2', 'https://github.com//dashboard', 'https://github.com/dashboard', - 'https://github.com/orgs/edit/dashboard', 'https://github.big-corp.com/', 'https://not-github.com/', 'https://my-little-hub.com/', @@ -84,6 +86,31 @@ TEST: addTests('isDashboard', [ 'https://github.com/dashboard-feed', ]); +export const isHome = (url: URL | HTMLAnchorElement | Location = location): boolean => !isGist(url) && /^$|^dashboard\/?$/.test(getCleanPathname(url)); +TEST: addTests('isHome', [ + 'https://github.com', + 'https://github.com//dashboard', + 'https://github.com///', + 'https://github.com//', + 'https://github.com/', + 'https://github.com/dashboard', + 'https://github.big-corp.com/', + 'https://not-github.com/', + 'https://my-little-hub.com/', + 'https://github.com/?tab=repositories', // Gotcha for `isUserProfileRepoTab` + 'https://github.com/?tab=stars', // Gotcha for `isUserProfileStarsTab` + 'https://github.com/?tab=followers', // Gotcha for `isUserProfileFollowersTab` + 'https://github.com/?tab=following', // Gotcha for `isUserProfileFollowingTab` + 'https://github.com/?tab=overview', // Gotcha for `isUserProfileMainTab` + 'https://github.com?search=1', // Gotcha for `isRepoTree` +]); + +export const isFeed = (url: URL | HTMLAnchorElement | Location = location): boolean => !isGist(url) && /^(feed|orgs\/[^/]+\/dashboard)\/?$/.test(getCleanPathname(url)); +TEST: addTests('isFeed', [ + 'https://github.com/feed', + 'https://github.com/orgs/refined-github/dashboard', +]); + export const isEnterprise = (url: URL | HTMLAnchorElement | Location = location): boolean => url.hostname !== 'github.com' && url.hostname !== 'gist.github.com'; TEST: addTests('isEnterprise', [ 'https://github.big-corp.com/',