Onion Link Opener

Open .onion links in Tor Browser

// ==UserScript==
// @name         Onion Link Opener
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Open .onion links in Tor Browser
// @author       Your Name
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to check if the link is a .onion link
    function isOnionLink(url) {
        return url.includes('.onion');
    }

    // Get all anchor tags on the page
    const links = document.getElementsByTagName('a');

    // Loop through the links and modify .onion links
    for (let link of links) {
        if (isOnionLink(link.href)) {
            // Change the link to open in Tor Browser
            link.href = 'tor:' + link.href;
        }
    }
})();