forked from tastytea/userscripts
Added error handling.
This commit is contained in:
parent
bf9f303204
commit
4a818ef80b
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue