🏠 Home 

Discussions » Development

Help with a website userscript.

§
Posted: 2025-02-28

I'm trying to make a userscript that can spoof the time for this website to go back in time to play earlier days. Problem is, I can't find where the website is getting the date from. Can someone help me find where it is, or help me write a userscript to do this? I'm not at all versed in userscript.

§
Posted: 2025-03-01
// ==UserScript==
// @name          Heardledecades.com: date spoofer
// @version       1
// @match         https://*.heardledecades.com/*
// @match         https://*.heardledecades.xyz/*
// @icon          https://www.google.com/s2/favicons?sz=64&domain=heardledecades.com
// @run-at        document-start
// @grant         unsafeWindow
// ==/UserScript==
(function() {
'use strict';
const spoofDate = '01.02.2025'.split('.');
const spoofedTime = new Date(`${spoofDate[2]}-${spoofDate[1]}-${spoofDate[0]}T12:00:00Z`);
unsafeWindow.Date.now = () => spoofedTime.getTime();
}());

Works using latest Firefox. Didn't test Chrome

§
Posted: 2025-03-01

It's unfortunately pretty inconsistent with chrome. It seems to need a full new page, not just a refresh. I'm gonna snoop around a bit to see if I can fix that, but thanks for the code anyway.

§
Posted: 2025-03-01

I've had the exact problem, but I have an outdated Chrome and it had similar problems before, so I did use Firefox for this case. Since you have modern Chrome, you can try another script manager for the case. If you're using Tampermonkey, try to use the Violentmonkey, or vice versa. You can have them both together, using one for this script only

§
Posted: 2025-03-01

Inconsistency reason might be the script injection speed. It is not fast enough sometimes, for some reason. If that is correct, you can fix this only by using a different approach for the script. One would be intercepting the website script and deferring it, or making an edit

§
Posted: 2025-03-04
Edited: 2025-03-04

Just switch Tampermonkey's setting "Security - Content Script API" to "Userscripts API Dynamic" makes @run-at document-start scripts a lot faster (usually earlier than any script execution in webpage). Similar setting is "Synchrous page mode" in Violentmonkey.

§
Posted: 2025-03-05

Switching to synchronous page mode was the fix, thanks a bunch. Ended up uploading my final script for the hell of it.

Post reply

Sign in to post a reply.