This commit is contained in:
anzz1 2023-06-12 14:08:27 +02:00 committed by GitHub
commit 00b19be08b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -23,7 +23,7 @@ Any time you're on a Github repo you can click the bookmarklet
and it'll bring up the Active Forks of that repo.
```javascript
javascript:!function(){if(title=document.title,title)if(thing=title.split(/(GitHub\s-\s)*([^:]*)/)[2],thing){var t="https://techgaun.github.io/active-forks/index.html#"+thing;window.open(t)}else window.alert("Not%20a%20valid%20GitHub%20page")}();
javascript:(function(){if(window.location.hostname.match(/github.com+/)){var%20a=window.location.pathname.split('/',3);if(a.length==3){var%20b=encodeURIComponent(a[1]+'/'+a[2]);window.open('https://techgaun.github.io/active-forks/index.html#'+b,'_blank','noreferrer,noopener');return}}window.alert('Not%20a%20valid%20GitHub%20page')})();
```
![Screenshot](screenshot.png "Active Forks in Action")

View File

@ -112,6 +112,10 @@ function fetchAndShow(repo) {
repo = repo.replace('https://github.com/', '');
repo = repo.replace('http://github.com/', '');
repo = repo.replace(/\.git$/, '');
repo = repo.replace(/^\s+/, ''); // remove leading whitespace
repo = repo.replace(/\s+$/, ''); // remove trailing whitespace
repo = repo.replace(/^\/+/, ''); // remove leading slashes
repo = repo.replace(/\/+$/, ''); // remove trailing slashes
fetch(
`https://api.github.com/repos/${repo}/forks?sort=stargazers&per_page=100`