From b843fa1b26334f19e3c8012d083a2b62c8855631 Mon Sep 17 00:00:00 2001 From: samuel Date: Sun, 16 Nov 2025 12:53:44 +0100 Subject: [PATCH] fix bug with search regex --- CHANGELOG.md | 4 ++++ manifest.json | 2 +- metadata.json | 4 ++-- src/kaplus.js | 18 ++++++++++++------ 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c0aefd..f1b476a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 1.7.4 (2025-11-16) + +- correction bug de calcul des secondes en utilisant search regex + ## 1.7.3 (2025-11-16) - correction bug de calcul des secondes en utilisant le temps du serveur diff --git a/manifest.json b/manifest.json index 3ff6838..6fffd22 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 3, "name": "KAplus", - "version": "1.7.3", + "version": "1.7.4", "developer": { "name": "Samuel Campos", diff --git a/metadata.json b/metadata.json index 6e7422d..2c63408 100644 --- a/metadata.json +++ b/metadata.json @@ -5,8 +5,8 @@ "firefox" ], "release_notes": { - "fr": "- correction bug de calcul des secondes en utilisant le temps du serveur", - "en-US": "- fix bug on seconds by using server time" + "fr": "- correction bug de calcul des secondes en utilisant search regex", + "en-US": "- fix bug on seconds by using search regex" } } } \ No newline at end of file diff --git a/src/kaplus.js b/src/kaplus.js index 4aac046..b9e9151 100644 --- a/src/kaplus.js +++ b/src/kaplus.js @@ -39,6 +39,12 @@ function createInput(type, name, value) { return elt; } +function searchPoint(text) { + let index = text.search(/\d{3}\|\d{3}/); + let point = text.slice(index, index + 7).split("|"); + return {x: point[0], y: point[1]} +} + function shortcutElementReplace(elt, img, text) { // If more than one hyperlink element found, // then keep the last one but with href of the first one. @@ -230,16 +236,16 @@ function main() { let hour = arrival.toLocaleTimeString("fr-FR"); arrivalDateCell.textContent = arrivalDateCell.textContent.replace(/(.*)\d\d:\d\d(.*)/, "$1" + hour + "$2"); - let startPoint = cells[2].textContent.replace(/.*(\d{3}\|\d{3}).*/, "$1").split("|"); - let targetPoint = cells[1].textContent.replace(/.*(\d{3}\|\d{3}).*/, "$1").split("|"); + let startPoint = searchPoint(cells[2].textContent); + let targetPoint = searchPoint(cells[1].textContent); let calculatorCell = document.createElement("td"); let calculatorForm = document.createElement("form"); calculatorForm.setAttribute("method", "post"); calculatorForm.setAttribute("action", "/?s=tools&m=runtime_calculator&inta=calculate"); - calculatorForm.appendChild(createInput("hidden", "start_x", startPoint[0])); - calculatorForm.appendChild(createInput("hidden", "start_y", startPoint[1])); - calculatorForm.appendChild(createInput("hidden", "target_x", targetPoint[0])); - calculatorForm.appendChild(createInput("hidden", "target_y", targetPoint[1])); + calculatorForm.appendChild(createInput("hidden", "start_x", startPoint.x)); + calculatorForm.appendChild(createInput("hidden", "start_y", startPoint.y)); + calculatorForm.appendChild(createInput("hidden", "target_x", targetPoint.x)); + calculatorForm.appendChild(createInput("hidden", "target_y", targetPoint.y)); let calculatorImg = document.createElement("input"); calculatorImg.setAttribute("type", "image"); calculatorImg.setAttribute("src", chrome.runtime.getURL("images/calculator.svg"));