diff --git a/src/_locales/en/messages.json b/src/_locales/en/messages.json index cb26cb0..d70dc61 100644 --- a/src/_locales/en/messages.json +++ b/src/_locales/en/messages.json @@ -37,6 +37,10 @@ "groupRepository": { "message": "Repository" }, "groupProfile": { "message": "Profile" }, + "featTrendingLinkName": { "message": "Trending Link" }, + "featTrendingLinkDesc": { + "message": "Add a Trending shortcut below Feed in the home sidebar." + }, "featBetterTopReposName": { "message": "Better Top Repositories" }, "featBetterTopReposDesc": { "message": "Auto-expand the \"Top repositories\" list and pin your favorite repos to the top." diff --git a/src/_locales/zh_CN/messages.json b/src/_locales/zh_CN/messages.json index 0a1e7e6..e3cc435 100644 --- a/src/_locales/zh_CN/messages.json +++ b/src/_locales/zh_CN/messages.json @@ -37,6 +37,10 @@ "groupRepository": { "message": "仓库" }, "groupProfile": { "message": "用户" }, + "featTrendingLinkName": { "message": "Trending 入口" }, + "featTrendingLinkDesc": { + "message": "在首页侧栏的 Feed 下方添加 Trending 快捷入口。" + }, "featBetterTopReposName": { "message": "增强的热门仓库" }, "featBetterTopReposDesc": { "message": "自动展开「热门仓库」列表,并将你喜爱的仓库置顶。" diff --git a/src/_locales/zh_TW/messages.json b/src/_locales/zh_TW/messages.json index 369919f..191686c 100644 --- a/src/_locales/zh_TW/messages.json +++ b/src/_locales/zh_TW/messages.json @@ -37,6 +37,10 @@ "groupRepository": { "message": "儲存庫" }, "groupProfile": { "message": "使用者" }, + "featTrendingLinkName": { "message": "Trending 入口" }, + "featTrendingLinkDesc": { + "message": "在首頁側欄的 Feed 下方加入 Trending 快捷入口。" + }, "featBetterTopReposName": { "message": "增強的熱門儲存庫" }, "featBetterTopReposDesc": { "message": "自動展開「熱門儲存庫」清單,並將你喜愛的儲存庫置頂。" diff --git a/src/content.ts b/src/content.ts index 329f43a..55306f2 100644 --- a/src/content.ts +++ b/src/content.ts @@ -28,6 +28,7 @@ import { injectPRCollapseExpand } from "./features/pr-collapse-expand"; import { injectContributorCard, cleanupContributorCard } from "./features/contributor-card"; import { reserveInfoRowSkeletons } from "./lib/info-row-skeleton"; import { applyPageMarker } from "./lib/page-marker"; +import { injectTrendingLink } from "./features/trending-link"; const FEATURE_KEYS = [ "feature-pr-branch-names", @@ -42,6 +43,7 @@ const FEATURE_KEYS = [ "feature-commit-tags", "feature-commit-diff-stats", "feature-better-top-repos", + "feature-trending-link", "feature-watch-fork-star-popup", "feature-pr-collapse-expand", "feature-contributor-card", @@ -63,6 +65,7 @@ const FEATURE_CLASSES: Record = { "feature-commit-tags": ["better-github-commit-tag"], "feature-commit-diff-stats": ["better-github-commit-diff-stats", "bg-skeleton-pill--commit-diff"], "feature-better-top-repos": [], + "feature-trending-link": ["better-github-trending-nav"], "feature-watch-fork-star-popup": ["bg-wfs-popup"], "feature-pr-collapse-expand": ["better-github-toggle-tree", "better-github-collapse-expand"], "feature-contributor-card": ["better-github-contributor-card"], @@ -149,6 +152,9 @@ function injectFeature(key: FeatureKey): void { case "feature-better-top-repos": injectBetterTopRepos(); break; + case "feature-trending-link": + injectTrendingLink(); + break; case "feature-watch-fork-star-popup": injectWatchForkStarPopup(); break; diff --git a/src/features/trending-link.ts b/src/features/trending-link.ts new file mode 100644 index 0000000..debbf91 --- /dev/null +++ b/src/features/trending-link.ts @@ -0,0 +1,16 @@ +const TRENDING_ICON = ``; + +export function injectTrendingLink(): void { + if (location.pathname !== "/") return; + + const feedItem = document.querySelector('.feed-left-sidebar a[href="/feed"]')?.closest("li"); + if (feedItem && !document.querySelector(".better-github-trending-nav")) { + const item = document.createElement("li"); + item.className = "ActionListItem better-github-trending-nav"; + item.innerHTML = ` + ${TRENDING_ICON} + Trending + `; + feedItem.after(item); + } +} diff --git a/src/options.test.ts b/src/options.test.ts index b6a80db..0cdedc7 100644 --- a/src/options.test.ts +++ b/src/options.test.ts @@ -13,6 +13,7 @@ const FEATURE_KEYS = [ "feature-commit-tags", "feature-commit-diff-stats", "feature-better-top-repos", + "feature-trending-link", "feature-watch-fork-star-popup", "feature-pr-collapse-expand", "feature-contributor-card", diff --git a/src/options.ts b/src/options.ts index fe20b8a..3d6308a 100644 --- a/src/options.ts +++ b/src/options.ts @@ -37,6 +37,7 @@ const FEATURE_KEYS = [ "feature-commit-tags", "feature-commit-diff-stats", "feature-better-top-repos", + "feature-trending-link", "feature-watch-fork-star-popup", "feature-pr-collapse-expand", "feature-contributor-card", diff --git a/static/options.html b/static/options.html index c9bd0bc..c7031a0 100644 --- a/static/options.html +++ b/static/options.html @@ -561,6 +561,18 @@

Settings

+
  • +
    +
    Trending Link
    +
    + Add a Trending shortcut below Feed in the home sidebar. +
    +
    + +