Rule34 Wiki Tag Linker

Turns the "Now Viewing: tag_name" text on Rule34 wiki entries into a clickable link to the tag's image posts.

Tendrás que instalar una extensión para tu navegador como Tampermonkey, Greasemonkey o Violentmonkey si quieres utilizar este script.

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

Tendrás que instalar una extensión como Tampermonkey o Violentmonkey para instalar este script.

Necesitarás instalar una extensión como Tampermonkey o Userscripts para instalar este script.

Tendrás que instalar una extensión como Tampermonkey antes de poder instalar este script.

Necesitarás instalar una extensión para administrar scripts de usuario si quieres instalar este script.

(Ya tengo un administrador de scripts de usuario, déjame instalarlo)

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Tendrás que instalar una extensión como Stylus antes de poder instalar este script.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

Para poder instalar esto tendrás que instalar primero una extensión de estilos de usuario.

(Ya tengo un administrador de estilos de usuario, déjame instalarlo)

// ==UserScript==
// @name         Rule34 Wiki Tag Linker
// @namespace    http://tampermonkey.net
// @version      1.2
// @description  Turns the "Now Viewing: tag_name" text on Rule34 wiki entries into a clickable link to the tag's image posts.
// @author       uNderdog_101
// @license      MIT
// @match        https://rule34.xxx/index.php?page=wiki&s=view&*
// @grant        none
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';

    // 1. Locate the header element. Rule34 wiki view headers typically use an <h2> element.
    const headers = document.querySelectorAll('h2');

    // 2. Loop through all <h2> elements on the page to find the one containing the tag name text.
    for (const h2 of headers) {

        // Check if the text inside the header starts with "Now Viewing:"
        if (h2.textContent.includes('Now Viewing:')) {

            // 3. Extract the clean tag name.
            // .replace() removes the "Now Viewing:" text and .trim() removes any accidental leading/trailing spaces.
            const tagName = h2.textContent.replace('Now Viewing:', '').trim();

            // Fail-safe: Ensure we actually extracted a tag string before creating elements.
            if (tagName.length > 0) {

                // 4. Construct the URL pointing to the image posts for this specific tag.
                // FIXED: Fully restored the correct path and query parameters you debugged.
                const postUrl = 'https://rule34.xxx/index.php?page=post&s=list&tags=' + encodeURIComponent(tagName);

                // 5. Create a new anchor (<a>) element to serve as our link.
                const tagLink = document.createElement('a');
                tagLink.href = postUrl;
                tagLink.textContent = tagName;
                tagLink.target = '_blank'; // Instructs the browser to open the link in a new tab.
                tagLink.rel = 'noopener noreferrer'; // Security best practice when opening links in new tabs.

                // 6. Style the new link to ensure it looks distinct and matches a standard hyperlink look.
                tagLink.style.color = '#007bff';
                tagLink.style.textDecoration = 'underline';

                // 7. Rebuild the header's contents safely.
                // Clear the existing text so we can split it cleanly into plain text and our new clickable link.
                h2.textContent = 'Now Viewing: ';

                // Append the link element right next to the "Now Viewing: " prefix text.
                h2.appendChild(tagLink);
            }

            // Exit the loop early since we found and modified the correct heading element.
            break;
        }
    }
})();