PornoLab.net Thumbnail Expander

Automatically unfolds spoilers and replaces thumbnails with full sized images while removing thumbnails linking to adware.

  1. // ==UserScript==
  2. // @name PornoLab.net Thumbnail Expander
  3. // @namespace http://pornolab.net/
  4. // @version 0.5.2
  5. // @description Automatically unfolds spoilers and replaces thumbnails with full sized images while removing thumbnails linking to adware.
  6. // @author Anonymous
  7. // @include http://pornolab.net/forum/viewtopic.php*
  8. // @include https://pornolab.net/forum/viewtopic.php*
  9. // @grant GM_xmlhttpRequest
  10. // ==/UserScript==
  11.  
  12. (function(){
  13. ////////// SETTINGS: ///////////
  14. var auto_unfold = true; // auto unfold spoilers
  15. var auto_preload = true; // start loading images while the spoiler is closed
  16. var max_img_width = '1200px'; // max image widths, set to 'auto' to disable
  17. // thumbnails hosted on these sites will be removed:
  18. var blocked_hosts = ['piccash.net', 'picclick.ru', 'pic4cash.ru', 'picspeed.ru', 'picforall.ru', 'freescreens.ru'];
  19. ////////////////////////////////
  20. var targets = document.querySelectorAll('.sp-wrap');
  21. for(var i=0; i<targets.length; i++){
  22. var containers = targets[i].querySelectorAll('var.postImg');
  23. for(var j=0; j<containers.length; j++){
  24. var url = containers[j].title;
  25. if(url.indexOf('fastpic.org/thumb/') != -1){
  26. (function(target, pageUrl){
  27. GM_xmlhttpRequest({
  28. method: 'GET',
  29. url: pageUrl,
  30. onload: function(response) {
  31. var matches = response.responseText.match(/<img src="http(.+?)" class="image img-fluid"/);
  32. if(matches && matches.length > 1) {
  33. var url = 'http' + matches[1];
  34. GM_xmlhttpRequest({
  35. method: 'GET',
  36. url: url,
  37. responseType: 'blob',
  38. headers: {
  39. referer: pageUrl,
  40. },
  41. onload: function(response) {
  42. var reader = new FileReader();
  43. reader.onload = function() {
  44. updateImageUrl(target, reader.result);
  45. };
  46. reader.readAsDataURL(response.response);
  47. }
  48. });
  49. }
  50. }
  51. });
  52. })(containers[j], containers[j].parentNode.href);
  53. } else if(url.indexOf('imagebam.com') != -1){
  54. (function(target){
  55. GM_xmlhttpRequest({
  56. method: 'GET',
  57. url: target.parentNode.href,
  58. onload: function(response) {
  59. var matches = response.responseText.match(/<img src="(.+?)"[^>]+class="main-image/i);
  60. if(matches && matches.length > 1) {
  61. updateImageUrl(target, matches[1]);
  62. }
  63. }
  64. });
  65. })(containers[j]);
  66. } else if(url.indexOf('imagevenue.com') != -1){
  67. (function(target){
  68. GM_xmlhttpRequest({
  69. method: 'GET',
  70. url: target.parentNode.href,
  71. onload: function(response) {
  72. var matches = response.responseText.match(/<img src="http(.+?)"/i);
  73. if(matches && matches.length > 1) {
  74. updateImageUrl(target, 'http' + matches[1]);
  75. }
  76. }
  77. });
  78. })(containers[j]);
  79. } else if(url.indexOf('imgbox.com') != -1){
  80. url = url.replace('thumbs', 'images');
  81. url = url.replace('_t', '_o');
  82. } else if(url.indexOf('imgdrive.net') != -1){
  83. url = url.replace('small', 'big');
  84. } else {
  85. for(var b=0; b<blocked_hosts.length; b++){
  86. if(url.indexOf(blocked_hosts[b]) != -1){
  87. url = null;
  88. break;
  89. }
  90. }
  91. }
  92. if(url){
  93. updateImageUrl(containers[j], url);
  94. }
  95. }
  96.  
  97. if(containers.length) {
  98. if(auto_unfold){
  99. var headers = targets[i].querySelectorAll('.sp-head');
  100. for(var m=0; m<headers.length; m++){
  101. headers[m].className += ' unfolded';
  102. }
  103. }
  104. if(auto_unfold || auto_preload){
  105. var bodies = targets[i].querySelectorAll('.sp-body');
  106. for(var k=0; k<bodies.length; k++){
  107. if(auto_preload){
  108. bodies[k].className += ' inited';
  109. }
  110. if(auto_unfold){
  111. bodies[k].style.display = 'block';
  112. }
  113. }
  114. }
  115. }
  116. }
  117.  
  118. function updateImageUrl(node, url) {
  119. node.title = url;
  120. if(auto_preload){
  121. node.innerHTML = '<img src="' + url + '" style="max-width:' + max_img_width + '" title=""/>';
  122. }
  123. }
  124.  
  125. })();