Gelbooru fullscreen image viewer

Auto loads original version of any picture on Gelbooru website

Mint 2017.08.11.. Lásd a legutóbbi verzió

  1. // ==UserScript==
  2. // @name Gelbooru fullscreen image viewer
  3. // @description Auto loads original version of any picture on Gelbooru website
  4. // @exclude /^https?://gelbooru\.com/index\.php\?page=post\&s=view\&id=\d{1,99}#$/
  5. // @include /^https?://gelbooru\.com/index\.php\?page=post\&s=view\&id=\d{1,99}$/
  6. // @require https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js
  7. // @author iceman94
  8. // @copyright 2015+, iceman94
  9. // @version 0.01
  10. // @grant none
  11. // @namespace https://greasyfork.org/users/148290
  12. // ==/UserScript==
  13.  
  14. //https://gelbooru.com/index.php?page=post&s=view&id=3646928
  15. //http://gelbooru\.com/index\.php\?page=post\&s=view\&id=\d{1,99}$
  16.  
  17. //=======================================================================================================
  18. // Cross-browsers load function
  19. // Tests in this order :
  20. // -support for jQuery API
  21. // |-uses $(window).load method if available
  22. // |-uses $(window).ready method if available
  23. // -support for DOMContentLoaded event (compatible only with the following browsers :
  24. // Chrome >= 0.2; Firefox >= 1.0; IE >= 9.0; Opera >= 9.0; Safari >= 3.1)
  25. // -support for document.attachEvent
  26. // -uses setTimeout w/ 5000ms delay
  27. //=======================================================================================================
  28.  
  29. function XBLoad (func, verbose)
  30. {
  31. verbose = verbose || false;
  32.  
  33. if (window.jQuery)
  34. {
  35. if ($(window).load)
  36. {
  37. if (verbose == true) { console.log('Javascript loaded using $(window).load method'); };
  38. return $(window).load(function() { func(); });
  39. }
  40. else if ($(window).ready)
  41. {
  42. if (verbose == true) { console.log('Javascript loaded using $(window).ready method'); };
  43. return $(window).ready(function() { func(); });
  44. };
  45. }
  46. else if (document.addEventListener)
  47. {
  48. if (verbose == true) { console.log('Javascript loaded using document.addEventListener method'); };
  49. document.addEventListener('DOMContentLoaded', function(event)
  50. {
  51. return func();
  52. });
  53. }
  54. else if (document.attachEvent)
  55. {
  56. if (verbose == true) { console.log('Javascript loaded using document.attachEvent method'); };
  57. document.attachEvent('load', function()
  58. {
  59. return func();
  60. });
  61. }
  62. else
  63. {
  64. if (verbose == true) { console.log('Javascript loaded using setTimeout method'); };
  65. return setTimeout(function() { func(); }, 5000);
  66. };
  67. };
  68.  
  69.  
  70. //=======================================================================================================
  71. // Setting up functions
  72. //=======================================================================================================
  73.  
  74. // Loads original (high resolution) version of any picture if available
  75. function loadOriginal ()
  76. {
  77. var coll = document.getElementsByTagName('a');
  78. var collL = coll.length;
  79. for (var i=0; i<collL; i++)
  80. {
  81. if (coll[i] && coll[i].textContent == 'Original image')
  82. {
  83. editLocation();
  84. window.location = coll[i].href;
  85. }
  86. }
  87. }
  88. // function loadOriginal ()
  89. // {
  90. // if (document.getElementById('image') && document.getElementById('image').src)
  91. // {
  92. // $('body').load( document.getElementById('image').src);
  93. // }
  94. // }
  95.  
  96. // Appends pound ('#') symbol to actual URI to avoid endless redirecting
  97. function editLocation ()
  98. {
  99. window.location.replace(window.location.href + "#");
  100. }
  101.  
  102.  
  103. //=======================================================================================================
  104. // Showtime !
  105. //=======================================================================================================
  106.  
  107. XBLoad(loadOriginal());