Skip to content

Commit 0da7d50

Browse files
authored
Add detections for all user profile pages (#4)
1 parent 6e076bb commit 0da7d50

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ collect.set('isDashboard', [
5858
'https://not-github.com/',
5959
'https://my-little-hub.com/',
6060
'https://github.com/?tab=repositories', // Gotcha for `isUserProfileRepoTab`
61+
'https://github.com/?tab=stars', // Gotcha for `isUserProfileStarsTab`
62+
'https://github.com/?tab=followers', // Gotcha for `isUserProfileFollowersTab`
63+
'https://github.com/?tab=following', // Gotcha for `isUserProfileFollowingTab`
6164
]);
6265

6366
export const isEnterprise = (url: URL | Location = location): boolean => url.hostname !== 'github.com' && url.hostname !== 'gist.github.com';
@@ -354,10 +357,25 @@ collect.set('isBranches', [
354357

355358
export const isUserProfile = (): boolean => exists('.user-profile-nav');
356359

360+
export const isUserProfileMainTab = (): boolean =>
361+
isUserProfile() && !new URLSearchParams(location.search).get('tab');
362+
357363
export const isUserProfileRepoTab = (): boolean =>
358364
isUserProfile() &&
359365
new URLSearchParams(location.search).get('tab') === 'repositories';
360366

367+
export const isUserProfileStarsTab = (): boolean =>
368+
isUserProfile() &&
369+
new URLSearchParams(location.search).get('tab') === 'stars';
370+
371+
export const isUserProfileFollowersTab = (): boolean =>
372+
isUserProfile() &&
373+
new URLSearchParams(location.search).get('tab') === 'followers';
374+
375+
export const isUserProfileFollowingTab = (): boolean =>
376+
isUserProfile() &&
377+
new URLSearchParams(location.search).get('tab') === 'following';
378+
361379
export const isSingleTagPage = (url: URL | Location = location): boolean => /^(releases\/tag)/.test(getRepoPath(url)!);
362380
collect.set('isSingleTagPage', [
363381
'https://github.com/sindresorhus/refined-github/releases/tag/v1.0.0-beta.4',

0 commit comments

Comments
 (0)