Created
July 14, 2022 09:03
-
-
Save cceyda/d6b3cc6a56d35d12ec85c7b771103747 to your computer and use it in GitHub Desktop.
Bookmarklet for finding forks that are ahead
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javascript:(async () => { | |
/* while on the forks page, collect all the hrefs and pop off the first one (original repo) */ | |
const aTags = [...document.querySelectorAll('div.repo a:last-of-type')].slice(1); | |
for (const aTag of aTags) { | |
/* fetch the forked repo as html, search for the "This branch is [n commits ahead,] [m commits behind]", print it directly onto the web page */ | |
await fetch(aTag.href) | |
.then(x => x.text()) | |
.then(html => aTag.outerHTML += `${html.match(/This branch is.*/).pop().replace('This branch is', '').replace(/([0-9]+ commits? ahead)/, '<font color="#0c0">$1</font>').replace(/([0-9]+ commits? behind)/, '<font color="red">$1</font>')}`) | |
.catch(console.error); | |
} | |
})(); | |
// Copy the above code block. | |
// On Chrome; right click bookmark bar-> add page->paste into URL line, give meaningful name. | |
// Now when you are on the page showing all the forks on github click the bookmarklet~ may take some time if a lot of forks | |
// Credits: https://stackoverflow.com/a/68335748 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment