From b3b9ea55d1619b6708417923f73cef6b9f5f25cd Mon Sep 17 00:00:00 2001 From: Kumi Date: Thu, 4 Jul 2024 14:31:27 +0200 Subject: [PATCH] feat(navigation): enhance link handling and fetch redirects Refactored feedback and quiz link detection to push both types to the feedbackLinks array. Updated nextContent and openQuizModal functions to handle "/quiz/" links similarly to "/feedback/" links, including replacing "view" with "attempt" and ensuring they are fetched to resolve potential redirects. This async handling ensures users are directed accurately. Also, consolidated logic for URL manipulation to maintain consistency. --- script.js | 56 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/script.js b/script.js index 59bb27c..d3e88ce 100644 --- a/script.js +++ b/script.js @@ -21,8 +21,12 @@ function getFeedbackLinks() { links.forEach((link) => { const href = link.getAttribute("href"); // Check if the href includes "/feedback/" - if (href && href.includes("/feedback/")) { - feedbackLinks.push(href); + if (href) { + if (href.includes("/feedback/")) { + feedbackLinks.push(href); + } else if (href.includes("/quiz/")) { + feedbackLinks.push(href); + } } }); @@ -91,7 +95,7 @@ loadScript( openInModal("about:blank"); } - function nextContent() { + async function nextContent() { // Get the currently executing