Open Image on Double-Click

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

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

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

// ==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!');
        }
    }
})();