ExtendYouPorn

Remove ads, enlarges video, stops autoplay keeping buffering, fixes the overhaul style & block pop-ups

Verzia zo dňa 25.10.2014. Pozri najnovšiu verziu.

  1. // ==UserScript==
  2. // @author Jack_mustang
  3. // @version 3.9
  4. // @name ExtendYouPorn
  5. // @description Remove ads, enlarges video, stops autoplay keeping buffering, fixes the overhaul style & block pop-ups
  6. // @date 2014 October 25
  7. // @include *youporn.com/*
  8. // @run-at document-start
  9. // @grant none
  10. // @license Public Domain
  11. // @icon http://public.bay.livefilestore.com/y1pSshvmSZkkqpfd9b6gp07U8-OpJIkZfKToFxXLn2M98janqOErccktUHWxF8gqQ6LdW5SrmzSRZONoPbE_YCaJw/ExtendYouPornIcon.png
  12. // @namespace https://greasyfork.org/users/2464
  13. // ==/UserScript==
  14. var ExtendYP = function ExtendYouPorn(){
  15. // Pop-up killer, we trick YP to think we are old Presto Opera, this kills the pop-ups
  16. if (!window.opera)
  17. window.opera = true
  18.  
  19. addStyle()
  20.  
  21. window.addEventListener('DOMContentLoaded', function(){
  22. // Remove ads functions
  23. function removeQuery(query) {
  24. var ifr = document.querySelectorAll(query)
  25. if(ifr.length > 0)
  26. for(var i=0; i < ifr.length; i++)
  27. ifr[i].parentNode.removeChild(ifr[i])
  28. }
  29. // Advertisements
  30. removeQuery(".advertisement")
  31. // Remove right banners in video page
  32. removeQuery(".adSpace")
  33. // Remove footer ad in video page
  34. removeQuery(".advertisement_watchFooter")
  35. // Remove video bottom ad
  36. removeQuery(".ad-bottom")
  37. // Remove iframes because they are ads
  38. removeQuery("iframe")
  39.  
  40. // Set tooltips for the titles
  41. var titles = document.getElementsByClassName('videoTitle')
  42. if(titles.length > 0)
  43. for(i=0; i < titles.length; i++)
  44. titles[i].setAttribute('title', titles[i].innerHTML)
  45.  
  46. /* Video page */
  47. if(document.getElementById('videoContainer')) {
  48. var rightColumn = document.querySelector('.right-column'),
  49. rightColumnNode = rightColumn.cloneNode(true)
  50. document.getElementById('videoCanvas').removeChild(rightColumn)
  51. document.querySelector('.left-column').appendChild(rightColumnNode)
  52.  
  53. // Change player
  54. var player = document.querySelector('#videoContainer').parentNode.innerHTML
  55. player = player.replace(/autoplay=true/g,"autoplay=false&autoload=true")
  56. player = player.replace(/disablePauseroll=false/g,"disablePauseroll=true")
  57. player = player.replace(/disable_sharebar=false/g,"disable_sharebar=true")
  58. player = player.replace(/&pauseroll_url=http:\/\/ads(.*).php/g,"")
  59. document.querySelector('#videoContainer').parentNode.innerHTML = player
  60.  
  61. // Scroll video to middle of page
  62. function scrollthere() {
  63. var player = document.getElementById('videoContainer'),
  64. vh = player.offsetHeight,
  65. vd = (player.parentNode.offsetTop == 0)? ((document.querySelector('#studioCanvas'))? document.querySelector('.grid_8.alpha').offsetTop : document.querySelector('.watchWrapper').offsetTop+document.querySelector('#videoCanvas').offsetTop ) : player.parentNode.offsetTop,
  66. fh = window.innerHeight;
  67. sc = vd-((fh-vh)/2)
  68. scrollTo(0, sc)
  69. console.info("top: "+vd+", height: "+vh+", scrolled: "+sc+", window: "+fh)
  70. }
  71. // Inject this function to page
  72. var script = document.createElement("script")
  73. script.setAttribute("type", "text/javascript")
  74. script.innerHTML = scrollthere.toString() + "scrollthere();"
  75. script.id = "EYP-scrollVid"
  76. document.body.appendChild(script)
  77.  
  78. // Include button in right corner to center video on screen
  79. var node = document.createElement("div")
  80. node.setAttribute("style","position: fixed; bottom: 0; right: 0; cursor: pointer; border-top-left-radius: 10px; color: #fff; text-shadow: 1px 1px 1px #292929; font-weight: 700; background: url('http://cdn1.static.youporn.phncdn.com/cb/bundles/manwinyoupornwebfront/images/sprite-watch-bg.png?v=1358797378') 0px -42px repeat-x transparent; text-align: center; font-size: 1.2em; padding: 7px;z-index: 999999;")
  81. node.setAttribute("onclick", "scrollthere();")
  82. node.innerHTML = "Center video"
  83. node.id = "EYP-scroll"
  84. document.body.appendChild(node)
  85. }
  86. },false)
  87.  
  88. function addStyle() {
  89. // While <head> is not loaded we keep trying
  90. if (!document.querySelector("head"))
  91. return setTimeout(addStyle, 50)
  92.  
  93. // Block popups and let middle mouse click on thumbs open link
  94. function popupBlocker (event) {
  95. window.g367CB268B1094004A3689751E7AC568F = "EYP-Blocker"
  96. }
  97. var popblock = document.createElement("script")
  98. popblock.setAttribute("type", "text/javascript")
  99. popblock.id = "ERT-popupBlock"
  100. popblock.innerHTML = 'window.addEventListener("DOMContentLoaded", function blockPop() {\n'+
  101. 'var name = document.querySelectorAll(".te")\n'+
  102. 'if(name.length > 0)\n'+
  103. 'for(var i=0; i < name.length; i++)\n'+
  104. '$("#"+name[i].id).off("click")\n'+
  105. '}, false)\n'+
  106. 'window.addEventListener("DOMNodeInserted", '+ popupBlocker.toString() +', false)'
  107. var targ = document.head
  108. targ.appendChild(popblock)
  109.  
  110. // We create an object and start including its content to include in DOM at the end
  111. var eypcss =
  112. // Hide ads while we can't remove them
  113. ".advertisement, .adSpace, .advertisement_watchFooter, .ad-bottom, #videoCanvas .grid_5 {\n\
  114. display: none !important;\n\
  115. }\n" +
  116. // Fix ::selection
  117. "::selection {\n\
  118. background: #FFACC0;\n\
  119. color: #fff;\n\
  120. }\n\
  121. ::moz-selection {\n\
  122. background: #FFACC0;\n\
  123. color: #fff;\n\
  124. }\n" +
  125. // Videos Being Watched Right Now in one line
  126. ".videoList.vbwn ul {\n\
  127. margin: 0 !important;\n\
  128. width: 100% !important;\n\
  129. }\n\
  130. .videoList.count-6 ul li.videoBox.grid_3 {\n\
  131. margin: 0 10px 10px 0 !important;\n\
  132. }\n\
  133. .vbwn .omega {\n\
  134. display: none !important;\n\
  135. }\n\
  136. .videoList.count-6 ul .videoBox.grid_3:nth-child(5) {\n\
  137. margin-right: 0 !important;\n\
  138. }\n\
  139. .videoList.count-6.vbwn ul li.videoBox.grid_3:nth-child(4n) {\n\
  140. clear: none !important;\n\
  141. }\n\
  142. @media only screen and (max-width: 9999px) {\n\
  143. .videoList.count-6 ul li.videoBox.grid_3, [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3 {\n\
  144. margin: 0 1% 1% 0 !important;\n\
  145. }\n\
  146. }\n\
  147. @media only screen and (max-width: 1699px) and (min-width: 1280px) {\n\
  148. .videoList.count-6 ul li.videoBox.grid_3, [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3 {\n\
  149. width: 23.9% !important;\n\
  150. }\n\
  151. .videoList.count-6 ul li.videoBox.grid_3:nth-child(4n), [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3:nth-child(4n) {\n\
  152. margin-right: 0 !important;\n\
  153. }\n\
  154. .videoList ul li.videoBox.subscription.grid_3:last-child {\n\
  155. display: none;\n\
  156. }\n\
  157. }\n\
  158. @media only screen and (min-width: 1700px) {\n\
  159. .videoList.count-6 ul li.videoBox.grid_3, [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3 {\n\
  160. width: 18.9% !important;\n\
  161. }\n\
  162. [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3:nth-child(5n) {\n\
  163. margin-right: 0 !important;\n\
  164. }\n\
  165. }\n" +
  166. /* Video page */
  167. // Enlarge video
  168. ".left-column, #videoCanvas #videoWrapper {\n\
  169. width: 100% !important;\n\
  170. }\n\
  171. .underplayer-tabs {\n\
  172. float: left;\n\
  173. }\n" +
  174. // User pages - Dashboard
  175. ".wrapTitle.grid_9 {\n\
  176. width: 100% !important;\n\
  177. }\n" +
  178. // Fix last element non-clickable on festive skins
  179. "#watchBottom {\n\
  180. position: relative;\n\
  181. z-index: 1;\n\
  182. }\n" +
  183. /* Channel pages */
  184. "#channelCanvas .grid_3 {\n\
  185. width: 25% !important;\n\
  186. }\n"
  187.  
  188. // Inject created CSS
  189. var eypnode = document.createElement("style")
  190. eypnode.type = "text/css"
  191. eypnode.id = "EYP-style"
  192. eypnode.appendChild(document.createTextNode(eypcss))
  193. document.head.appendChild(eypnode)
  194. }
  195. }();