From 155e1bedb0c4ef8feb1d9ae3e7a9acf6942b5723 Mon Sep 17 00:00:00 2001 From: Haka <76921756+Hakorr@users.noreply.github.com> Date: Fri, 31 May 2024 19:59:04 +0300 Subject: [PATCH] Update bypasstimeout.user.js --- .../BypassTimeout/bypasstimeout.user.js | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/Flightradar24.com/BypassTimeout/bypasstimeout.user.js b/Flightradar24.com/BypassTimeout/bypasstimeout.user.js index a779325..6963348 100644 --- a/Flightradar24.com/BypassTimeout/bypasstimeout.user.js +++ b/Flightradar24.com/BypassTimeout/bypasstimeout.user.js @@ -3,18 +3,32 @@ // @namespace HKR // @match https://www.flightradar24.com/* // @grant none -// @version 1.0 +// @version 1.2 // @author HKR -// @description Bypasses the 15-min timeout -// @run-at document-load +// @description Bypasses the 30-min timeout +// @run-at document-start // ==/UserScript== - -(() => { - setInterval(() => { - try { - dispatcher.features['map.timeout.mins'] = 999999999999; - } catch { - // nothing - } - }, 1000); -})(); + +function modifyConfigString(configStr, key, value) { + let regex = new RegExp(`("${key}":\\s*)[^,]+`, 'g'); + let newConfigStr = configStr.replace(regex, `$1${value}`); + + return newConfigStr; +} + +function patchNode(node) { + const changeArr = [ + ['map.timeout.mins', 0] + // room for more changes... + ]; + + changeArr.forEach(x => node.innerText = modifyConfigString(node.innerText, x[0], x[1])); +} + +new MutationObserver(mutationsList => { + mutationsList.forEach(mutationRecord => { + [...mutationRecord.addedNodes] + .filter(node => node.tagName === 'SCRIPT') + .forEach(node => patchNode(node)); + }); +}).observe(document, { childList: true, subtree: true });