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) => {
|
||||
mutations.forEach((mutation) => {
|
||||
if (mutation.type === 'childList') {
|
||||
var target = mutation.target;
|
||||
if (target.tagName === 'TD') {
|
||||
var timetable = target.querySelector("td div.detailContainer table.result tbody");
|
||||
var products = timetable.querySelectorAll("tr.first td.products");
|
||||
products.forEach((product) => {
|
||||
var train_names = product.querySelectorAll("span a");
|
||||
train_names.forEach((train) => {
|
||||
var train_name = bahnParseTrainName(train.innerText);
|
||||
if(typeof train_name !== 'undefined') {
|
||||
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>';
|
||||
}
|
||||
});
|
||||
});
|
||||
var stations = timetable.querySelectorAll("tr td.station");
|
||||
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>';
|
||||
});
|
||||
mutations.forEach((mutation) => {
|
||||
if (mutation.type === 'childList') {
|
||||
var target = mutation.target;
|
||||
if (target.tagName === 'TD') {
|
||||
var timetable = target.querySelector("td div.detailContainer table.result tbody");
|
||||
|
||||
var trains = timetable.querySelectorAll("tr.first td.products");
|
||||
trains.forEach((train) => {
|
||||
var train_names = train.querySelectorAll("span a");
|
||||
train_names.forEach((train_name) => {
|
||||
train_name = bahnParseTrainName(train_name.innerText);
|
||||
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;
|
||||
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