Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -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."
Expand Down
4 changes: 4 additions & 0 deletions src/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"groupRepository": { "message": "仓库" },
"groupProfile": { "message": "用户" },

"featTrendingLinkName": { "message": "Trending 入口" },
"featTrendingLinkDesc": {
"message": "在首页侧栏的 Feed 下方添加 Trending 快捷入口。"
},
"featBetterTopReposName": { "message": "增强的热门仓库" },
"featBetterTopReposDesc": {
"message": "自动展开「热门仓库」列表,并将你喜爱的仓库置顶。"
Expand Down
4 changes: 4 additions & 0 deletions src/_locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"groupRepository": { "message": "儲存庫" },
"groupProfile": { "message": "使用者" },

"featTrendingLinkName": { "message": "Trending 入口" },
"featTrendingLinkDesc": {
"message": "在首頁側欄的 Feed 下方加入 Trending 快捷入口。"
},
"featBetterTopReposName": { "message": "增強的熱門儲存庫" },
"featBetterTopReposDesc": {
"message": "自動展開「熱門儲存庫」清單,並將你喜愛的儲存庫置頂。"
Expand Down
6 changes: 6 additions & 0 deletions src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -63,6 +65,7 @@ const FEATURE_CLASSES: Record<FeatureKey, string[]> = {
"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"],
Expand Down Expand Up @@ -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;
Expand Down
16 changes: 16 additions & 0 deletions src/features/trending-link.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const TRENDING_ICON = `<svg aria-hidden="true" class="octicon octicon-graph" fill="currentColor" width="16" height="16" viewBox="0 0 16 16"><path d="M1.5 1.75V13.5h13.75a.75.75 0 0 1 0 1.5H.75a.75.75 0 0 1-.75-.75V1.75a.75.75 0 0 1 1.5 0Zm14.28 2.53-5.25 5.25a.75.75 0 0 1-1.06 0L7 7.06 4.28 9.78a.751.751 0 0 1-1.042-.018.751.751 0 0 1-.018-1.042l3.25-3.25a.75.75 0 0 1 1.06 0L10 7.94l4.72-4.72a.751.751 0 0 1 1.042.018.751.751 0 0 1 .018 1.042Z"/></svg>`;

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 = `<a href="/trending" class="ActionListContent ActionListContent--visual16">
<span class="ActionListItem-visual ActionListItem-visual--leading">${TRENDING_ICON}</span>
<span class="ActionListItem-label">Trending</span>
</a>`;
feedItem.after(item);
}
}
1 change: 1 addition & 0 deletions src/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions src/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 12 additions & 0 deletions static/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,18 @@ <h2 class="brand-title" data-i18n="settingsTitle">Settings</h2>
<span class="slider"></span>
</label>
</li>
<li class="feature-item">
<div class="feature-info">
<div class="feature-name" data-i18n="featTrendingLinkName">Trending Link</div>
<div class="feature-desc" data-i18n="featTrendingLinkDesc">
Add a Trending shortcut below Feed in the home sidebar.
</div>
</div>
<label class="toggle">
<input type="checkbox" id="feature-trending-link" checked />
<span class="slider"></span>
</label>
</li>
</ul>
</details>

Expand Down
Loading