Add Volcano Plot Link

Adds a link to the volcano plot page on the current page

Από την 10/09/2024. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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.

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

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

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.

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

// ==UserScript==
// @name         Add Volcano Plot Link
// @namespace     https://greasyfork.org/en/users/1291562-zarotrox
// @version      0.1
// @description  Adds a link to the volcano plot page on the current page
// @author       Zarotrox
// @match        https://www.grundos.cafe/dome/*
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';

    // Function to add the link
    function addLink() {
        // Select the navigation bar using its class and aria-label
        var nav = document.querySelector('nav.center.margin-1[aria-label="Battledome Links"]');

        if (nav) {
            // Check if the link already exists to prevent duplicates
            if (!nav.querySelector('a[href="https://www.grundos.cafe/dome/1p/select/?plot=volcano"]')) {
                // Create the new link element
                var newLink = document.createElement('a');
                newLink.href = 'https://www.grundos.cafe/dome/1p/select/?plot=volcano'; // URL of the page you want to link to
                newLink.textContent = 'Volcano Plot'; // Text for the link
                newLink.style.marginLeft = '10px'; // Add margin to separate from other links
                newLink.style.textDecoration = 'none'; // Optional: remove underline

                // Append the new link to the navigation bar
                nav.appendChild(newLink);
            }
        } else {
            console.log('Navigation bar not found.');
        }
    }

    // Run the function after a slight delay to ensure content is loaded
    setTimeout(addLink, 3000); // Adjust delay as needed

    // Optional: Observe changes to the document and try adding the link again if necessary
    const observer = new MutationObserver((mutationsList) => {
        for (let mutation of mutationsList) {
            if (mutation.type === 'childList') {
                addLink();
            }
        }
    });

    // Start observing the document body
    observer.observe(document.body, { childList: true, subtree: true });

})();