diff --git a/js/reiseauskunft.js b/js/reiseauskunft.js index cbe0109..99fb400 100644 --- a/js/reiseauskunft.js +++ b/js/reiseauskunft.js @@ -6,12 +6,15 @@ function getMediaURL(path) { path = "media/" + path; return chrome.runtime.getURL(path) || browser.runtime.getURL(path); } + /** * Return train name in format "PRODUCT TRAIN_NUMER" * i.e. "ICE 112", "RE 12734" * Sometimes train name is in format "PRODUCT LINE_NUMER (TRAIN_NUMER)" * i.e. "STB 12 (62371)" - * this will be cleaned up + * Sometimes 'trains' are not trains or we can't find an unique id for them + * i.e. busses, ferrys, trams + * they will also be cleaned up and returned as undefined, because we can't link to them correctly */ function bahnParseTrainName(dirty_train_name) { var name_list = dirty_train_name.split(" "); @@ -21,6 +24,11 @@ function bahnParseTrainName(dirty_train_name) { return name_list[0] + " " + name_list[2].substring(1, name_list[2].length-1); } + // Exclude linking to specific products + if(["bus", "fäh", "str"].indexOf(name_list[0].toLowerCase()) !== -1) { + return undefined; + } + return dirty_train_name; } @@ -33,7 +41,9 @@ var observer = new MutationObserver((mutations, observer) => { var products = timetable.querySelectorAll("tr.first td.products"); products.forEach((product) => { var train_name = bahnParseTrainName(product.querySelector("span a").innerText); - product.innerHTML = product.innerHTML + ' '; + if(typeof train_name !== 'undefined') { + product.innerHTML = product.innerHTML + ' '; + } }); var stations = timetable.querySelectorAll("tr td.station"); stations.forEach((station) => {