Japanese ASMR Tags Tooltip on hover

Adds a floating tooltip with the ASMR's tags when you hover over the thumbnail.

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

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         Japanese ASMR Tags Tooltip on hover
// @namespace    https://www.swcombine.com/
// @version      1.1
// @description  Adds a floating tooltip with the ASMR's tags when you hover over the thumbnail.
// @author       code-syl
// @match        https://japaneseasmr.com/*
// @icon         https://external-content.duckduckgo.com/ip3/japaneseasmr.com.ico
// @grant        none
// @require      https://greasyfork.org/scripts/383527-wait-for-key-elements/code/Wait_for_key_elements.js?version=701631
// @license      MIT
// ==/UserScript==
/* @require      https://code.jquery.com/jquery-3.6.3.min.js /* <-- enable when not using waitForKeyElements.js */

(function() {
    'use strict';

    const styles = `
        .op-square:hover .syl-tooltip {
            display: flex;
        }

        .syl-tooltip {
            display: none;
            flex-direction: row;
            justify-content: center;
            gap: .5em;
            flex-wrap: wrap;
            align-self: center;

            background: #262626;
            padding: .7em !important;
            max-width: 100%;

            z-index: 1000;
        }
    `;

    /* add custom styles to the page */
    let styleSheet = document.createElement('style');
    styleSheet.innerText = styles;
    document.head.appendChild(styleSheet);

    const addTagsOnMainThumbnails = (mainThumbnail) => {
        const $anchor = mainThumbnail.find('a')[0];
        const $url = $anchor.href;

        let $tooltip = $("<div>", {"class": "syl-tooltip post-meta post-tags"});
        $.get($url, (data) => {
            const $tags = $(data).find('a[rel=tag]').toArray();
            $tags.forEach(($tag) => {
                $tooltip.append($tag);
            });
        });

        $anchor.after($tooltip[0]);
    }

    waitForKeyElements('.site-archive-post .op-square', addTagsOnMainThumbnails);
})();