ExtendRedTube

Remove ads, enlarge video, add video download links, block popups and stops autoplay keeping buffering

  1. // ==UserScript==
  2. // @author Jack_mustang
  3. // @version 6.0
  4. // @name ExtendRedTube
  5. // @description Remove ads, enlarge video, add video download links, block popups and stops autoplay keeping buffering
  6. // @date 2017 October 3
  7. // @include *redtube.com*
  8. // @include *redtube.org*
  9. // @include *redtube.cz*
  10. // @include *redtube.es*
  11. // @include *redtube.fr*
  12. // @include *redtube.it*
  13. // @include *redtube.kr*
  14. // @include *redtube.pl*
  15. // @include *redtube.si*
  16. // @exclude *blog.redtube.com*
  17. // @exclude *api.redtube.com*
  18. // @run-at document-start
  19. // @grant none
  20. // @license Public Domain
  21. // @icon https://gmgmla.dm2301.livefilestore.com/y2phTdvWAn7a3fxjda6GWNCiS1ERegalgwxn5z-65SPxhpws5ISHa-Z8CHpmq18FPUOBm-3QJtCfOYFaiyM0Kji1MwBUy6mkxBLJtc5THpPtEU/ERT-logo.png
  22. // @namespace 44db8537bb6ac3d112dd3b5ec7b6b33b84aa5765
  23. // ==/UserScript==
  24.  
  25. // Block popups fallback
  26. function NoOpen() { return 1; }
  27. parent.open = NoOpen;
  28. this.open = NoOpen;
  29. window.open = NoOpen;
  30. open = NoOpen;
  31. window.open = function () { return; };
  32. open = function () { return; };
  33. this.open = function () { return; };
  34. parent.open = function () { return; };
  35.  
  36. function fnull() {
  37. return null;
  38. }
  39.  
  40. // Block ads
  41. Object.defineProperty(window, "adDelivery", {
  42. get: fnull,
  43. set: fnull
  44. });
  45. Object.defineProperty(window, "tj_ads", {
  46. get: fnull,
  47. set: fnull
  48. });
  49. Object.defineProperty(window, "tj_channels", {
  50. get: fnull,
  51. set: fnull
  52. });
  53.  
  54. // stop autoplay
  55. Object.defineProperty(window, "MHP1138", {
  56. set: function (e) {
  57. if (!!e.players.redtube_flv_player) {
  58. e.players.redtube_flv_player.autoplay = false;
  59. e.players.redtube_flv_player.autoPlayVideo.enabled = false;
  60. e.players.redtube_flv_player.flashSettings.autoplay = false;
  61. }
  62. window.MHP1138a = e;
  63. },
  64. get: function () {
  65. return window.MHP1138a;
  66. }
  67. });
  68.  
  69. // Inject CSS
  70. (function addStuff() {
  71. // While <head> is not loaded we keep trying
  72. if (!document.querySelector("head")) {
  73. return setTimeout(addStuff, 50);
  74. }
  75.  
  76. // We create an object and start including its content to include in DOM at the end.
  77. var ertcss =
  78. // Hide ads while we can't remove them
  79. ".tja,\
  80. .tj_ads_remove,\
  81. #slidePanelContainerAB,\
  82. .footerAd,\
  83. .bvq,\
  84. .bvq-caption {\
  85. display: none !important;\
  86. visibility: hidden !important;\
  87. opacity: 0 !important;\
  88. height: 0 !important;\
  89. overflow: hidden !important;\
  90. width: 0 !important;\
  91. }" +
  92. // Prevent background ad
  93. "body {\
  94. background-color: #000 !important;\
  95. }" +
  96. // Make thumbs have 4 in every row
  97. "#home_page_section_c,\
  98. #community_section_b {\
  99. display: none;\
  100. }\
  101. ul.video-listing.two-in-row {\
  102. width: 100% !important;\
  103. }\
  104. ul.video-listing.two-in-row .first-in-row:nth-child(3) {\
  105. clear: none;\
  106. margin-left: 25px;\
  107. }" +
  108. // Porstar page
  109. ".pornstar-small-info,\
  110. .close-button,\
  111. .show-less-link {\
  112. display: none !important\
  113. }\
  114. .pornstar-highlight {\
  115. background: none !important;\
  116. margin-bottom: -390px !important;\
  117. width: auto !important;\
  118. z-index: 2;\
  119. }\
  120. .pornstar-details-subscribe {\
  121. margin-right: 0 !important;\
  122. padding-left: 235px\
  123. }\
  124. .pornstar-all-info {\
  125. float: right !important;\
  126. width: 485px !important;\
  127. }\
  128. .pornstar-highlight-more {\
  129. display: block !important\
  130. }" +
  131. // PornStars page
  132. "ul.pornStarsThumbs.four-in-row {\
  133. width: 100% !important\
  134. }\
  135. .pornStarsThumbs.four-in-row > li {\
  136. clear: none !important;\
  137. margin: 0 8px 20px 0 !important\
  138. }\
  139. .pornStarsThumbs.four-in-row > li:last-child {\
  140. margin-right: 0 !important;\
  141. }" +
  142. // Gallery
  143. ".gallery-listing.three-in-row .first-in-row {\
  144. clear: none !important;\
  145. margin-left: 24px !important;\
  146. }\
  147. .galleriesTable .pages {\
  148. padding: 45px 0 125px 100px;\
  149. }\
  150. .gallery-listing.three-in-row li:last-child {\
  151. position: absolute;\
  152. bottom: 135px;\
  153. margin-left: 0 !important;\
  154. }" +
  155. // Video Page
  156. // Enlarge player
  157. ".video-wrap,\
  158. .watch,\
  159. .videoPlayer {\
  160. width: 100% !important;\
  161. }\
  162. .videoPlayer {\
  163. height: auto !important;\
  164. }\
  165. .mhp1138_container .mhp1138_videoWrapper,\
  166. .mhp1138_container .mhp1138_videoWrapper video {\
  167. height: auto !important;\
  168. position: static !important;\
  169. }" +
  170. // Change pause button
  171. "#pb_template > :not(.mhp1138_playerStateIcon) {\
  172. display: none;\
  173. }";
  174.  
  175. // Inject created CSS
  176. var ertnode = document.createElement("style");
  177. ertnode.type = "text/css";
  178. ertnode.id = "ERT-style";
  179. ertnode.appendChild(document.createTextNode(ertcss));
  180. document.head.appendChild(ertnode);
  181. }());
  182.  
  183. (function ExtendRedTube() {
  184. function videoStuff() {
  185. // Scroll video to middle of page
  186. function scrollthere() {
  187. var vid = document.querySelector(".watch");
  188. var vh = vid.offsetHeight;
  189. var vd = vid.offsetTop + document.querySelector("#contentHolder").offsetTop;
  190. var fh = window.innerHeight;
  191. var sc = vd - ((fh - vh) / 2);
  192. console.log(vd);
  193. scrollTo(0, sc);
  194. }
  195. // Now inject this function
  196. var script = document.createElement("script");
  197. script.setAttribute("type", "text/javascript");
  198. script.innerHTML = scrollthere.toString();
  199. script.id = ("ERT-scrollVid");
  200. document.head.appendChild(script);
  201. window.setTimeout(scrollthere, 500);
  202.  
  203. // Keyboard Shortcut for centring
  204. window.addEventListener("keyup", function (e) {
  205. if (e.ctrlKey && e.altKey && (e.code === "KeyC" || (e.code === undefined && e.keyCode === 67))) {
  206. scrollthere();
  207. }
  208. }, false);
  209.  
  210. // Include button in right corner to center video on screen;
  211. var node = document.createElement("div");
  212. node.setAttribute("style", "position: fixed;" +
  213. "bottom: 0;" +
  214. "right: 0;" +
  215. "top: auto !important;" +
  216. "height: 15px;" +
  217. "cursor: pointer;" +
  218. "background: #121212;" +
  219. "padding: 5px 10px;" +
  220. "border: 1px solid #202020;" +
  221. "z-index: 10000");
  222. node.setAttribute("onclick", "scrollthere();");
  223. node.setAttribute("title", "Use the keyboard shortcut Ctrl+Alt+C (For other keyboard layouts use the key where C should be on the QWERTY layout)");
  224. node.innerHTML = "Centre";
  225. document.body.appendChild(node);
  226.  
  227. // Download withouth being logged
  228. if (!!document.querySelector("#download-link-hd")) {
  229. node = document.querySelector("#download-link-hd");
  230. node.parentNode.appendChild(node.cloneNode());
  231. node.parentNode.lastElementChild.innerText = node.innerText.match(/[^\n]+/)[0];
  232. node.parentNode.removeChild(node);
  233. }
  234. if (!!document.querySelector("#download-link-480p")) {
  235. node = document.querySelector("#download-link-480p");
  236. node.parentNode.appendChild(node.cloneNode());
  237. node.parentNode.lastElementChild.innerText = node.innerText.match(/[^\n]+/)[0];
  238. node.parentNode.removeChild(node);
  239. }
  240. if (!!document.querySelector("#download-link-mobile")) {
  241. node = document.querySelector("#download-link-mobile");
  242. node.parentNode.appendChild(node.cloneNode());
  243. node.parentNode.lastElementChild.innerText = node.innerText.match(/[^\n]+/)[0];
  244. node.parentNode.removeChild(node);
  245. }
  246.  
  247. // Thumbnail tabs
  248. var remtab = document.querySelector(".fakeLinkTabber[rel=related-premium-videos]").parentNode;
  249. if (!remtab) {
  250. document.querySelector(".tabsElements").removeChild(remtab);
  251. }
  252. }
  253.  
  254. var observer = new MutationObserver(function (changes) {
  255. changes.forEach(function (chg) {
  256. if (chg.target.id === "redtube_flv_player") {
  257. chg.addedNodes.forEach(function (element) {
  258. if (!!element && element.id === "pb_template") {
  259. var node = document.createElement("div");
  260. node.className = "mhp1138_playerStateIcon";
  261. node.setAttribute("style", "opacity: 1");
  262. node.innerHTML =
  263. "<div class='mhp1138_play' style='display: block'>" +
  264. " <div class='mhp1138_icon mhp1138_icon-play'></div>" +
  265. "</div>" +
  266. "<div class='mhp1138_background'></div>";
  267. element.appendChild(node);
  268.  
  269. videoStuff();
  270. }
  271. });
  272. }
  273. });
  274. });
  275.  
  276. // starts the mutation observer
  277. observer.observe(document, {childList: true, subtree: true});
  278. }());