Open Image on Double-Click

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

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