Refactor code and renaming vars
This commit is contained in:
parent
83feb9af10
commit
d3d1aeecd8
@ -33,30 +33,32 @@ function bahnParseTrainName(dirty_train_name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var connection_result_observer = new MutationObserver((mutations) => {
|
var connection_result_observer = new MutationObserver((mutations) => {
|
||||||
mutations.forEach((mutation) => {
|
mutations.forEach((mutation) => {
|
||||||
if (mutation.type === 'childList') {
|
if (mutation.type === 'childList') {
|
||||||
var target = mutation.target;
|
var target = mutation.target;
|
||||||
if (target.tagName === 'TD') {
|
if (target.tagName === 'TD') {
|
||||||
var timetable = target.querySelector("td div.detailContainer table.result tbody");
|
var timetable = target.querySelector("td div.detailContainer table.result tbody");
|
||||||
var products = timetable.querySelectorAll("tr.first td.products");
|
|
||||||
products.forEach((product) => {
|
var trains = timetable.querySelectorAll("tr.first td.products");
|
||||||
var train_names = product.querySelectorAll("span a");
|
trains.forEach((train) => {
|
||||||
train_names.forEach((train) => {
|
var train_names = train.querySelectorAll("span a");
|
||||||
var train_name = bahnParseTrainName(train.innerText);
|
train_names.forEach((train_name) => {
|
||||||
if(typeof train_name !== 'undefined') {
|
train_name = bahnParseTrainName(train_name.innerText);
|
||||||
product.innerHTML = product.innerHTML + ' <a href="https://marudor.de/details/' + train_name + '" target="_blank"><img src="' + getMediaURL("marudor.svg") + '" style="height: 2em; vertical-align:middle;"></a>';
|
if(typeof train_name !== 'undefined') {
|
||||||
}
|
train.innerHTML = train.innerHTML + ' <a href="https://marudor.de/details/' + train_name + '" target="_blank"><img src="' + getMediaURL("marudor.svg") + '" style="height: 2em; vertical-align:middle;"></a>';
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
var stations = timetable.querySelectorAll("tr td.station");
|
});
|
||||||
stations.forEach((station) => {
|
|
||||||
var station_name = station.innerText;
|
var stations = timetable.querySelectorAll("tr td.station");
|
||||||
station.innerHTML = station.innerHTML + ' <a href="https://marudor.de/' + station_name + '" target="_blank"><img src="' + getMediaURL("marudor.svg") + '" style="height: 2em; vertical-align:middle;"></a>';
|
stations.forEach((station) => {
|
||||||
});
|
var station_name = station.innerText;
|
||||||
|
station.innerHTML = station.innerHTML + ' <a href="https://marudor.de/' + station_name + '" target="_blank"><img src="' + getMediaURL("marudor.svg") + '" style="height: 2em; vertical-align:middle;"></a>';
|
||||||
|
});
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user