Link Opener

Öffnet Links im Browser und ermöglicht Whitelisting

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

Advertisement:

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