Mirror script for Forgejo
A lightweight companion script for Forgejo that restores its' engagement metrics to mirrored repositories by pulling live Star and Fork counts from the original source.
Designed to work seamlessly with our brand-inspired Melosso Forgejo Theme.
Forgejo mirrors only synchronize Git data, leaving social metrics like stars and forks at zero. This makes it difficult to see a project's popularity or "social proof" at a glance on your local instance.
This script fills those gaps by fetching live engagement data from the original source (GitHub, GitLab, etc.) and overlaying it onto your Forgejo UI. All fetched metrics are cached locally for 24 hours to ensure your instance stays fast and respects API rate limits.
The script has universal support for GitHub, GitLab, GitBucket, and Gitea-based instances. It automatically identifies mirrors through the Forgejo API and adds a small snippet to your custom header template.
Important Privacy Note: While Forgejo syncs the code server-side, this script creates a client-side leak by forcing the visitor's browser to announce itself to GitHub's API just to update the "Star" count. This means the visitor's IP address and the repository they are viewing are visible to the upstream provider (e.g., Codeberg, GitHub). Please make sure to indicate this in your privacy policy if you have one.
Add the contents of mirror-meta.js to your Forgejo custom header template.
-
Use an editor to create or edit the
custom/templates/custom/header.tmplfile -
Make sure to keep the code in the
<script>tag -
Restart Forgejo:
sudo systemctl restart forgejo
Edit the top of the script to toggle features:
const enableStars = true;
const enableForks = true;
// If you don't like to use animations:
const useAnimation = true;Published and licensed under the AGPL-3.0 license.
