1
0

Cleaning up code

This commit is contained in:
clerie 2020-09-16 12:47:22 +02:00
parent d462400ff4
commit a9d7a3bcc0

View File

@ -7,18 +7,11 @@ function getMediaURL(path) {
return chrome.runtime.getURL(path) || browser.runtime.getURL(path); return chrome.runtime.getURL(path) || browser.runtime.getURL(path);
} }
log("Bahn Insight loaded");
var target = document.getElementById('resultsOverview'); var target = document.getElementById('resultsOverview');
log("target");
console.log(target);
var observer = new MutationObserver((mutations, observer) => { var observer = new MutationObserver((mutations, observer) => {
mutations.forEach((mutation) => { mutations.forEach((mutation) => {
if (mutation.type === 'childList') { if (mutation.type === 'childList') {
// Changed object
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");
@ -26,8 +19,6 @@ var observer = new MutationObserver((mutations, observer) => {
products.forEach((product) => { products.forEach((product) => {
var train_name = product.querySelector("span a").innerText; var train_name = product.querySelector("span a").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>'; 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>';
log("added to");
console.log(product);
}); });
var stations = timetable.querySelectorAll("tr td.station"); var stations = timetable.querySelectorAll("tr td.station");
stations.forEach((station) => { stations.forEach((station) => {