Skip to content

Commit d921ebb

Browse files
committed
Adopt to new github UI (v0.0.2)
1 parent 0ba6fd8 commit d921ebb

File tree

3 files changed

+16
-5
lines changed

3 files changed

+16
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ NB: I have no idea how to make extensions. You might know better than me.
1414

1515
The code as-written is pretty hacky, but it does work.
1616

17-
For testing see [this issue](https://github.com/rust-lang/rust/issues/35121#issuecomment-243008208) ("Load more") or this [pull request](https://github.com/rust-lang/rust/pull/111503/files#diff-b12d31237d3790cfe414f072d2ac7ed12906ccbc95f01b7454c72ebab5001421) ("Load diff"). For debugging on android see [this page](https://extensionworkshop.com/documentation/develop/developing-extensions-for-firefox-for-android/). For instructions on how to publish extensions see [this](https://extensionworkshop.com/documentation/publish/submitting-an-add-on/).
17+
For testing see [this issue](https://github.com/rust-lang/rust/issues/35121#issuecomment-243008208) ("Load more") or this [pull request](https://github.com/rust-lang/rust/pull/111503/files#diff-b12d31237d3790cfe414f072d2ac7ed12906ccbc95f01b7454c72ebab5001421) ("Load diff"). For debugging on android see [this page](https://extensionworkshop.com/documentation/develop/developing-extensions-for-firefox-for-android/). For instructions on how to publish extensions see [this](https://extensionworkshop.com/documentation/publish/submitting-an-add-on/).

content_script.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,27 @@
33
// Clicks on all buttons which contain "Load more..." or "Load diff"
44

55
const find_buttons =
6-
(text) => Array.from(document.getElementsByTagName("button")).filter((e) => e.textContent.includes(text));
6+
(f) => Array.from(document.getElementsByTagName("button")).filter((e) =>
7+
// HACK: "new" github UI doesn't remove the button once clicked.
8+
// `.ariaDisabled` is the only way I found to check if the button was already clicked.
9+
// (otherwise clicking would cause updates, which would cause clicking... -> infinite loop)
10+
e.ariaDisabled !== "true"
11+
&& f(e.textContent)
12+
);
713

814
async function expandAllLoads(mutations) {
915
// If a text or button node was added
1016
if (!mutations.some((m) => Array.from(m.addedNodes).some((n) => n.nodeName === "#button" || n.nodeName === "#text"))) {
1117
return
1218
}
1319

14-
// Click on all "Load more…" and "Load diff" buttons
15-
let loads = find_buttons("Load more…").concat(find_buttons("Load diff"));
20+
// Click on all the "Load more…" and its variations buttons
21+
let loads = find_buttons((text) =>
22+
text.includes("Load more…")
23+
|| text.includes("Load diff")
24+
|| text.includes("Load all")
25+
|| (text.includes("Load ") && text.includes(" more")) // "Load 150 more"
26+
);
1627
loads.forEach((b) => b.click());
1728
}
1829

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33
"name": "github-no-more",
44
"description": "No more \"Load more...\" on github",
5-
"version": "0.0.1",
5+
"version": "0.0.2",
66
"homepage_url": "https://github.com/WaffleLapkin/github-no-more",
77
"icons": {
88
"256": "icons/icon.png"

0 commit comments

Comments
 (0)