Sleazy Fork is available in English.

Redgifs++

Automatically sets Redgifs to HD and unmutes when viewed directly or on Reddit. Inspired by "betterRedgifs" by u/MatthieuG7.

  1. // ==UserScript==
  2. // @name Redgifs++
  3. // @version 1.1
  4. // @license AGPLv3
  5. // @author midnightarousal93
  6. // @description Automatically sets Redgifs to HD and unmutes when viewed directly or on Reddit. Inspired by "betterRedgifs" by u/MatthieuG7.
  7. // @match https://www.redgifs.com/ifr/*
  8. // @match https://www.redgifs.com/watch/*
  9. // @match https://old.reddit.com/*
  10. // @match https://www.reddit.com/*
  11. // @grant none
  12. // @namespace https://greasyfork.org/users/1073886
  13. // ==/UserScript==
  14.  
  15. if (window.location.href.includes("redgifs.com")) {
  16.  
  17. const click = (elm) => {
  18. const evt = document.createEvent('MouseEvents');
  19. evt.initMouseEvent('click', true, true, window, 0, 1, 1, 1, 1, false, false, false, false, 0, null);
  20. elm.dispatchEvent(evt);
  21. }
  22.  
  23. const hdInterval = setInterval(() => {
  24. const gear = document.querySelector(".gear");
  25. if (gear) {
  26. if (gear.parentNode.childNodes[1].outerText == "SD") {
  27. click(gear);
  28. return clearInterval(hdInterval);
  29. }
  30. else if (gear.parentNode.childNodes[1].outerText == "HD") {
  31. return clearInterval(hdInterval);
  32. }
  33. }
  34. const sd = document.querySelector(".sd");
  35. if (sd) {
  36. click(sd);
  37. return clearInterval(hdInterval);
  38. }
  39. const hd = document.querySelector(".hd");
  40. if (hd) {
  41. return clearInterval(hdInterval);
  42. }
  43. }, 100)
  44.  
  45. function unmute() {
  46. if (!this.unmuted) {
  47. this.unmuted = true
  48. const unmuteInterval = setInterval(() => {
  49. const soundOff = document.querySelector(".soundOff");
  50. if (soundOff) {
  51. click(soundOff);
  52. return clearInterval(unmuteInterval);
  53. }
  54. const video = document.querySelector(".embeddedPlayer video");
  55. if (video && video.muted === true) {
  56. video.muted = false;
  57. return clearInterval(unmuteInterval);
  58. }
  59. }, 100)
  60. }
  61. }
  62.  
  63. if (window.top === window.self) {
  64. unmute();
  65. }
  66. else {
  67. window.addEventListener("message", function(event) {
  68. if (event.data.unmuteRedgifs) {
  69. unmute();
  70. }
  71. }, false);
  72. }
  73. }
  74. else if (window.location.href.includes("old.reddit.com")) {
  75. setInterval(() => {
  76. const iframes = document.getElementsByTagName("iframe");
  77. for(let i = 0; i < iframes.length; i++) {
  78. iframes[i].contentWindow.postMessage({
  79. unmuteRedgifs: true
  80. }, "*");
  81. }
  82. }, 500)
  83. }
  84. else if (window.location.href.includes("www.reddit.com")) {
  85. const processElement = (element) => {
  86. const iframes = element.getElementsByTagName("iframe");
  87. for (let i = 0; i < iframes.length; i++) {
  88. iframes[i].contentWindow.postMessage({
  89. unmuteRedgifs: true
  90. }, "*");
  91. }
  92. }
  93.  
  94. setInterval(() => {
  95. const content = document.querySelectorAll('[data-test-id="post-content"]');
  96. for (let i = 0; i < content.length; i++) {
  97. processElement(content[i]);
  98. }
  99. const closeButtons = document.querySelectorAll('[data-click-id="expando_close"]');
  100. for (let i = 0; i < closeButtons.length; i++) {
  101. const postContainer = closeButtons[i].closest('[data-testid="post-container"]');
  102. if (postContainer) {
  103. processElement(postContainer);
  104. }
  105. }
  106. }, 500)
  107. }