2.8 KiB
GitHub OpenScripts
Small, independent OpenScript enhancements for GitHub. Install either script or both.
Scripts
Display Repo Info and File Sizes
DisplayRepoInfo.os.js adds repository information and file sizes directly to GitHub's interface.
- Shows total repository disk usage and repository age in the About sidebar.
- Shows the exact repository creation date and time on hover.
- Adds human-readable sizes beside files in root and nested directory listings.
- Handles GitHub SPA navigation without requiring a page refresh.
- Uses GitHub-native layout, colors, and responsive filename cells.
- Supports private repositories through an optional
GH_PATsecret.
This script requests repository metadata when the About section is rendered and directory contents when a GitHub file listing is rendered. It guards in-progress directory requests to avoid duplicate API calls during DOM updates.
Download GitHub Directory
DownloadDir.os.js adds Download directory to the three-dot menu on GitHub directory pages.
- Makes no GitHub requests on page load, navigation, or menu opening.
- Starts all download-related requests only after Download directory is clicked.
- Uses one recursive Git Trees API request for a normal public repository, then retrieves file bytes from
raw.githubusercontent.comwithout spending additional REST API quota. - Falls back to additional tree requests only when GitHub truncates an unusually large recursive tree response.
- Downloads private repository files through authenticated Git blob requests.
- Builds the ZIP locally in the browser with JSZip and preserves the selected directory as its root folder.
- Handles GitHub SPA navigation and branch names containing slashes.
OpenScript downloads and caches the declared JSZip @require when the script is saved. It is not downloaded again on every GitHub page.
Installation
Each file is a separate OpenScript:
- Open the OpenScript extension popup.
- Click + New.
- Paste the contents of the script you want to install.
- Click save script.
- Repeat for the other script if you want both features.
After updating an installed script, save it again and refresh the current GitHub page once. Later GitHub navigation works without refreshing.
Private Repositories
Both scripts support a GitHub personal access token stored in OpenScript:
- Create a GitHub token with read access to the required private repositories.
- Open OpenScript and select the Secrets tab.
- Add
GH_PATas the key and the token as its value. - Click + Add, then re-save the scripts.
The scripts also recognize GITHUB_PAT, GITHUB_TOKEN, and PAT. Tokens are sent only to api.github.com and are never included in generated ZIP files.