Imgur open image in new tab

Allows favoriting single images from dumps

  1. // ==UserScript==
  2. // @name Imgur open image in new tab
  3. // @namespace http://cactuspie.com
  4. // @version 1.0
  5. // @description Allows favoriting single images from dumps
  6. // @author CactusPie
  7. // @match https://imgur.com/gallery/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. $(document.body).on("mousedown mouseup click focus blur", "img[src^='//i.imgur.com'],video", e => {
  15. let url;
  16.  
  17. if(e.target.tagName.toUpperCase() === "VIDEO") {
  18. url = e.target.children[0].src;
  19. } else {
  20. url = e.target.src;
  21. }
  22.  
  23. if(e.which === 2) {
  24. const imgName = url.substr(url.lastIndexOf('/') + 1);
  25. let imgId = imgName.substr(0, imgName.indexOf("."));
  26. if(imgId.endsWith('g')) {
  27. imgId = imgId.substr(0, imgId.length - 1);
  28. }
  29. window.open(`https://imgur.com/${imgId}`, '_blank');
  30. }
  31. });
  32. })();