ExtendYouPorn

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

As of 2015-07-31. See the latest version.

  1. // ==UserScript==
  2. // @author Jack_mustang
  3. // @version 3.13.1
  4. // @name ExtendYouPorn
  5. // @description Remove ads, enlarges video, stops autoplay keeping buffering, fixes the overhaul style & block pop-ups
  6. // @date 2015 July 31
  7. // @include *youporn.com/*
  8. // @include *youporngay.com/*
  9. // @run-at document-start
  10. // @grant none
  11. // @license Public Domain
  12. // @icon https://gmgmla.dm2301.livefilestore.com/y2pYluU8jK3EnLV1U8D92pYCC9wU5O04Il4j64Ft_pjKGpUG_I5L0fUHrsLpUB4oDCLIJdWp9Bwmr0RPMdhJhl5Bo362RwjatCFUpNjEdMosGA/EYP-logo.jpg
  13. // @namespace 14fac5d83892686b90beea51d35d1d7dbcfe49b6
  14. // ==/UserScript==
  15. var ExtendYP = function ExtendYouPorn(){
  16. // Pop-up killer, we trick YP to think we are old Presto Opera, this kills the pop-ups
  17. if (!window.opera)
  18. window.opera = true
  19.  
  20. addStyle()
  21.  
  22. window.addEventListener('DOMContentLoaded', function(){
  23. // Remove ads functions
  24. function removeQuery(query) {
  25. var ifr = document.querySelectorAll(query)
  26. if(ifr.length > 0)
  27. for(var i=0; i < ifr.length; i++)
  28. ifr[i].parentNode.removeChild(ifr[i])
  29. }
  30. // Advertisements
  31. removeQuery(".advertisement")
  32. // Remove right banners in video page
  33. removeQuery(".adSpace")
  34. // Remove footer ad in video page
  35. removeQuery(".advertisement_watchFooter")
  36. // Remove video bottom ad
  37. removeQuery(".ad-bottom")
  38. // Remove iframes because they are ads
  39. removeQuery("iframe")
  40.  
  41. // Set tooltips for the titles
  42. var titles = document.getElementsByClassName('videoTitle')
  43. if(titles.length > 0)
  44. for(i=0; i < titles.length; i++)
  45. titles[i].setAttribute('title', titles[i].innerHTML)
  46.  
  47. /* Video page */
  48. if(document.getElementById('videoContainer')) {
  49. var rightColumn = document.querySelector('.right-column'),
  50. videoWrapper = document.getElementById('videoWrapper')
  51. rightColumn.setAttribute('class', 'right-column large')
  52. videoWrapper.setAttribute('class', 'large')
  53.  
  54. // Delete duplicate video element
  55. var video = document.querySelectorAll('video')
  56. if (video !== null) {
  57. for (var i = video.length - 1; i >= 1; i--)
  58. video[i].parentNode.removeChild(video[i])
  59. if (navigator.userAgent.search("Firefox/") === -1) {
  60. video[0].setAttribute("onclick", "var vid = event.target;if(vid.paused)vid.play();else vid.pause()")
  61. video[0].setAttribute("onmouseover", "event.target.controls = true")
  62. video[0].setAttribute("onmouseout", "event.target.controls = false")
  63. }
  64. }
  65.  
  66. // Change player
  67. var player = document.getElementById('videoContainer'),
  68. vidId = parseInt(videoJason.video_id),
  69. newflashvars = document.createElement("script")
  70. newflashvars.setAttribute("type", "text/javascript")
  71. newflashvars.id = "EYP-newflashvars"
  72. newflashvars.innerHTML =
  73. 'flashvars['+vidId+'].autoplay = false;'+
  74. 'flashvars['+vidId+'].autoload = true;'+
  75. 'flashvars['+vidId+'].disablePauseroll = true;'
  76. player.insertBefore(newflashvars, player.childNodes[0])
  77.  
  78. // Scroll video to middle of page
  79. function scrollthere() {
  80. var player = document.getElementById('videoContainer'),
  81. vh = (document.getElementById('videoWrapper').getAttribute('class') == 'large')? 640 : player.offsetHeight,
  82. 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,
  83. fh = window.innerHeight;
  84. sc = vd-((fh-vh)/2)
  85. scrollTo(0, sc)
  86. console.info("** ExtendYouPorn **\ntop: "+vd+", height: "+vh+", scrolled: "+sc+", window: "+fh)
  87. }
  88. // Inject this function to page
  89. var script = document.createElement("script")
  90. script.setAttribute("type", "text/javascript")
  91. script.innerHTML = scrollthere.toString() + "scrollthere();"
  92. script.id = "EYP-scrollVid"
  93. document.body.appendChild(script)
  94.  
  95. // Include button in right corner to center video on screen
  96. var node = document.createElement("div")
  97. 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;")
  98. node.setAttribute("onclick", "scrollthere();")
  99. node.innerHTML = "Center video"
  100. node.id = "EYP-scroll"
  101. document.body.appendChild(node)
  102. }
  103. },false)
  104.  
  105. function addStyle() {
  106. // While <head> is not loaded we keep trying
  107. if (!document.querySelector("head"))
  108. return setTimeout(addStyle, 50)
  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, #adblock_1 {\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. "video {\n\
  168. position: absolute;\n\
  169. }\n\
  170. #no_flash_player_message {\n\
  171. display: block !important;\n\
  172. }\n" +
  173. // User pages - Dashboard
  174. ".wrapTitle.grid_9 {\n\
  175. width: 100% !important;\n\
  176. }\n" +
  177. // Fix last element non-clickable on festive skins
  178. "#watchBottom {\n\
  179. position: relative;\n\
  180. z-index: 1;\n\
  181. }\n" +
  182. /* Channel pages */
  183. "#channelCanvas .grid_3 {\n\
  184. width: 25% !important;\n\
  185. }\n"
  186.  
  187. // Inject created CSS
  188. var eypnode = document.createElement("style")
  189. eypnode.type = "text/css"
  190. eypnode.id = "EYP-style"
  191. eypnode.appendChild(document.createTextNode(eypcss))
  192. document.head.appendChild(eypnode)
  193. }
  194. }();