Skip to content

Instantly share code, notes, and snippets.

@dante-nl
Created February 27, 2024 15:46
Show Gist options
  • Save dante-nl/5ea074c8b3f298a9d29963d8a2661426 to your computer and use it in GitHub Desktop.
Save dante-nl/5ea074c8b3f298a9d29963d8a2661426 to your computer and use it in GitHub Desktop.
OpenEngine
<!DOCTYPE html><html lang="en"><head></head><body><script>
const oldVersion = "PUT YOUR SHORTCUT VERSION HERE"
const newVersion = "PUT THE LATEST VERSION HERE"
// π—’π—½π—²π—»π—˜π—»π—΄π—Άπ—»π—² v1.0
// Β© dante_nl
// OpenEngine is an engine to check for your shortcut! You can use this for your updater to check for an update, rollback or latest version.
// π—›π—Όπ˜„ π˜π—Ό π˜‚π˜€π—²?
// Put in the current version of the shortcut and the most recent version at the top, and check for the output.
// The engine will output either "latest", "update" and "rollback". You have to the proper actions with that.
// For a full example, please check: <example soon>
numbers_oldversion = oldVersion.replace(/[^0-9]/g, "")
numbers_newversion = newVersion.replace(/[^0-9]/g, "")
if (numbers_oldversion == "" || numbers_newversion == "") {
// the version is purely alphabetical
if (oldVersion == newVersion) {
// latest
document.write("latest")
} else {
document.write("update")
}
} else {
if (parseInt(numbers_oldversion) < parseInt(numbers_newversion)) {
// update available
document.write("update")
} else if (parseInt(numbers_oldversion) > parseInt(numbers_newversion)) {
// rollback available
document.write("rollback")
} else {
// latest version
document.write("latest")
}
}
</script></body></html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment