rule34.xxx Improved

Bunch of improvements for rule34.xxx

  1. // ==UserScript==
  2. // @name rule34.xxx Improved
  3. // @namespace Hentiedup
  4. // @version 0.1
  5. // @description Bunch of improvements for rule34.xxx
  6. // @author Hentiedup
  7. // @match https://rule34.xxx/*
  8. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. //=======================================================//
  16. /**///================ Settings ===================///**/
  17. /**/ /**/
  18. /**/ var autoplayVideos = true; /**/
  19. /**/ var defaultVideoVolume = 1; /**/
  20. /**/ var useViewportDependentHeight = true; /**/
  21. /**/ var ViewportDependentHeight = 70; /**/
  22. /**/ var stretchImgVid = false; /**/
  23. /**/ var trueVideoSize = true; /**/
  24. /**/ /**/
  25. /**///===============================================///**/
  26. //=======================================================//
  27. /*
  28.  
  29. Settings explained
  30.  
  31. -autoplayVideos: (true/false)
  32. -defaultVideoVolume: (0-1) 0=mute, 0.5=50%, 1=100%, etc.
  33. -useViewportDependentHeight: (true/false) Makes the max-height of all images and videos X% of the viewport (inner window of the browser) height.
  34. -ViewportDependentHeight: (1-100) the size used by above. (in %)
  35. -stretchImgVid: (true/false) Makes image and video height follow the ViewportDependentHeight regardless of true size. i.e. will stretch if needed.
  36. -trueVideoSize: (true/false) Resizes videos to their true size (unless overriden by stretchImgVid)
  37.  
  38. */
  39. //Don't touch anything else unless you know what you're doing
  40.  
  41.  
  42.  
  43. var viewPDepenCSS = "";
  44. if(useViewportDependentHeight) {
  45. viewPDepenCSS = (stretchImgVid ? `
  46. #gelcomVideoContainer {
  47. width: auto !important;
  48. max-width: 100% !important;
  49. height: ` + ViewportDependentHeight + `vh !important;
  50. }
  51. ` : "") + `
  52. #image {
  53. width: auto !important;
  54. max-width: 100% !important;
  55. ` + (stretchImgVid ? "" : "max-") + `height: ` + ViewportDependentHeight + `vh !important;
  56. }
  57. `;
  58. }
  59.  
  60.  
  61. addGlobalStyle(`
  62. #content > #post-view > #right-col > div > img.custom-button {
  63. cursor: pointer;
  64. width: 35px;
  65. padding: 3px;
  66. margin: 0;
  67. border-radius: 20px;
  68. }
  69. .custom-button:hover {
  70. background-color: rgba(255,255,255,.5);
  71. }
  72. .custom-button:active {
  73. background-color: rgba(255,255,255,1);
  74. }
  75.  
  76. ` + viewPDepenCSS + `
  77.  
  78. `);
  79.  
  80. $("#gelcomVideoPlayer").prop("volume", defaultVideoVolume);
  81. if(autoplayVideos)
  82. $("#gelcomVideoPlayer").prop("autoplay", true);
  83.  
  84. if(!stretchImgVid && trueVideoSize) {
  85. $("#gelcomVideoContainer").prop("style", "width: " + ($("#stats > ul > li:contains('Size: ')").text().split(": ")[1].split("x")[0]) + "px; max-width: 100%; height: " + ($("#stats > ul > li:contains('Size: ')").text().split("x")[1]) + "px;");
  86. }
  87.  
  88. $("#edit_form").prev().before('<img id="like-butt" class="custom-button" src="https://i.imgur.com/Kh1HzGr.png" alt="like"><img id="favorite-butt" class="custom-button" src="https://i.imgur.com/dTpBrIj.png" alt="favorite">');
  89. $("#like-butt").click(function() {
  90. $("#stats > ul > li:contains('(vote up)') > a:contains('up')").click();
  91. });
  92. $("#favorite-butt").click(function() {
  93. $("#stats + div > ul > li > a:contains('Add to favorites')").click();
  94. });
  95.  
  96. function addGlobalStyle(css) {
  97. var head, style;
  98. head = document.getElementsByTagName('head')[0];
  99. if (!head) { return; }
  100. style = document.createElement('style');
  101. style.type = 'text/css';
  102. style.innerHTML = css;
  103. head.appendChild(style);
  104. }
  105. })();