fantasti.cc load images from thumbnails

Show images instead of thumbnails (+ endless scrolling with AutoPager)

  1. // ==UserScript==
  2. // @name fantasti.cc load images from thumbnails
  3. // @namespace https://greasyfork.org/users/5174-jesuis-parapluie
  4. // @author jesuis-parapluie
  5. // @description Show images instead of thumbnails (+ endless scrolling with AutoPager)
  6. //
  7. // @include /^https?://(.+\.)?fantasti\.cc/(.+/)?images/.*$/
  8. // @exclude /^https?://(.+\.)?fantasti\.cc/(.+/)?images/image/.*$/
  9. // @exclude http://fantasti.cc/category/tagcloud/images/*
  10. //
  11. // @require http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js
  12. //
  13. // @version 0.12
  14. // @grant none
  15. // ==/UserScript==
  16.  
  17. (function ($) {
  18. "use strict";
  19. /*jslint browser:true */
  20. /*global $, jQuery */
  21. var loadImgs = function () {
  22. var query = $('div#loop'),
  23. q = $("div[id*='post_']");
  24. if (!query.size()) {
  25. query = $('div#archive');
  26. q = $('.xxx').parent();
  27. }
  28. query.each(function () {
  29. if (!$(this).hasClass('done')) {
  30. var imgs, p;
  31. $(this).addClass('done');
  32. imgs = $('<div>', {
  33. 'class': 'images'
  34. });
  35. p = $(this).find('.pages').last();
  36. if (p.size()) {
  37. $(this).before(p.parent(), imgs);
  38. } else {
  39. imgs.appendTo($(this));
  40. }
  41. $(this).find(q).each(function () {
  42. if (!$(this).hasClass('imgdone')) {
  43. $(this).addClass('imgdone');
  44. var href = $(this).find('a').attr('href');
  45. $.get(href, function (data) {
  46. var link = $('<a>', {
  47. 'href': href
  48. });
  49. link.append($(data).find('div[id*=\'albums\']').find('img'));
  50. imgs.append(link);
  51. });
  52. }
  53. });
  54. }
  55. });
  56. };
  57. $(function () {
  58. var link = $('<a>', {
  59. 'id': 'loadImgs',
  60. 'class': 'subm_link',
  61. 'style': 'color:#FF4700;cursor:pointer;font-weight:bold;',
  62. 'text': 'Show images'
  63. }).click(function () {
  64. var query;
  65. if ($('a#loadImgs').hasClass('imagesVisible')) {
  66. $('a#loadImgs').removeClass('imagesVisible');
  67. $('a#loadImgs').html('Show images');
  68. $('div.images').hide();
  69. query = $("div[id*='post_']");
  70. if (!$(query).size()) {
  71. query = $('.xxx').parent();
  72. }
  73. query.show();
  74. $('div#extra_webcams').show();
  75. } else {
  76. $('a#loadImgs').addClass('imagesVisible');
  77. $('a#loadImgs').html('Show thumbnails');
  78. $('div.images').show();
  79. query = $("div[id*='post_']");
  80. if (!$(query).size()) {
  81. query = $('.xxx').parent();
  82. }
  83. query.hide();
  84. $('div#extra_webcams').hide();
  85. loadImgs();
  86. }
  87. });
  88. $('.sm-navlist').append($('<li>').append(link));
  89. $('head').append('<style>.images img { width: 100%!important; height: 100%!important; margin-left: 20px; };</style>');
  90.  
  91. $(document).bind('DOMNodeInserted', function (e) {
  92. if ($('a#loadImgs').hasClass('imagesVisible') && e.target.tagName === 'DIV' && e.target.getAttribute('id') && (e.target.getAttribute('id') === 'loop' || e.target.getAttribute('id') === 'archive')) {
  93. $('div.images').show();
  94. $('div[id*="post_"]').hide();
  95. var query = $("div[id*='post_']");
  96. if (!query.size()) {
  97. query = $('.xxx').parent();
  98. }
  99. query.hide();
  100. loadImgs();
  101. }
  102. });
  103. });
  104. }(jQuery));