Japanese ASMR Tags Tooltip on hover

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

Versione datata 16/01/2023. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Japanese ASMR Tags Tooltip on hover
// @namespace    https://www.swcombine.com/
// @version      1.0
// @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://code.jquery.com/jquery-3.6.3.min.js
// @license      MIT
// ==/UserScript==

(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;
            background: #262626;
            padding: .7em !important;
            max-width: 100%;
            align-self: center;
            z-index: 1000;
        }
    `;

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

    /**
     * Inserts a node after another node
     * @param {Node} referenceNode A node to insert the new node after
     * @param {Node} newNode The node to insert
     */
    function insertAfter(referenceNode, newNode) {
        referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
    }

    const onLoad = () => {
        const mainThumbnails = document.querySelectorAll('.site-archive-post .op-square');
        mainThumbnails.forEach((thumbnail) => {
            const link = thumbnail.querySelector('a');
            let tooltip = document.createElement('div');
            tooltip.classList.add('syl-tooltip', 'post-meta', 'post-tags');
            insertAfter(link, tooltip);

            $.get(link.href, (data) => {
                const tags = $(data).find('a[rel=tag]').toArray();
                tags.forEach((tag) => {
                    tooltip.appendChild(tag);
                });
            });
        });
    };

    window.addEventListener('load', onLoad, false);
})();