Vertretungsplan Opener

Öffnet Vertretungsplan PDFs direkt im Browser in einem neuen Tab

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Vertretungsplan Opener
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Öffnet Vertretungsplan PDFs direkt im Browser in einem neuen Tab
// @author       You
// @match        https://www.mittelschule-ossling.de/vertretungsplan.html
// @match        https://www.mittelschule-ossling.de/stundenplan.html
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    window.addEventListener('load', function() {
        var pdfLinks = document.querySelectorAll('.ce_downloads ul a[href$=".pdf"]');
        pdfLinks.forEach(function(link) {
            link.addEventListener('click', function(event) {
                event.preventDefault();
                var fileNameWithSize = link.textContent.trim();
                var fileName = fileNameWithSize.replace(/\s*\(\d+,\d+\s*KiB\)\s*$/, '');
                var newLink = document.createElement('a');


                if (window.location.href === 'https://www.mittelschule-ossling.de/stundenplan.html') {
                  newLink.href = 'https://www.mittelschule-ossling.de/files/pdf/stundenplan/' + fileName;
                } else if (window.location.href === 'https://www.mittelschule-ossling.de/vertretungsplan.html') {
                  newLink.href = 'https://www.mittelschule-ossling.de/files/pdf/vertretungsplan/' + fileName;
                }

                newLink.target = '_blank';
                newLink.textContent = 'Öffne ' + fileName + ' im neuen Tab';
                document.body.appendChild(newLink);
                newLink.click();
                document.body.removeChild(newLink);
            });
        });
    });
})();