Rule34 Image Opener

Opens images in a new background tab when middle-clicked on rule34.xxx

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Rule34 Image Opener
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Opens images in a new background tab when middle-clicked on rule34.xxx
// @author       MathaNoshto
// @match        https://rule34.xxx/*
// @grant        GM_openInTab
// ==/UserScript==

(function() {
    'use strict';

    // Function to handle middle mouse click on images
    function handleImageMiddleClick(event) {
        // Check if it's a middle mouse button click (button 1)
        if (event.button !== 1) return;

        const image = event.target;

        // Check if the clicked element is an image
        if (image.tagName === 'IMG') {
            // Prevent default middle-click behavior
            event.preventDefault();

            // Get the highest resolution image URL
            let imageUrl = '';

            // If it's a thumbnail, try to get the full image URL
            if (image.parentElement && image.parentElement.tagName === 'A') {
                imageUrl = image.parentElement.href;
            } else {
                // If it's already a full image, use its source
                imageUrl = image.src;
            }

            // Open the image in a new background tab using GM_openInTab
            if (imageUrl) {
                GM_openInTab(imageUrl, {
                    active: false,      // This ensures the tab opens in the background
                    insert: true,       // This opens the tab next to the current one
                    setParent: true     // This sets the current tab as the parent
                });
            }
        }
    }

    // Add mousedown event listener to the document
    document.addEventListener('mousedown', handleImageMiddleClick);

    // Log that the script is loaded
    console.log('Rule34 Image Opener script loaded!');
})();