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 .github/workflows/buildcanary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
echo "should_run=true" >> $GITHUB_OUTPUT
fi
build:
name: Build Canary
needs: check_date
if: ${{ needs.check_date.outputs.should_run != 'false' || github.event_name != 'schedule' }}
runs-on: ubuntu-latest
Expand Down
76 changes: 63 additions & 13 deletions Profile Folder/chrome/JS/Geckium_updater.uc.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,69 @@ function updateSettings(iteration) {

// PLACEHOLDER UPDATE MECHANISM FOR GECKIUM PUBLIC BETA 1
async function gkCheckForUpdates() {
const ghURL = "https://api.github.com/repos/angelbruni/Geckium/releases?page=1&per_page=1";
// Check for updates based on the channel
if (await gkUpdater.getChannel() == "canary") {
await gkCheckForUpdatesCanary();
} else {
await gkCheckForUpdateReleases();
}

}

// Fetch remote version with timestamp to prevent caching
var gkver = await gkUpdater.getVersion();
fetch(ghURL, {cache: "reload", headers: {"X-GitHub-Api-Version": "2022-11-28", "Accept": "application/vnd.github+json",}})
.then((response) => response.json())
.then((releases) => {
if (releases[0].tag_name !== gkver) {
document.documentElement.setAttribute("gkcanupdate", "true");
}
})
.catch(error => {
console.error("Something happened when checking for newer Geckium builds:", error);
});
async function gkCheckForUpdateReleases() {
const ghURL = "https://api.github.com/repos/angelbruni/Geckium/releases?page=1&per_page=1";

// Fetch remote version with timestamp to prevent caching
var gkver = await gkUpdater.getVersion();
fetch(ghURL, {cache: "reload", headers: {"X-GitHub-Api-Version": "2022-11-28", "Accept": "application/vnd.github+json", "UserAgent": "GeckiumUpdater/1.0"}})
.then((response) => response.json())
.then((releases) => {
if (releases[0].tag_name !== gkver) {
document.documentElement.setAttribute("gkcanupdate", "true");
} else {
document.documentElement.setAttribute("gkcanupdate", "false");
}
})
.catch(error => {
console.error("Something happened when checking for newer Geckium builds:", error);
});
}

async function gkCheckForUpdatesCanary() {
// Canary is under a weird case where it is not an actual release, so we need to get it from github actions.
// Also versioning is different, using the commit hash.
const ghURL = "https://api.github.com/repos/angelbruni/Geckium/actions/workflows/127139753/runs?status=success&branch=main";
var gkverraw = await gkUpdater.getRawVersion();
fetch(ghURL, {cache: "reload", headers: {"X-GitHub-Api-Version": "2022-11-28", "Accept": "application/vnd.github+json", "UserAgent": "GeckiumUpdater/1.0"}})
.then((response) => response.json())
.then((workflow_runs) => {
// JSON is beautiful, isn't it?
let hasUpdate = false;
for (let run of workflow_runs.workflow_runs) {
if (hasUpdate) break;

// check if the latest successful run is newer than the current version. I am assuming they are in order of when they were run.
if (run.head_commit.id.substring(0, 7) == gkverraw) {
// We are on the newest version, abort.
document.documentElement.setAttribute("gkcanupdate", "false");
break;
}

// We know that the latest run is newer than the current version, but we do not know if it actually built anything.
// We need to check the artifacts to see if there is a build.
fetch(run.artifacts_url, {cache: "reload", headers: {"X-GitHub-Api-Version": "2022-11-28", "Accept": "application/vnd.github+json", "UserAgent": "GeckiumUpdater/1.0"}})
.then((response) => response.json())
.then((artifacts) => {
if (artifacts.total_count > 0) {
// We have a build, we can update.
document.documentElement.setAttribute("gkcanupdate", "true");
hasUpdate = true;
}
});
}
})
.catch(error => {
console.error("Something happened when checking for newer Geckium Canary builds:", error);
});
}
window.addEventListener("load", gkCheckForUpdates);
22 changes: 22 additions & 0 deletions Profile Folder/chrome/JS/modules/GeckiumUpdater.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ export class gkUpdater {
throw error; // re-throw the error to propagate it further if needed
}
}
static async getChannel() {
try {
const response = await fetch("chrome://userchrome/content/version.json");
const data = await response.json();

return data.update_channel;
} catch (error) {
console.error('Error fetching JSON:', error);
throw error; // re-throw the error to propagate it further if needed
}
}
static async getRawVersion() {
try {
const response = await fetch("chrome://userchrome/content/version.json");
const data = await response.json();

return data.version;
} catch (error) {
console.error('Error fetching JSON:', error);
throw error; // re-throw the error to propagate it further if needed
}
}

static checkForUpdates() {
return "W.I.P."
Expand Down