Fix bullshit upload timeout in Matrix Element

10/11/2025, 9:48:28 PM

Ekde 2025/10/18. Vidu La ĝisdata versio.

// ==UserScript==
// @name        Fix bullshit upload timeout in Matrix Element
// @namespace   Violentmonkey Scripts
// @match       *://app.element.io/*
// @match       *://app.schildi.chat/*
// @match       *://chat.das-labor.org/*
// @match       *://element.envs.net/*
// @match       *://matrix.dropnet.ch/*
// @match       *://element.gnulinux.club/*
// @match       *://element.nope.chat/*
// @match       *://chat.bark.lgbt/*
// @match       *://chat.socialnetwork24.com/*
// @match       *://chat.tchncs.de/*
// @match       *://element.hot-chilli.im/*
// @match       *://chat.pub.solar/*
// @match       *://matrix.glasgow.social/*
// @match       *://matrix.furryrefuge.com/*
// @match       *://element.catgirl.cloud/*
// @match       *://element.private.coffee/*
// @match       *://element.tedomum.fr/*
// @match       *://app.nitro.chat/*
// @match       *://element.arcticfoxes.net/*
// @match       *://chat.archaeo.social/*
// @match       *://element.fachschaften.org/*
// @match       *://*/*
// @grant       none
// @version     1.0.4
// @author      ainofeet
// @description 10/11/2025, 9:48:28 PM
// @license     GPLv2
// ==/UserScript==

(function() {
    if (window.matrixChat == undefined) return;
    window.origDateNow = Date.now;
    Date.now = window.origDateNow === Date.now ? () => {
        let stack = new Error().stack.toString().split(/\n +at /);
        let applyOffset = stack?.some((i) => i.includes(".upload.onprogress"));
        const actualNow = window.origDateNow();
        const hardcodedShit = 30000;
        const offset = window.newTimeout - hardcodedShit;
        const patchedNow = actualNow + offset;
        if(window.debugPatch && applyOffset) console.trace(
          "Applying patched Date.now");
        return applyOffset ? patchedNow : actualNow;
    } : Date.now;
})()