Skip to content

Instantly share code, notes, and snippets.

@7bitlyrus
Created June 10, 2024 23:33
Show Gist options
  • Save 7bitlyrus/5d99b3f6ef9e9eb6ca509abcb726a6cc to your computer and use it in GitHub Desktop.
Save 7bitlyrus/5d99b3f6ef9e9eb6ca509abcb726a6cc to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Geordle Date Spoofer
// @namespace geordle-fake-date
// @version 1
// @match https://no-jons.xyz/geordle*
// @match http://no-jons.xyz/geordle*
// @grant unsafeWindow
// @run-at document-start
// ==/UserScript==
// https://stackoverflow.com/a/35385518
function fromHTML(html, trim = true) {
// Process the HTML string.
html = trim ? html.trim() : html;
if (!html) return null;
// Then set up a new template element.
const template = document.createElement('template');
template.innerHTML = html;
const result = template.content.children;
// Then return either an HTMLElement or HTMLCollection,
// based on whether the input HTML had one or more roots.
if (result.length === 1) return result[0];
return result;
}
if(unsafeWindow.location.hash) {
// Specify the fake date and time you want to use
const fakeDate = new Date(unsafeWindow.location.hash.substring(1).slice(0, 10) + "T00:00:00");
// Override the global Date object with a custom FakeDate class
class FakeDate extends Date {
constructor() {
super();
return fakeDate;
}
}
unsafeWindow.Date = FakeDate;
}
unsafeWindow.changeDate = function() {
let entry = prompt("Enter the desired date in format YYYY-MM-DD:");
entry = entry.slice(0, 10);
let vaildate = new Date(entry).toISOString().slice(0, 10);
if(entry == vaildate) {
window.location = location.pathname + "#" + entry;
unsafeWindow.location.reload();
}
}
let game = document.getElementById("game");
let button = fromHTML("<button style='position:absolute;z-index: 1000' onclick='changeDate()'>" + new unsafeWindow.Date().toISOString().slice(0, 10) + "</button>");
document.body.append(button);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment