From a149042c5f9f8a5694710924e6b2292afcf1c873 Mon Sep 17 00:00:00 2001 From: Yakov Kantor <16872793+yakov116@users.noreply.github.com> Date: Mon, 18 May 2020 17:27:20 -0400 Subject: [PATCH] Add detection for all user profile pages --- index.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/index.ts b/index.ts index a23e4407..1b0d94c2 100644 --- a/index.ts +++ b/index.ts @@ -58,6 +58,9 @@ collect.set('isDashboard', [ '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` ]); export const isEnterprise = (url: URL | Location = location): boolean => url.hostname !== 'github.com' && url.hostname !== 'gist.github.com'; @@ -354,10 +357,25 @@ collect.set('isBranches', [ export const isUserProfile = (): boolean => exists('.user-profile-nav'); +export const isUserProfileMainTab = (): boolean => + isUserProfile() && !new URLSearchParams(location.search).get('tab'); + export const isUserProfileRepoTab = (): boolean => isUserProfile() && new URLSearchParams(location.search).get('tab') === 'repositories'; +export const isUserProfileStarsTab = (): boolean => + isUserProfile() && + new URLSearchParams(location.search).get('tab') === 'stars'; + +export const isUserProfileFollowersTab = (): boolean => + isUserProfile() && + new URLSearchParams(location.search).get('tab') === 'followers'; + +export const isUserProfileFollowingTab = (): boolean => + isUserProfile() && + new URLSearchParams(location.search).get('tab') === 'following'; + export const isSingleTagPage = (url: URL | Location = location): boolean => /^(releases\/tag)/.test(getRepoPath(url)!); collect.set('isSingleTagPage', [ 'https://github.com/sindresorhus/refined-github/releases/tag/v1.0.0-beta.4',