Compare commits
4 Commits
7df84bca5c
...
0ec0d9164e
Author | SHA1 | Date | |
---|---|---|---|
0ec0d9164e | |||
678d00a57b | |||
7b3e750513 | |||
a216984bb4 |
@ -151,6 +151,10 @@ var connection_result_observer = new MutationObserver((mutations) => {
|
||||
var relations = timetable.querySelectorAll("tr.first");
|
||||
relations.forEach((relation, i) => {
|
||||
var relationend = relation.nextElementSibling;
|
||||
while(relationend.querySelector("td.station") == null) {
|
||||
relationend = relationend.nextElementSibling;
|
||||
}
|
||||
|
||||
data[i] = {};
|
||||
data[i]["from"] = {}
|
||||
data[i]["to"] = {}
|
||||
@ -201,25 +205,25 @@ var connection_result_observer = new MutationObserver((mutations) => {
|
||||
data[i]["products"][j] = {};
|
||||
|
||||
// Prodcut details
|
||||
data[i]["products"][j]["product"] = null;
|
||||
data[i]["products"][j]["train_id"] = null;
|
||||
data[i]["products"][j]["type"] = null;
|
||||
data[i]["products"][j]["train_number"] = null;
|
||||
data[i]["products"][j]["train_name"] = null;
|
||||
data[i]["products"][j]["line_name"] = null;
|
||||
|
||||
var name_list = train.innerText.trim().replace(/ +/g, ' ').split(" ");
|
||||
|
||||
// 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) == ')') {
|
||||
data[i]["products"][j]["product"] = name_list[0];
|
||||
data[i]["products"][j]["train_id"] = name_list[2].substring(1, name_list[2].length-1)
|
||||
data[i]["products"][j]["type"] = name_list[0];
|
||||
data[i]["products"][j]["train_number"] = name_list[2].substring(1, name_list[2].length-1)
|
||||
data[i]["products"][j]["line_name"] = name_list[0] + " " + name_list[1];
|
||||
}
|
||||
// Product name in format "ICE 234"
|
||||
else {
|
||||
data[i]["products"][j]["product"] = name_list[0];
|
||||
data[i]["products"][j]["train_id"] = name_list[1];
|
||||
data[i]["products"][j]["type"] = name_list[0];
|
||||
data[i]["products"][j]["train_number"] = name_list[1];
|
||||
}
|
||||
data[i]["products"][j]["train_number"] = data[i]["products"][j]["product"] + " " + data[i]["products"][j]["train_id"];
|
||||
data[i]["products"][j]["train_name"] = data[i]["products"][j]["type"] + " " + data[i]["products"][j]["train_number"];
|
||||
});
|
||||
|
||||
// Travel information
|
||||
@ -240,6 +244,9 @@ var connection_result_observer = new MutationObserver((mutations) => {
|
||||
var relations = timetable.querySelectorAll("tr.first");
|
||||
relations.forEach((relation, i) => {
|
||||
var relationend = relation.nextElementSibling;
|
||||
while(relationend.querySelector("td.station") == null) {
|
||||
relationend = relationend.nextElementSibling;
|
||||
}
|
||||
|
||||
var products = relation.querySelectorAll("td.products span a");
|
||||
products.forEach((product, j) => {
|
||||
@ -250,10 +257,10 @@ var connection_result_observer = new MutationObserver((mutations) => {
|
||||
var departure_time = new Date(Date.parse(connection_result_date + " " + data[i]["from"]["time"]));
|
||||
|
||||
// Button linking to marudor.de
|
||||
var marudor_button = domCreateButtonMarudor("/details/" + data[i]["products"][j]["train_number"] + "/" + departure_time.getTime());
|
||||
var marudor_button = domCreateButtonMarudor("/details/" + data[i]["products"][j]["train_name"] + "/" + departure_time.getTime());
|
||||
bahn_insight_field.appendChild(marudor_button);
|
||||
|
||||
var dbf_button = domCreateButtonDbf("/_wr/" + data[i]["products"][j]["train_id"] + "/" + datetimeToYYYYMMDDHHMM(departure_time));
|
||||
var dbf_button = domCreateButtonDbf("/_wr/" + data[i]["products"][j]["train_number"] + "/" + datetimeToYYYYMMDDHHMM(departure_time));
|
||||
bahn_insight_field.appendChild(dbf_button);
|
||||
|
||||
// Move linebreaks from link inner, after our 'bahn-insight' field
|
||||
@ -266,6 +273,7 @@ var connection_result_observer = new MutationObserver((mutations) => {
|
||||
}
|
||||
});
|
||||
|
||||
// Linking to station
|
||||
var from = relation.querySelector("td.station");
|
||||
var bahn_insight_field = domCreateBahnInsightField();
|
||||
from.appendChild(bahn_insight_field);
|
||||
@ -276,6 +284,7 @@ var connection_result_observer = new MutationObserver((mutations) => {
|
||||
var dbf_button = domCreateButtonDbf("/" + data[i]["from"]["station"]);
|
||||
bahn_insight_field.appendChild(dbf_button);
|
||||
|
||||
// Linking to station
|
||||
var to = relationend.querySelector("td.station");
|
||||
var bahn_insight_field = domCreateBahnInsightField();
|
||||
to.appendChild(bahn_insight_field);
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
"manifest_version": 2,
|
||||
"name": "Bahn Insight",
|
||||
"version": "0.6",
|
||||
"version": "0.7",
|
||||
|
||||
"description": "Extends the booking portal of bahn.de with linking to useful information.",
|
||||
"homepage_url": "https://git.clerie.de/clerie/bahn-insight/",
|
||||
|
Loading…
Reference in New Issue
Block a user