From 489ec3a7df69b8ae9c593eb230abf704c156f57c Mon Sep 17 00:00:00 2001 From: Captain ALM Date: Sat, 30 Jul 2022 22:17:33 +0100 Subject: [PATCH] Hopefully fix history state. --- index.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index e349f2c..03e3012 100644 --- a/index.js +++ b/index.js @@ -9,6 +9,7 @@ var SortOrderBStateI = true var SortOrderEnabled = false var SortValue = "" var OrderValue = "" +var ReplaceNeeded = true function SetupJS() { SetupIndexArray() SetupJSTheme() @@ -78,11 +79,16 @@ function PushHistory(url) { var s = true if (window.history) { if (window.history.pushState) { - window.history.pushState({ + var objectData = { light: !!document.getElementById("so-theme"), order: document.getElementById("so-order").value, sort: document.getElementById("so-sort").value - }, "", url); + }; + if (ReplaceNeeded) { + window.history.replaceState(objectData, "", url); + ReplaceNeeded = false + } + window.history.pushState( objectData, "", url); s = false } }