Open Image on Double-Click

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

  1. // ==UserScript==
  2. // @name Open Image on Double-Click
  3. // @namespace net.tealpink
  4. // @version 1.0.0
  5. // @description Opens the image in a new tab on double-clicking full image
  6. // @author tealpink
  7. // @license MIT
  8. // @match https://onlyfans.com/*
  9. // @grant none
  10. // @run-at document-idle
  11. // @noframes
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. 'use strict';
  16.  
  17. // Add a double-click listener to the document body
  18. document.body.addEventListener('dblclick', function (e) {
  19. const clickedElement = e.target;
  20.  
  21. // Check if the clicked element is a <div> containing an <img>
  22. if (clickedElement.tagName === 'DIV' && clickedElement.querySelector('img')) {
  23. const imgElement = clickedElement.querySelector('img');
  24. openImageInNewTab(imgElement);
  25. }
  26. });
  27.  
  28. // Function to open an image in a new tab
  29. function openImageInNewTab(imgElement) {
  30. if (imgElement && imgElement.src) {
  31. window.open(imgElement.src, '_blank'); // Open the image source in a new tab
  32. } else {
  33. alert('No image source found!');
  34. }
  35. }
  36. })();