// ==UserScript==
// @name ownNavbar
// @version 1.0
// @description Make your own navbar
// @author Ron31
// @match https://www.leitstellenspiel.de/
// @grant none
// ==/UserScript==
(function () {
'use strict';
const standardElementSelectors = ['']; /*Hier müsste man für NL und UK/US/AU anpassen*/
const showStandardElements = ["#menu_profile", "#menu_alliance", "#menue_news"]; /*Hier alle selectors (von oben) rein, die nicht ausgeblendet werden sollen*/
const ownElements = [
{
url: '#', //let url # when using childrens for a dropdown
imgSrc: 'https://img.icons8.com/fluent/48/000000/home.png',
text: '',
appendLeft: true,
childrens: [
{
url: 'https://feuerwehr-in-bayern.de/',
openLightbox: true,
imgSrc: '',
text: 'Startseite',
},
{
url: 'https://feuerwehr-in-bayern.de/vge-termine2020/',
openLightbox: true,
imgSrc: '',
text: 'VGE Termine 2020',
},
{
url: 'https://feuerwehr-in-bayern.de/event-termine-2020/',
openLightbox: true,
imgSrc: '',
text: 'Event Termine 2020',
}
],
},
{
url: '',
imgSrc: 'https://img.icons8.com/fluent/48/000000/high-priority.png',
text: '',
appendLeft: true,
childrens: [
{
url: 'https://www.leitstellenspiel.de/buildings/4175030',
openLightbox: true,
imgSrc: '',
text: 'ALST01 Bereitschaftspolizei',
},
{
url: 'https://www.leitstellenspiel.de/buildings/4366144',
openLightbox: true,
imgSrc: '',
text: 'ALST02 Polizei',
},
{
url: 'https://www.leitstellenspiel.de/buildings/4366150',
openLightbox: true,
imgSrc: '',
text: 'ALST03 Rettungsdienst',
},
{
url: 'https://www.leitstellenspiel.de/buildings/7624820',
openLightbox: true,
imgSrc: '',
text: 'ALST04 Feuerwehr - (Personal fehlt)',
},
{
url: 'https://www.leitstellenspiel.de/buildings/3771390',
openLightbox: true,
imgSrc: '',
text: 'ALST05 Schnelleinsatzgruppe',
},
{
url: 'https://www.leitstellenspiel.de/buildings/2596262',
openLightbox: true,
imgSrc: '',
text: 'ALST06 Klinik',
},
{
url: 'https://www.leitstellenspiel.de/buildings/7797679',
openLightbox: true,
imgSrc: '',
text: 'ALST07 Technisches Hilfswerk',
},
{
url: 'https://www.leitstellenspiel.de/buildings/4366159',
openLightbox: true,
imgSrc: '',
text: 'ALST08 Wasserrettung',
},
{
url: 'https://www.leitstellenspiel.de/buildings/7767907',
openLightbox: true,
imgSrc: '',
text: 'ALST09 Flughafen',
},
{
url: 'https://www.leitstellenspiel.de/buildings/7797755',
openLightbox: true,
imgSrc: '',
text: 'ALST10 Werksfeuerwehr',
}
],
},
{
url: '',
imgSrc: 'https://img.icons8.com/fluent/48/000000/medium-priority.png',
text: '',
appendLeft: true,
childrens: [
{
url: 'https://www.leitstellenspiel.de/buildings/7620531',
openLightbox: true,
imgSrc: '',
text: 'BLST01 Feuerwehr - (Fz + Ausbildungen fehlen)',
}
],
},
{
url: '',
imgSrc: 'https://img.icons8.com/fluent/48/000000/low-priority.png',
text: '',
appendLeft: true,
childrens: [
{
url: 'https://www.leitstellenspiel.de/buildings/7275233',
openLightbox: true,
imgSrc: '',
text: 'CLST01 Rettungshundestaffel',
},
{
url: 'https://www.leitstellenspiel.de/buildings/7029605',
openLightbox: true,
imgSrc: '',
text: 'CLST02 Werksfeuerwehr',
},
{
url: 'https://www.leitstellenspiel.de/buildings/7030429',
openLightbox: true,
imgSrc: '',
text: 'CLST03 München Werksfeuerwehr',
},
{
url: 'https://www.leitstellenspiel.de/buildings/2267475',
openLightbox: true,
imgSrc: '',
text: 'CLST04 Feuerwehr',
},
{
url: 'https://www.leitstellenspiel.de/buildings/2994459',
openLightbox: true,
imgSrc: '',
text: 'CLST05 BePo Verbandseinsätze',
},
{
url: 'https://www.leitstellenspiel.de/buildings/2687092',
openLightbox: true,
imgSrc: '',
text: 'CLST06 Polizei',
},
{
url: 'https://www.leitstellenspiel.de/buildings/2686831',
openLightbox: true,
imgSrc: '',
text: 'CLST07 Polizeihubschrauber',
},
{
url: 'https://www.leitstellenspiel.de/buildings/2687099',
openLightbox: true,
imgSrc: '',
text: 'CLST08 Rettungsdienst',
},
{
url: 'https://www.leitstellenspiel.de/buildings/2524210',
openLightbox: true,
imgSrc: '',
text: 'CLST09 Schnelleinsatzgruppe',
},
{
url: 'https://www.leitstellenspiel.de/buildings/2687077',
openLightbox: true,
imgSrc: '',
text: 'CLST10 Klinik',
},
{
url: 'https://www.leitstellenspiel.de/buildings/6167263',
openLightbox: true,
imgSrc: '',
text: 'CLST11 Verbands - Klinik',
},
{
url: 'https://www.leitstellenspiel.de/buildings/6264552',
openLightbox: true,
imgSrc: '',
text: 'CLST12 Rettungshubschruaber',
},
{
url: 'https://www.leitstellenspiel.de/buildings/2687119',
openLightbox: true,
imgSrc: '',
text: 'CLST13 Technisches Hilfswerk 1 bis 3',
},
{
url: 'https://www.leitstellenspiel.de/buildings/2687130',
openLightbox: true,
imgSrc: '',
text: 'CLST14 Wasserrettung',
},
{
url: 'https://www.leitstellenspiel.de/buildings/7767906',
openLightbox: true,
imgSrc: '',
text: 'CLST15 Flughafen',
},
{
url: 'https://www.leitstellenspiel.de/buildings/7498975',
openLightbox: true,
imgSrc: '',
text: 'CLST16 Technisches Hilfswerk 4 & 5',
},
{
url: 'https://www.leitstellenspiel.de/buildings/7797739',
openLightbox: true,
imgSrc: '',
text: 'CLST17 Bereitschaftspolizei',
},
]
},
{
url: '',
imgSrc: 'https://img.icons8.com/fluent/48/000000/student-male.png',
text: '',
appendLeft: true,
childrens: [
{
url: 'https://www.leitstellenspiel.de/buildings/2683603',
openLightbox: true,
imgSrc: '',
text: 'Feuerwehr',
},
{
url: 'https://www.leitstellenspiel.de/buildings/4270261',
openLightbox: true,
imgSrc: '',
text: 'Rettungsdienst',
},
{
url: 'https://www.leitstellenspiel.de/buildings/4270242',
openLightbox: true,
imgSrc: '',
text: 'Polizei',
},
{
url: 'https://www.leitstellenspiel.de/buildings/4270249',
openLightbox: true,
imgSrc: '',
text: 'Technisches Hilfswerk',
},
]
},
];
let leftObject = document.querySelector('#navbar-main-collapse .navbar-right #news_li');
standardElementSelectors.forEach(selector => !showStandardElements.includes(selector) && document.querySelector(`#navbar-main-collapse .navbar-right li a${selector}`)?.parentElement.classList.add('hidden'));
ownElements.forEach(ownElement => {
const liElement = document.createElement('li');
const aElement = document.createElement('a');
aElement.setAttribute('role', 'button');
aElement.setAttribute('href', ownElement.url);
if(ownElement.imgSrc) {
aElement.innerHTML = `<img alt="${ownElement.text}" class="navbar-icon" src="${ownElement.imgSrc}" title="${ownElement.text}"><span class="visible-xs">${ownElement.text}</span>`
} else {
aElement.innerText = ownElement.text;
}
let ulElement;
if(ownElement.childrens[0]) {
const bElement = document.createElement('b');
bElement.classList.add('caret');
aElement.appendChild(bElement);
liElement.classList.add('dropdown');
aElement.classList.add('dropdown-toogle');
aElement.setAttribute('data-toggle', 'dropdown');
ulElement = document.createElement('ul');
ulElement.classList.add('dropdown-menu');
ulElement.setAttribute('role', 'menu');
ownElement.childrens.forEach((ownChildElement) => {
const liChildElement = document.createElement('li');
liChildElement.setAttribute('role', 'presentation');
const aChildElement = document.createElement('a');
ownChildElement.openLightbox && aChildElement.classList.add('lightbox-open');
aChildElement.setAttribute('href', ownChildElement.url);
if(ownChildElement.imgSrc) {
aChildElement.innerHTML = `<img class="icon" src="${ownChildElement.imgSrc}" width="24" height="24"> ${ownChildElement.text}`
} else {
aChildElement.innerText = ownChildElement.text;
}
liChildElement.appendChild(aChildElement);
ulElement.appendChild(liChildElement);
});
}
liElement.appendChild(aElement);
ulElement && liElement.appendChild(ulElement);
if(ownElement.appendLeft) {
leftObject.parentNode.insertBefore(liElement, leftObject);
leftObject = liElement;
} else {
document.querySelector('#navbar-main-collapse .navbar-right').appendChild(liElement);
}
})
})();