Eza's Gallery Smoothener

Removes unimportant links below thumbnails, so select -> right-click -> open-links-in-new-tabs works cleanly.

  1. // ==UserScript==
  2. // @name Eza's Gallery Smoothener
  3. // @namespace https://inkbunny.net/ezalias
  4. // @author Ezalias
  5. // @description Removes unimportant links below thumbnails, so select -> right-click -> open-links-in-new-tabs works cleanly.
  6. // @license MIT
  7. // @include http://www.furaffinity.net/msg/submissions/*
  8. // @include http://www.furaffinity.net/favorites/*
  9. // @include http://www.furaffinity.net/gallery/*
  10. // @include https://inkbunny.net/submissionsviewall.php*mode=unreadsubs*
  11. // @include https://inkbunny.net/submissionsviewall.php*mode=userfavs*
  12. // @include http://www.hentai-foundry.com/users/FaveUsersRecentPictures?username=*
  13. // @include https://www.hentai-foundry.com/users/FaveUsersRecentPictures?username=*
  14. // @include http://www.hentai-foundry.com/pictures/*
  15. // @include https://www.hentai-foundry.com/pictures/*
  16. // @exclude /^https?://www\.hentai-foundry\.com/pictures/.*/.*/[0-9]*/.*/
  17. // @include https://www.weasyl.com/messages/submissions*
  18. // @include https://www.weasyl.com/submissions*
  19. // @include https://www.weasyl.com/favorites*
  20. // @include http://www.y-gallery.net/gallery/*
  21. // @include http://www.y-gallery.net/favourites/*
  22. // @include http://www.y-gallery.net/browse/
  23. // @include http://www.y-gallery.net/browsetops/
  24. // @include http://www.y-gallery.net/clubgallery/*
  25. // @include http://rule34.paheal.net/post/list/*
  26. // @include http://www.pixiv.net/bookmark_new_illust.php*
  27. // @include http://www.pixiv.net/bookmark.php*
  28. // @include http://www.pixiv.net/member_illust.php?*
  29. // @exclude http://www.pixiv.net/member_illust.php?mode*
  30. // @include https://www.pixiv.net/bookmark_new_illust.php*
  31. // @include https://www.pixiv.net/bookmark.php*
  32. // @include https://www.pixiv.net/member_illust.php?*
  33. // @exclude https://www.pixiv.net/member_illust.php?mode*
  34. // @include http://*.deviantart.com/gallery/*
  35. // @version 1.14
  36. // @grant none
  37. // ==/UserScript==
  38.  
  39. // This removes user-profile links and other extraneous junk from supported image galleries so that users can select many images and open them all in tabs.
  40. // This only matters if your browser has some extension to select multiple links and "Open links in tabs."
  41.  
  42. // Todo: support relevant sites from Eza's Image Glutton - mostly "watching" pages and "favorites" galleries.
  43. // Linked images seem to disappear, even though they ought to be handled by innerHTML.
  44. // SoFurry requires additional handling thanks to their dynamic page shenanigans. (Be restful, you stupid document!)
  45. // Maybe Derpibooru? They have comment / vote links above every thumbnail.
  46. // DeviantArt pools are kind of a pain.
  47. // Can the DOM change an element's tag name? Can I just 'a' -> 'span' for the relevant links? (Seems not.)
  48. // Apparently data-whatever-etc attributes are handled super specially by JS: it's thing.dataset.whateverEtc. Yes, it automatically converts to camelcase. Jesus.
  49. // Fix FurAffinity before uploading? Augh, it's some kind of imaginary inline iframe. Guess I'm stuck with titles off.
  50. // Maybe... maybe just get rid of FA's CSS and resizing code?
  51. // http://www.pixiv.net/response.php?type=illust&id=59618700 - wtf? Ah, image responses.
  52. // http://www.pixiv.net/bookmark.php?id=5238&rest=show&p=4
  53. // Changed some picky details in @includes, mostly .php?* => .php* for bookmark-related URLs.
  54. // Added HTTPS.
  55. // Fixed Hentai-Foundry HTTPS, badly. I fucking hate having to specify that. There's no sane way to do it outside of illegible regexes.
  56. // Added user-gallery support to FurAffinity, whoops. Still only works with titles disabled.
  57. // Pixiv broke on Christmas 2017.
  58. // Removed on-hover menu (and its report link) with interval function.
  59. // Is there some way to make links inactive when they're selected? Some sane way? It'd be useful in Tumblr Scrape as well, for the permalinks.
  60. // Finally excised Hentai-Foundry's thumbnail zoom. Not strictly within this script's stated goal, but definitely a smoothening.
  61. // https://derpibooru.org/ needs this treatment.
  62.  
  63.  
  64.  
  65. // For Pixiv specifically, since they have a weird delayed menu on each thumbnail:
  66. if( document.domain == "www.pixiv.net" ) {
  67. var pixiv_handle = setInterval( pixiv_interval, 1000 );
  68. setTimeout( function() { clearInterval( pixiv_handle ); }, 10000 ); // Lazy solution: after ten seconds, stop trying
  69. // The lazy solution isn't good enough. When loading takes a long time (e.g. after opening a bunch of tabs, duh) menu guff never gets removed.
  70. }
  71.  
  72. function pixiv_interval() {
  73. // Rename 'crap.'
  74. var crap = document.getElementsByClassName( 'thumbnail-menu' ) // For each ellipsis-and-star thumbnail menu (menu: mute / report, favorite)
  75. while( crap[0] ) { crap[0].parentNode.removeChild( crap[0] ); } // While list is not empty, delete first element. (Child -> Parent -> Kill this child.)
  76. remove_links(); // And filter the links again, because they also have a delay issue.
  77. }
  78.  
  79.  
  80.  
  81. // For Furaffinity's awful section/figure/gallery nonsense:
  82. if( document.domain == "www.furaffinity.net" ) {
  83. // So what's the issue here? Do I need to swap the element type of the section? Of the figures?
  84. }
  85.  
  86.  
  87.  
  88. //For Hentai-Foundry's awful on-hover thumbnail zoom:
  89. if( document.domain == "www.hentai-foundry.com" ) {
  90. // These aren't <img> tags, they're <span> elements with the thumbnail as a background. Removing the "thumb" class makes images disappear.
  91. // The zoom-transition rule for .thumb:hover is @included by default.css, so we can't alter it in a sensible fashion.
  92. // So we kludge: swap the "thumb" class for our own knockoff class, with the display rules but not the on-hover rules.
  93.  
  94. var zoom_class = document.getElementsByClassName( "thumb" );
  95. while( zoom_class.length > 0 ) {
  96. zoom_class[0].classList.add( "fake_thumb" );
  97. zoom_class[0].classList.remove( "thumb" );
  98. }
  99.  
  100. var sheet = document.createElement( "style" );
  101. sheet.innerHTML = ".fake_thumb { background-position: center center; background-size: cover; background-repeat: no-repeat; border: 0; width: 200px; height: 200px;display: block; }";
  102. document.body.appendChild( sheet );
  103. }
  104.  
  105.  
  106.  
  107. // For all sites:
  108. remove_links(); // This is now a function so that Pixiv can call it after a delay.
  109. function remove_links() {
  110. var links = document.getElementsByTagName( 'a' ); // Grab all links.
  111. for( var n = links.length-1; n >= 0; n-- ) { // For each link,
  112. if( username_link_in( links[n] ) ) { // If it points to a user's profile,
  113. // Replace it with unlinked text.
  114. var dud = document.createElement("span"); // I.e. - create blank span,
  115. for( var x in links[n] ) { dud[x] = links[n][x]; } // Copy all elements of this link onto this span,
  116. links[n].parentNode.replaceChild( dud, links[n] ); // Replace this link with this span.
  117. }
  118. }
  119. } // Done.
  120.  
  121.  
  122.  
  123. // -------------------------
  124.  
  125.  
  126.  
  127. function username_link_in( anchor ) { // True / False: does this link element look like a userpage link?
  128. switch( document.domain ) {
  129. case "www.furaffinity.net": // FA: yes, if it contains "/user/username". (Also for "deleted by the owner" fake-links.)
  130. return anchor.href.indexOf( "/user/" ) > 0 || anchor.href.indexOf( "/favorites/" ) >= 0; break;
  131. case "inkbunny.net": // IB: yes, if the messy class string includes a userName designation.
  132. return anchor.className.indexOf( "userName" ) > 0; break;
  133. case "www.hentai-foundry.com": // HF: yes, if it contains "/user/username/profile". (Every HF link has /user/ in it. Grr.)
  134. return anchor.href.indexOf( "/profile" ) > 0; break;
  135. case "www.weasyl.com": // Weasy: yes, if it contains... tilde? I don't even remember writing this one. Am I on Weasyl?
  136. return anchor.href.indexOf( "~" ) > 0; break;
  137. case "www.y-gallery.net": // YG: yes, if it contains "/user/username" or "/club/clubname".
  138. return anchor.href.indexOf( "/user/" ) > 0 || anchor.href.indexOf( "/club/" ) > 0; break;
  139. case "rule34.paheal.net": // Paheal: yes, if it's a bare image link. (Or a weird invisible same-page anchor.)
  140. return anchor.href.indexOf( "_images" ) > 0 || anchor.href[ anchor.href.length - 1 ] == "#"; break;
  141. case "www.pixiv.net": // Pixiv: yes, if it's a username. But not on Works pages.
  142. return ( anchor.href.indexOf( "member_illust.php?id" ) > 0 && window.location.href.indexOf( "member_illust.php?id" ) < 0 )
  143. || ( anchor.href.indexOf( "/series/" ) > 0 ) // Also ignore links to series collections.
  144. break;
  145. }
  146. if( document.domain.indexOf( '.deviantart.com' ) > -1 ) { // Fucking subdomains.
  147. return ( anchor.href.indexOf( '#comments' ) > -1 || anchor.href.indexOf( '/morelikethis/' ) > -1 ); // DeviantArt: yes for "comments" and "more like this."
  148. }
  149. }
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.