Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<script src="js/technical/layerSupport.js"></script>

<script src="js/game.js"></script>
<script src="js/technical/githack-redirect.js"></script>
<script src="js/technical/loader.js"></script>

<script src="js/technical/temp.js"></script>
Expand Down
1 change: 1 addition & 0 deletions js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let gameInfo = {
discordName: "",
discordLink: "",
initialStartPoints: new Decimal (10), // Used for hard resets and new players
githackBranch: "",
offlineLimit: 1, // In hours
}

Expand Down
22 changes: 22 additions & 0 deletions js/technical/githack-redirect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
if (gameInfo.githackBranch && window.location.hostname === "rawcdn.githack.com") {
// Parse the current user and repo from the URL
const parts = window.location.pathname.split('/');
const user = parts[1];
const repo = parts[2];

// Find latest commit on specified branch
fetch(`https://api.github.com/repos/${user}/${repo}/commits/${gameInfo.githackBranch}`)
.then(response => response.json())
.then(response => {
// Calculate the URL for the latest version of the mod
const updatedURL = `https://rawcdn.githack.com/${user}/${repo}/${response.sha}/index.html?min=1`;

// Do nothing if we're already on that URL
if (updatedURL === window.location.href) {
return;
}

// Redirect to the latest version of the mod
window.location.href = updatedURL;
});
}