Compare commits
4 Commits
68301c44d4
...
60ae28c9d3
Author | SHA1 | Date | |
---|---|---|---|
60ae28c9d3 | |||
c0f50dfe3e | |||
5c89d26691 | |||
efec9271c3 |
@ -32,6 +32,15 @@ function bahnParseTrainName(dirty_train_name) {
|
|||||||
return dirty_train_name;
|
return dirty_train_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns date string in format YYYYMMDDHHMM
|
||||||
|
*
|
||||||
|
* @param datetime Date object
|
||||||
|
*/
|
||||||
|
function datetimeToYYYYMMDDHHMM(datetime) {
|
||||||
|
return datetime.getFullYear().toString().padStart(4, '0') + "" + (datetime.getMonth()+1).toString().padStart(2, '0') + "" + datetime.getDate().toString().padStart(2, '0') + "" + datetime.getHours().toString().padStart(2, '0') + "" + datetime.getMinutes().toString().padStart(2, '0')
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns HTML a as DOM object
|
* Returns HTML a as DOM object
|
||||||
*
|
*
|
||||||
@ -193,6 +202,7 @@ var connection_result_observer = new MutationObserver((mutations) => {
|
|||||||
|
|
||||||
// Prodcut details
|
// Prodcut details
|
||||||
data[i]["products"][j]["product"] = null;
|
data[i]["products"][j]["product"] = null;
|
||||||
|
data[i]["products"][j]["train_id"] = null;
|
||||||
data[i]["products"][j]["train_number"] = null;
|
data[i]["products"][j]["train_number"] = null;
|
||||||
data[i]["products"][j]["line_name"] = null;
|
data[i]["products"][j]["line_name"] = null;
|
||||||
|
|
||||||
@ -201,14 +211,15 @@ var connection_result_observer = new MutationObserver((mutations) => {
|
|||||||
// Product name in format "STB 12 (23561)"
|
// Product name in format "STB 12 (23561)"
|
||||||
if(name_list.length == 3 && name_list[2].charAt(0) == '(' && name_list[2].charAt(name_list[2].length-1) == ')') {
|
if(name_list.length == 3 && name_list[2].charAt(0) == '(' && name_list[2].charAt(name_list[2].length-1) == ')') {
|
||||||
data[i]["products"][j]["product"] = name_list[0];
|
data[i]["products"][j]["product"] = name_list[0];
|
||||||
data[i]["products"][j]["train_number"] = name_list[0] + " " + name_list[2].substring(1, name_list[2].length-1);
|
data[i]["products"][j]["train_id"] = name_list[2].substring(1, name_list[2].length-1)
|
||||||
data[i]["products"][j]["line_name"] = name_list[0] + " " + name_list[1];
|
data[i]["products"][j]["line_name"] = name_list[0] + " " + name_list[1];
|
||||||
}
|
}
|
||||||
// Product name in format "ICE 234"
|
// Product name in format "ICE 234"
|
||||||
else {
|
else {
|
||||||
data[i]["products"][j]["product"] = name_list[0];
|
data[i]["products"][j]["product"] = name_list[0];
|
||||||
data[i]["products"][j]["train_number"] = name_list[0] + " " + name_list[1];
|
data[i]["products"][j]["train_id"] = name_list[1];
|
||||||
}
|
}
|
||||||
|
data[i]["products"][j]["train_number"] = data[i]["products"][j]["product"] + " " + data[i]["products"][j]["train_id"];
|
||||||
});
|
});
|
||||||
|
|
||||||
// Travel information
|
// Travel information
|
||||||
@ -236,10 +247,15 @@ var connection_result_observer = new MutationObserver((mutations) => {
|
|||||||
var bahn_insight_field = domCreateBahnInsightField();
|
var bahn_insight_field = domCreateBahnInsightField();
|
||||||
product.after(bahn_insight_field);
|
product.after(bahn_insight_field);
|
||||||
|
|
||||||
|
var departure_time = new Date(Date.parse(connection_result_date + " " + data[i]["from"]["time"]));
|
||||||
|
|
||||||
// Button linking to marudor.de
|
// Button linking to marudor.de
|
||||||
var marudor_button = domCreateButtonMarudor("/details/" + data[i]["products"][j]["train_number"]);
|
var marudor_button = domCreateButtonMarudor("/details/" + data[i]["products"][j]["train_number"] + "/" + departure_time.getTime());
|
||||||
bahn_insight_field.appendChild(marudor_button);
|
bahn_insight_field.appendChild(marudor_button);
|
||||||
|
|
||||||
|
var dbf_button = domCreateButtonDbf("/_wr/" + data[i]["products"][j]["train_id"] + "/" + datetimeToYYYYMMDDHHMM(departure_time));
|
||||||
|
bahn_insight_field.appendChild(dbf_button);
|
||||||
|
|
||||||
// Move linebreaks from link inner, after our 'bahn-insight' field
|
// Move linebreaks from link inner, after our 'bahn-insight' field
|
||||||
var linebreaks = product.querySelectorAll("br");
|
var linebreaks = product.querySelectorAll("br");
|
||||||
if(linebreaks.length != 0) {
|
if(linebreaks.length != 0) {
|
||||||
@ -282,6 +298,9 @@ var connection_result_observer = new MutationObserver((mutations) => {
|
|||||||
var target = document.getElementById('resultsOverview');
|
var target = document.getElementById('resultsOverview');
|
||||||
|
|
||||||
if(typeof target !== 'undefined') {
|
if(typeof target !== 'undefined') {
|
||||||
|
|
||||||
|
var connection_result_date = document.querySelector("html body div div div.resultContentHolder form div h2 span").innerText.replace(/(\d{2})\.(\d{2})\.(\d{2})/,'20$3-$2-$1');
|
||||||
|
|
||||||
connection_result_observer.observe(target, {
|
connection_result_observer.observe(target, {
|
||||||
subtree: true,
|
subtree: true,
|
||||||
childList: true
|
childList: true
|
||||||
|
Loading…
Reference in New Issue
Block a user