Vertretungsplan Opener

Öffnet Vertretungsplan PDFs direkt im Browser in einem neuen Tab

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==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);
            });
        });
    });
})();