diff --git a/src/helpers/get-developer-info.ts b/src/helpers/get-developer-info.ts index 04c4173c..f3b2c04d 100644 --- a/src/helpers/get-developer-info.ts +++ b/src/helpers/get-developer-info.ts @@ -12,3 +12,7 @@ export async function isDeveloperWithMeta() { pageDetect.isUserProfile() && (await metaStore.has(getDeveloperName())) ); } + +export function checkLogined() { + return !!$('meta[name="user-login"]').attr('content'); +} diff --git a/src/pages/ContentScripts/features/repo-fork-tooltip/index.tsx b/src/pages/ContentScripts/features/repo-fork-tooltip/index.tsx index 46d61f50..4d6ee9d1 100644 --- a/src/pages/ContentScripts/features/repo-fork-tooltip/index.tsx +++ b/src/pages/ContentScripts/features/repo-fork-tooltip/index.tsx @@ -33,8 +33,9 @@ const init = async (): Promise => { repoName = getRepoName(); await getData(); - await elementReady('a[data-ga-click*="show fork modal"]'); - $('a[data-ga-click*="show fork modal"]').attr({ + const selector = '#fork-button'; + await elementReady(selector); + $(selector).attr({ 'data-tip': '', 'data-for': 'fork-tooltip', 'data-class': `floating-window ${githubTheme}`, diff --git a/src/pages/ContentScripts/features/repo-star-tooltip/index.tsx b/src/pages/ContentScripts/features/repo-star-tooltip/index.tsx index e94f424d..97ef1062 100644 --- a/src/pages/ContentScripts/features/repo-star-tooltip/index.tsx +++ b/src/pages/ContentScripts/features/repo-star-tooltip/index.tsx @@ -13,6 +13,7 @@ import { import { getStars } from '../../../../api/repo'; import View from './view'; import { RepoMeta, metaStore } from '../../../../api/common'; +import { checkLogined } from '../../../../helpers/get-developer-info'; const githubTheme = getGithubTheme(); const featureId = features.getFeatureID(import.meta.url); @@ -33,7 +34,11 @@ const init = async (): Promise => { repoName = getRepoName(); await getData(); - await elementReady('a[data-ga-click*="star button"]'); + const isLogined = checkLogined(); + const selector = isLogined + ? 'button[data-ga-click*="star button"]' + : 'a[data-hydro-click*="star button"]'; + await elementReady(selector); const attributes = { 'data-tip': '', 'data-for': 'star-tooltip', @@ -46,7 +51,7 @@ const init = async (): Promise => { 'data-text-color': githubTheme === 'light' ? '#24292F' : '#C9D1D9', 'data-background-color': githubTheme === 'light' ? 'white' : '#161B22', }; - $('button[data-ga-click*="star button"]').attr(attributes); + $(selector).attr(attributes); const container = document.createElement('div'); container.id = featureId;