From 2f3521d2cf17d22fcda6c243933e5e79075df2bc Mon Sep 17 00:00:00 2001 From: Martinski4GitHub <119833648+Martinski4GitHub@users.noreply.github.com> Date: Wed, 24 Jun 2026 06:58:19 -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 +- uiDivStats.sh | 4 ++-- uidivstats_www.asp | 8 ++++---- uidivstats_www.js | 31 ++++++++++++++++++++++++++++++- 4 files changed, 37 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 24657bc..f2b2a29 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # uiDivStats - WebUI for Diversion statistics ## v4.0.17 -### Updated on 2026-Apr-24 +### Updated on 2026-Jun-24 ## About A graphical representation of domain blocking performed by Diversion. diff --git a/uiDivStats.sh b/uiDivStats.sh index 07871d8..d33c231 100644 --- a/uiDivStats.sh +++ b/uiDivStats.sh @@ -13,7 +13,7 @@ ## Forked from https://github.com/jackyaz/uiDivStats ## ## ## ################################################################### -# Last Modified: 2026-Apr-24 +# Last Modified: 2026-Jun-24 #------------------------------------------------------------------ ################# Shellcheck directives ############### @@ -36,7 +36,7 @@ ### Start of script variables ### readonly SCRIPT_NAME="uiDivStats" readonly SCRIPT_VERSION="v4.0.17" -readonly SCRIPT_VERSTAG="26042400" +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.d" diff --git a/uidivstats_www.asp b/uidivstats_www.asp index c5566f0..d41b791 100644 --- a/uidivstats_www.asp +++ b/uidivstats_www.asp @@ -30,9 +30,9 @@ p{font-weight:bolder}thead.collapsible-jquery{color:#fff;padding:0;width:100%;bo diff --git a/uidivstats_www.js b/uidivstats_www.js index b3e34d0..0ad6258 100644 --- a/uidivstats_www.js +++ b/uidivstats_www.js @@ -1,5 +1,5 @@ /**----------------------------**/ -/** Last Modified: 2026-Jan-18 **/ +/** Last Modified: 2026-Jun-24 **/ /**----------------------------**/ var maxNoChartsBlocked = 6; @@ -600,6 +600,35 @@ function LogarithmicFormatter(tickValue,index,ticks) } }; +/**----------------------------------------------------------------** + ** 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('uidivstats_'+cookiename) !== null)