Forked from mschmitt/Reload-At-Wallclock.user.js
Last active
November 17, 2024 18:35
-
-
Save Goldenflamer/49961640156c89cd13fc613690e6ca88 to your computer and use it in GitHub Desktop.
Reload-At-Wallclock.user.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Reload at Wallclock | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description Reload at Wallclock | |
// @author You | |
// @match https://mschmitt.github.io/timestamp-tester/ | |
// @match https://tickets.events.ccc.de/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Edit here: ///////////////////////////////////// | |
var target_datetime='2024-11-23T11:00:00.000+0100'; | |
/////////////////////////////////////////////////// | |
var target = new Date(target_datetime); | |
console.log("Userscript: " + target_datetime + " parsed as " + target.toLocaleString() + ", " + target.getMilliseconds() + "ms"); | |
var now = new Date(); | |
if (target < now){ | |
console.log("Userscript: Too late to reload at " + target.toLocaleString() + ", " + target.getMilliseconds() + "ms"); | |
} else { | |
console.log("Userscript: Valid reload time: " + target.toLocaleString() + ", " + target.getMilliseconds() + "ms"); | |
var diff_ms = target - now; | |
setTimeout(function() { location.reload() }, diff_ms); | |
console.log("Userscript: Timeout set. Will reload in: " + diff_ms + " ms"); | |
window.setInterval(function() { console.log("Userscript: " + Math.floor((target - new Date()) / 1000) + " s remaining.") }, 10000); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment