Version 0.1
This commit is contained in:
parent
c3bcedfa7d
commit
d462400ff4
46
js/reiseauskunft.js
Normal file
46
js/reiseauskunft.js
Normal file
@ -0,0 +1,46 @@
|
||||
function log(msg) {
|
||||
console.log("[Bahn Insight] " + msg);
|
||||
}
|
||||
|
||||
function getMediaURL(path) {
|
||||
path = "media/" + path;
|
||||
return chrome.runtime.getURL(path) || browser.runtime.getURL(path);
|
||||
}
|
||||
|
||||
|
||||
log("Bahn Insight loaded");
|
||||
|
||||
var target = document.getElementById('resultsOverview');
|
||||
|
||||
log("target");
|
||||
console.log(target);
|
||||
|
||||
var observer = new MutationObserver((mutations, observer) => {
|
||||
mutations.forEach((mutation) => {
|
||||
if (mutation.type === 'childList') {
|
||||
// Changed object
|
||||
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_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>';
|
||||
log("added to");
|
||||
console.log(product);
|
||||
});
|
||||
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>';
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
observer.observe(target, {
|
||||
subtree: true,
|
||||
childList: true
|
||||
});
|
24
manifest.json
Normal file
24
manifest.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
|
||||
"manifest_version": 2,
|
||||
"name": "Bahn Insight",
|
||||
"version": "0.1",
|
||||
|
||||
"description": "Extends the booking portal of bahn.de with linking to useful information.",
|
||||
"homepage_url": "https://git.clerie.de/clerie/bahn-insight/",
|
||||
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": [
|
||||
"*://reiseauskunft.bahn.de/*"
|
||||
],
|
||||
"js": [
|
||||
"js/reiseauskunft.js"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
||||
"web_accessible_resources": [
|
||||
"media/*"
|
||||
]
|
||||
}
|
10
media/marudor.svg
Normal file
10
media/marudor.svg
Normal file
@ -0,0 +1,10 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="910.683" height="911.613" viewBox="0 0 240.952 241.198">
|
||||
<style>
|
||||
@media (prefers-color-scheme: dark) {
|
||||
path {
|
||||
fill: #FFF
|
||||
}
|
||||
}
|
||||
</style>
|
||||
<path d="M156.283 14.31l-76.155.03a6.102 6.102 0 0 0-.247 12.197c7.448.304 14.872 2.649 21.144 6.675 3.91 2.511 7.182 5.608 9.07 9.101.5.927.916 1.91 1.243 2.925-8.798.583-18.387 1.932-27.009 3.806-5.011 1.088-10.013 2.373-14.69 4.477-4.679 2.103-9.011 5.062-12.391 8.92-3.38 3.858-5.735 8.575-6.962 13.555-1.228 4.98-1.322 10.16-1.322 15.29v72.291c0 4.87.066 9.793 1.25 14.517 1.183 4.724 3.513 9.198 6.957 12.642 3.444 3.444 7.918 5.774 12.642 6.957 3.2.802 6.492 1.086 9.797 1.19l-21.18 31.596h16.19l8.39-12.515 75.786.067 8.284 12.355h16.189l-21.134-31.528c3.038-.124 6.059-.427 9.003-1.164 4.724-1.184 9.199-3.514 12.642-6.957 3.444-3.444 5.774-7.918 6.958-12.642 1.183-4.724 1.25-9.647 1.25-14.517V91.286c0-5.117-.096-10.285-1.328-15.25-1.232-4.967-3.594-9.668-6.98-13.504-3.385-3.837-7.72-6.77-12.393-8.853-4.674-2.083-9.666-3.351-14.665-4.44-9.599-2.092-18.512-3.595-28.316-4.119a20.03 20.03 0 0 1 1.782-3.754c1.785-2.919 4.444-5.549 7.575-7.78a39.466 39.466 0 0 1 19.172-7.098 6.102 6.102 0 0 0 5.522-6.351c-.148-3.25-2.82-5.797-6.074-5.826zm-29.096 12.215c-2.77 2.395-5.38 5.062-7.415 8.356-2.037-3.255-4.554-6.019-7.34-8.35zm-20.641 47.72c8.312 0 14.465 1.246 18.458 3.74 7.254-2.494 13.895-3.74 19.926-3.74 8.639 0 15.118 1.473 19.437 4.42 4.32 2.946 6.479 8.197 6.479 15.751v39.324h-22.249V99.403c0-2.947-.855-5.062-2.567-6.346-1.71-1.36-4.237-2.04-7.579-2.04-1.467 0-2.77.188-3.912.566-1.14.378-1.833.794-2.078 1.247v40.91h-22.248V99.403c0-2.947-.856-5.062-2.567-6.346-1.712-1.36-4.238-2.04-7.58-2.04-1.466 0-2.77.188-3.911.566-1.141.378-1.834.794-2.078 1.247v40.91H71.829V81.044c2.852-1.435 8.027-2.908 15.524-4.42 7.498-1.586 13.896-2.379 19.193-2.379zM83.483 152.82c7.27 0 13.165 5.895 13.165 13.166 0 7.27-5.894 13.165-13.165 13.165-7.271 0-13.166-5.894-13.166-13.165 0-7.271 5.895-13.166 13.166-13.166zm74.655 0c7.272 0 13.166 5.895 13.166 13.166 0 7.27-5.895 13.165-13.166 13.165-7.27 0-13.165-5.894-13.165-13.165 0-7.271 5.894-13.166 13.165-13.166zm-62.375 46.122H146l5.975 8.913-62.15-.054z" fill="#333"/>
|
||||
</svg>
|
After Width: | Height: | Size: 2.2 KiB |
Loading…
Reference in New Issue
Block a user