Link Opener

Öffnet Links im Browser und ermöglicht Whitelisting

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         Link Opener
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Öffnet Links im Browser und ermöglicht Whitelisting
// @author       You
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Whitelist für bestimmte Links
    var whitelist = [
        'https://example.com', // Beispiel-URL für Whitelisting
        'https://google.com',  // Beispiel-URL für Whitelisting
        // Fügen Sie hier weitere URLs hinzu, die Sie in der App öffnen möchten
    ];

    // Funktion, um Links zu modifizieren
    function modifyLinks() {
        // Alle Links auf der Seite finden
        var links = document.querySelectorAll('a');

        // Jeden Link durchgehen
        links.forEach(function(link) {
            // Prüfen, ob der Link in der Whitelist ist
            if (whitelist.includes(link.href)) {
                // Link bleibt unverändert, falls er in der Whitelist ist
                return;
            }

            // Prüfen, ob der Link eine App öffnen würde
            if (link.href.startsWith('https://') || link.href.startsWith('http://')) {
                // Den Link so ändern, dass er im Browser geöffnet wird
                link.target = '_self';
                // Optional: Den Link auf eine bestimmte Weise umleiten
                // link.href = link.href + '?browser=true';
            }
        });
    }

    // Funktion ausführen, wenn die Seite geladen ist
    document.addEventListener('DOMContentLoaded', function() {
        modifyLinks();
    });

    // Optional: Beim Klicken auf einen Link prüfen
    document.addEventListener('click', function(event) {
        if (event.target.tagName === 'A') {
            // Prüfen, ob der Link in der Whitelist ist
            if (whitelist.includes(event.target.href)) {
                return;
            }
            event.preventDefault();
            window.location.href = event.target.href;
        }
    });
})();