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: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Better GitHub is a Chrome extension that enhances the GitHub experience. Inspire

### Home

- **Feed Auto-Load** — On by default. Scroll near the bottom of `/feed` to load more posts. Turn it off under **Options → Home** to load more posts manually.

- ~~**Better Top Repositories** — Auto-expand the "Top repositories" sidebar list and pin your favorite repos to the top. Works on the dashboard, feed page, and navigation drawer.~~ On GitHub’s new dashboard, use **Edit repositories** in the sidebar to choose your favorites. [GitHub changelog](https://github.blog/changelog/2026-11-20-pin-your-favorite-repositories-to-your-dashboard/)

<details>
Expand Down Expand Up @@ -166,4 +168,4 @@ A few small features have little impact on the page experience. To avoid adding
Right-click the extension icon → **Options**:

- **GitHub Token** — A **classic** personal access token for private repos and review status. Needs `repo` scope. [Create one here](https://github.com/settings/tokens).
- **Feature Toggles** — Enable or disable each feature individually. Changes take effect immediately.
- **Feature Toggles** — Turn features listed on the options page on or off individually. Changes take effect immediately.
4 changes: 3 additions & 1 deletion README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Better GitHub 是一个增强 GitHub 使用体验的 Chrome 插件,灵感源

### 首页

- **Feed 自动加载** — 默认开启。在 `/feed` 页面滚动到接近底部时会自动加载更多动态。想手动加载时,可在**选项 → 首页**中关闭。

- ~~**Better Top Repositories** — 自动展开侧边栏 "Top repositories" 列表,并支持将常用仓库置顶。适用于 Dashboard、Feed 页面和导航抽屉。~~ 在 GitHub 新版首页,点击侧边栏的 **Edit repositories** 即可选择要置顶的仓库。[GitHub 更新公告](https://github.blog/changelog/2026-11-20-pin-your-favorite-repositories-to-your-dashboard/)

<details>
Expand Down Expand Up @@ -166,4 +168,4 @@ Better GitHub 是一个增强 GitHub 使用体验的 Chrome 插件,灵感源
右键扩展图标 → **选项**:

- **GitHub Token** — 用于访问私有仓库和获取 review 状态。需要 **classic** 类型的 token,勾选 `repo` 权限。[点此创建](https://github.com/settings/tokens)。
- **功能开关** — 独立控制每个功能的启用/禁用,修改后即时生效。
- **功能开关** — 可单独开启或关闭选项页列出的功能,修改后即时生效。
45 changes: 45 additions & 0 deletions e2e/regression.spec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,51 @@ async function hydrate(root, html) {
}, html);
}

test("loads successive Feed pages and applies the auto-load toggle immediately", async ({
page,
context,
}) => {
await page.route("https://github.com/feed", (route) =>
route.fulfill({
contentType: "text/html",
body: `<div id="conduit-feed-frame"><form class="js-ajax-pagination">
<div style="height: 200vh"></div><button class="ajax-pagination-btn">More</button>
</form></div>
<script>
document.querySelector("form").onsubmit = (event) => {
event.preventDefault();
const row = document.createElement("article");
row.style.height = "200vh";
event.submitter.replaceWith(row, event.submitter.cloneNode(true));
};
</script>`,
}),
);
await page.goto("https://github.com/feed");
const more = page.getByRole("button", { name: "More" });
for (const count of [1, 2]) {
await expect(page.locator("article")).toHaveCount(count - 1);
await more.scrollIntoViewIfNeeded();
await expect(page.locator("article")).toHaveCount(count);
}

const worker = context.serviceWorkers()[0] ?? (await context.waitForEvent("serviceworker"));
const options = await context.newPage();
await options.goto(new URL("options.html", worker.url()).href);
await options.locator("summary", { hasText: "Home" }).click();
const toggle = options.locator("label", { has: options.locator("#feature-feed-auto-load") });
await toggle.click();
await expect(toggle.locator("input")).not.toBeChecked();

await more.scrollIntoViewIfNeeded();
await more.click();
await expect(page.locator("article")).toHaveCount(3);
await more.scrollIntoViewIfNeeded();
await expect(more).toBeInViewport();
await toggle.click();
await expect(page.locator("article")).toHaveCount(4);
});

test("copies a repository-qualified issue number after GitHub replaces the list", async ({
page,
context,
Expand Down
2 changes: 2 additions & 0 deletions src/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"featTrendingLinkDesc": {
"message": "Add a Trending shortcut below Feed in the home sidebar."
},
"featFeedAutoLoadName": { "message": "Feed Auto-Load" },
"featFeedAutoLoadDesc": { "message": "Load more posts as you scroll near the bottom of the Feed." },
"featDefaultSortName": { "message": "Default Sort by Updated" },
"featDefaultSortDesc": {
"message": "Sort PR and issue lists by recently updated instead of creation time."
Expand Down
2 changes: 2 additions & 0 deletions src/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"featTrendingLinkDesc": {
"message": "在首页侧栏的 Feed 下方添加 Trending 快捷入口。"
},
"featFeedAutoLoadName": { "message": "Feed 自动加载" },
"featFeedAutoLoadDesc": { "message": "在 Feed 页面滚动到接近底部时,自动加载更多动态。" },
"featDefaultSortName": { "message": "默认按更新时间排序" },
"featDefaultSortDesc": {
"message": "PR 和 Issue 列表按最近更新排序,而非创建时间。"
Expand Down
2 changes: 2 additions & 0 deletions src/_locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
"featTrendingLinkDesc": {
"message": "在首頁側欄的 Feed 下方加入 Trending 快捷入口。"
},
"featFeedAutoLoadName": { "message": "Feed 自動載入" },
"featFeedAutoLoadDesc": { "message": "在 Feed 頁面捲動到接近底部時,自動載入更多動態。" },
"featDefaultSortName": { "message": "預設依更新時間排序" },
"featDefaultSortDesc": {
"message": "PR 和 Issue 清單依最近更新排序,而非建立時間。"
Expand Down
7 changes: 7 additions & 0 deletions src/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { injectContributorCard, cleanupContributorCard } from "./features/contri
import { reserveInfoRowSkeletons } from "./lib/info-row-skeleton";
import { applyPageMarker, syncListLayout } from "./lib/page-marker";
import { injectTrendingLink } from "./features/trending-link";
import { cleanupFeedPagination, observeFeedPagination } from "./features/feed-auto-load";

const FEATURE_KEYS = [
"feature-pr-branch-names",
Expand All @@ -47,6 +48,7 @@ const FEATURE_KEYS = [
"feature-commit-tags",
"feature-commit-diff-stats",
"feature-trending-link",
"feature-feed-auto-load",
"feature-watch-fork-star-popup",
"feature-pr-collapse-expand",
"feature-contributor-card",
Expand All @@ -68,6 +70,7 @@ const FEATURE_CLASSES: Record<FeatureKey, string[]> = {
"feature-default-sort": [],
"feature-commit-tags": ["better-github-commit-tag"],
"feature-commit-diff-stats": ["better-github-commit-diff-stats", "bg-skeleton-pill--commit-diff"],
"feature-feed-auto-load": [],
"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"],
Expand All @@ -84,6 +87,7 @@ const FEATURE_CLEANUPS: Partial<Record<FeatureKey, () => void>> = {
"feature-watch-fork-star-popup": cleanupWatchForkStarPopup,
"feature-release-downloads-count": cleanupReleaseAssetDownloads,
"feature-contributor-card": cleanupContributorCard,
"feature-feed-auto-load": cleanupFeedPagination,
};

function isExtensionValid(): boolean {
Expand Down Expand Up @@ -165,6 +169,9 @@ function injectFeature(key: FeatureKey): void {
case "feature-trending-link":
injectTrendingLink();
break;
case "feature-feed-auto-load":
observeFeedPagination();
break;
case "feature-watch-fork-star-popup":
injectWatchForkStarPopup();
break;
Expand Down
39 changes: 39 additions & 0 deletions src/features/feed-auto-load.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
let currentButton: HTMLButtonElement | null = null;
let observer: IntersectionObserver | null = null;

export function cleanupFeedPagination(): void {
observer?.disconnect();
observer = null;
currentButton = null;
}

export function observeFeedPagination(): void {
const button =
location.pathname === "/feed"
? document.querySelector<HTMLButtonElement>(
"#conduit-feed-frame .js-ajax-pagination button.ajax-pagination-btn",
)
: null;
if (button === currentButton) return;

cleanupFeedPagination();
currentButton = button;
if (!button) return;

observer = new IntersectionObserver(
([entry], paginationObserver) => {
if (
!entry.isIntersecting ||
!button.isConnected ||
observer !== paginationObserver ||
location.pathname !== "/feed"
) {
return;
}
paginationObserver.disconnect();
button.click();
},
{ rootMargin: "0px 0px 200px" },
);
observer.observe(button);
}
1 change: 1 addition & 0 deletions src/options.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const FEATURE_KEYS = [
"feature-commit-tags",
"feature-commit-diff-stats",
"feature-trending-link",
"feature-feed-auto-load",
"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 @@ -38,6 +38,7 @@ const FEATURE_KEYS = [
"feature-commit-tags",
"feature-commit-diff-stats",
"feature-trending-link",
"feature-feed-auto-load",
"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" id="feed-auto-load-name" data-i18n="featFeedAutoLoadName">Feed Auto-Load</div>
<div class="feature-desc" data-i18n="featFeedAutoLoadDesc">
Load more posts as you scroll near the bottom of the Feed.
</div>
</div>
<label class="toggle">
<input type="checkbox" id="feature-feed-auto-load" aria-labelledby="feed-auto-load-name" checked />
<span class="slider"></span>
</label>
</li>
</ul>
</details>

Expand Down