From 8b601bfc271730a6dc4225fb51d85e1477a638c1 Mon Sep 17 00:00:00 2001
From: Martinski4GitHub <119833648+Martinski4GitHub@users.noreply.github.com>
Date: Wed, 24 Jun 2026 06:59:32 -0700
Subject: [PATCH] Fix for Missing "cookie" Helper Functions
Fix for compatibility issue with latest AsusWRT6 routers, such as the GT-BE19000AI, running 3006.102.8 F/W version, where the webpage generates errors due to missing "cookie" helper functions previously defined in the 'state.js' file (Ported from Unbound Stats WebUI ASP fix supplied by @ExtremeFiretop).
---
README.md | 2 +-
spdmerlin.sh | 4 ++--
spdstats_www.asp | 8 ++++----
spdstats_www.js | 31 ++++++++++++++++++++++++++++++-
4 files changed, 37 insertions(+), 8 deletions(-)
diff --git a/README.md b/README.md
index 24b36ab7..1aa3b746 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,7 @@
# spdMerlin
## v4.4.20
-### Updated on 2026-Apr-15
+### Updated on 2026-Jun-24
## About
spdMerlin is an internet speedtest and monitoring tool for AsusWRT Merlin with charts for daily, weekly and monthly summaries. It tracks download/upload bandwidth as well as latency, jitter and packet loss.
diff --git a/spdmerlin.sh b/spdmerlin.sh
index 1c7eb18a..bc98fb48 100644
--- a/spdmerlin.sh
+++ b/spdmerlin.sh
@@ -14,7 +14,7 @@
## Forked from https://github.com/jackyaz/spdMerlin ##
## ##
##############################################################
-# Last Modified: 2026-Apr-15
+# Last Modified: 2026-Jun-24
#-------------------------------------------------------------
############## Shellcheck directives #############
@@ -39,7 +39,7 @@
readonly SCRIPT_NAME="spdMerlin"
readonly SCRIPT_NAME_LOWER="$(echo "$SCRIPT_NAME" | tr 'A-Z' 'a-z')"
readonly SCRIPT_VERSION="v4.4.20"
-readonly SCRIPT_VERSTAG="26041500"
+readonly SCRIPT_VERSTAG="26062400"
SCRIPT_BRANCH="develop"
SCRIPT_REPO="https://raw.githubusercontent.com/AMTM-OSR/$SCRIPT_NAME/$SCRIPT_BRANCH"
readonly SCRIPT_DIR="/jffs/addons/$SCRIPT_NAME_LOWER.d"
diff --git a/spdstats_www.asp b/spdstats_www.asp
index 0da58e4d..a6467bd3 100644
--- a/spdstats_www.asp
+++ b/spdstats_www.asp
@@ -30,9 +30,9 @@ p{font-weight:bolder;}thead.collapsible-jquery{color:white;padding:0;width:100%;
diff --git a/spdstats_www.js b/spdstats_www.js
index 219690e8..59bbb0ea 100644
--- a/spdstats_www.js
+++ b/spdstats_www.js
@@ -1,5 +1,5 @@
/**----------------------------**/
-/** Last Modified: 2025-Oct-14 **/
+/** Last Modified: 2026-Jun-24 **/
/**----------------------------**/
var daysofweek = ['Mon','Tues','Wed','Thurs','Fri','Sat','Sun'];
@@ -814,6 +814,35 @@ function getTimeFormat(value,format){
return timeformat;
}
+/**----------------------------------------------------------------**
+ ** Compatibility layer for the latest AsusWRT6 routers, such as
+ ** the GT-BE19000AI, where the previous global 'cookie' helper
+ ** functions defined in the 'state.js' file are now removed in
+ ** favour of using the "window.localStorage" property.
+ **----------------------------------------------------------------**/
+if (typeof window.cookie === "undefined" ||
+ typeof window.cookie.get !== "function" ||
+ typeof window.cookie.set !== "function")
+{
+ window.cookie = {
+ get: function (key) {
+ return window.localStorage.getItem(key);
+ },
+
+ /** In the previous 'cookie' function a 3rd argument was given for 'days' **/
+ /** Here, we ignore the value because there is no expiration date anymore **/
+ set: function (key, value, days) {
+ window.localStorage.setItem(key, String(value));
+ },
+
+ unset: function (key) {
+ window.localStorage.removeItem(key);
+ }
+ };
+
+ console.log("Installed localStorage compatibility for cookie API.");
+}
+
function GetCookie(cookiename,returntype){
if(cookie.get('spd_'+cookiename) != null){
return cookie.get('spd_'+cookiename);