Open Image on Double-Click

Opens the image in a new tab on double-clicking full image

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo 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        Open Image on Double-Click
// @namespace   net.tealpink
// @version     1.0.0
// @description Opens the image in a new tab on double-clicking full image
// @author      tealpink
// @license     MIT
// @match       https://onlyfans.com/*
// @grant       none
// @run-at      document-idle
// @noframes
// ==/UserScript==

(function () {
    'use strict';

    // Add a double-click listener to the document body
    document.body.addEventListener('dblclick', function (e) {
        const clickedElement = e.target;

        // Check if the clicked element is a <div> containing an <img>
        if (clickedElement.tagName === 'DIV' && clickedElement.querySelector('img')) {
            const imgElement = clickedElement.querySelector('img');
            openImageInNewTab(imgElement);
        }
    });

    // Function to open an image in a new tab
    function openImageInNewTab(imgElement) {
        if (imgElement && imgElement.src) {
            window.open(imgElement.src, '_blank'); // Open the image source in a new tab
        } else {
            alert('No image source found!');
        }
    }
})();