diff --git a/status-pages/dhl_redirect_tracking_page.user.js b/status-pages/dhl_redirect_tracking_page.user.js index 3a4973b..5212051 100644 --- a/status-pages/dhl_redirect_tracking_page.user.js +++ b/status-pages/dhl_redirect_tracking_page.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name Redirect DHL tracking page // @description Redirects to a more static version of the tracking page that doesn't reset after a short time. -// @version 2019.06.04.2 +// @version 2019.06.06.1 // @author tastytea // @copyright 2019, tastytea (https://tastytea.de/) // @license GPL-3.0-only @@ -15,9 +15,17 @@ // @inject-into content // ==/UserScript== -var re = new RegExp('dhl\.de/([^/]+)/.+idc=([0-9]+)'); -var result = re.exec(window.location.href); -var lang = result[1]; -var idc = result[2]; +const re = new RegExp('dhl\.de/([^/]+)/.+idc=([0-9]+)'); +const result = re.exec(window.location.href); -window.location.assign("https://nolp.dhl.de/nextt-online-public/" + lang + "/search?piececode=" + idc); +if (result.length < 3) +{ + console.error("Could not extract language or shipment number."); +} +else +{ + const lang = result[1]; + const idc = result[2]; + window.location.assign("https://nolp.dhl.de/nextt-online-public/" + lang + + "/search?piececode=" + idc); +}