ExtendYouPorn

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

As of 2014-08-30. See the latest version.

  1. // ==UserScript==
  2. // @author Jack_mustang
  3. // @version 3.7
  4. // @name ExtendYouPorn
  5. // @description Remove ads, enlarges video, stops autoplay keeping buffering, fixes the overhaul style & block pop-ups
  6. // @date 2014 August 30
  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. addStyle()
  16.  
  17. window.addEventListener('DOMContentLoaded', function(){
  18. // Remove ads functions
  19. function removeQuery(query) {
  20. var ifr = document.querySelectorAll(query)
  21. if(ifr.length > 0)
  22. for(var i=0; i < ifr.length; i++)
  23. ifr[i].parentNode.removeChild(ifr[i])
  24. }
  25. // Advertisements
  26. removeQuery(".advertisement")
  27. // Remove right banners in video page
  28. removeQuery(".adSpace")
  29. // Remove footer ad in video page
  30. removeQuery(".advertisement_watchFooter")
  31. // Remove video bottom ad
  32. removeQuery(".ad-bottom")
  33. // Remove iframes because they are ads
  34. removeQuery("iframe")
  35.  
  36. // Set tooltips for the titles
  37. var titles = document.getElementsByClassName('videoTitle')
  38. if(titles.length > 0)
  39. for(i=0; i < titles.length; i++)
  40. titles[i].setAttribute('title', titles[i].innerHTML)
  41.  
  42. /* Video page */
  43. if(document.getElementById('videoContainer')) {
  44. // Change player
  45. var player = document.querySelector('#videoContainer').parentNode.innerHTML
  46. player = player.replace(/autoplay=true/g,"autoplay=false&autoload=true")
  47. player = player.replace(/disablePauseroll=false/g,"disablePauseroll=true")
  48. player = player.replace(/disable_sharebar=false/g,"disable_sharebar=true")
  49. player = player.replace(/&pauseroll_url=http:\/\/ads(.*).php/g,"")
  50. document.querySelector('#videoContainer').parentNode.innerHTML = player
  51.  
  52. // Scroll video to middle of page
  53. function scrollthere() {
  54. var player = document.getElementById('videoContainer'),
  55. vh = player.offsetHeight,
  56. 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,
  57. fh = window.innerHeight;
  58. sc = vd-((fh-vh)/2)
  59. scrollTo(0, sc)
  60. console.info("top: "+vd+", height: "+vh+", scrolled: "+sc+", window: "+fh)
  61. }
  62. // Inject this function to page
  63. var script = document.createElement("script")
  64. script.setAttribute("type", "text/javascript")
  65. script.innerHTML = scrollthere.toString() + "scrollthere();"
  66. script.id = "EYP-scrollVid"
  67. document.body.appendChild(script)
  68.  
  69. // Include button in right corner to center video on screen
  70. var node = document.createElement("div")
  71. 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;")
  72. node.setAttribute("onclick", "scrollthere();")
  73. node.innerHTML = "Center video"
  74. node.id = "EYP-scroll"
  75. document.body.appendChild(node)
  76. }
  77.  
  78. /* Channel page */
  79. if(document.getElementById('channelCanvas')) {
  80. var channelInfo = document.querySelector('#channelCanvas > .grid_5'),
  81. chnInfo = channelInfo.cloneNode(true)
  82. document.getElementById('channelCanvas').removeChild(channelInfo)
  83. document.querySelector('#channelCanvas > .grid_10').appendChild(chnInfo)
  84. }
  85. },false)
  86.  
  87. function addStyle() {
  88. // While <head> is not loaded we keep trying
  89. if (!document.querySelector("head"))
  90. return setTimeout(addStyle, 50)
  91.  
  92. // Block popups and let middle mouse click on thumbs open link
  93. function popupBlocker (event) {
  94. window.g367CB268B1094004A3689751E7AC568F = "EYP-Blocker"
  95. }
  96. var popblock = document.createElement("script")
  97. popblock.setAttribute("type", "text/javascript")
  98. popblock.id = "ERT-popupBlock"
  99. popblock.innerHTML = 'window.addEventListener("DOMContentLoaded", function blockPop() {\n'+
  100. 'var name = document.querySelectorAll(".te")\n'+
  101. 'if(name.length > 0)\n'+
  102. 'for(var i=0; i < name.length; i++)\n'+
  103. '$("#"+name[i].id).off("click")\n'+
  104. '}, false)\n'+
  105. 'window.addEventListener("DOMNodeInserted", '+ popupBlocker.toString() +', false)'
  106. var targ = document.head
  107. targ.appendChild(popblock)
  108.  
  109. // We create an object and start including its content to include in DOM at the end
  110. var eypcss =
  111. // Hide ads while we can't remove them
  112. ".advertisement, .adSpace, .advertisement_watchFooter, .ad-bottom, #videoCanvas .grid_5 {\n\
  113. display: none !important;\n\
  114. }\n" +
  115. // Fix ::selection
  116. "::selection {\n\
  117. background: #FFACC0;\n\
  118. color: #fff;\n\
  119. }\n\
  120. ::moz-selection {\n\
  121. background: #FFACC0;\n\
  122. color: #fff;\n\
  123. }\n" +
  124. // Videos Being Watched Right Now in one line
  125. ".videoList.vbwn ul {\n\
  126. margin: 0 !important;\n\
  127. width: 100% !important;\n\
  128. }\n\
  129. .videoList.count-6 ul li.videoBox.grid_3 {\n\
  130. margin: 0 10px 10px 0 !important;\n\
  131. }\n\
  132. .vbwn .omega {\n\
  133. display: none !important;\n\
  134. }\n\
  135. .videoList.count-6 ul .videoBox.grid_3:nth-child(5) {\n\
  136. margin-right: 0 !important;\n\
  137. }\n\
  138. .videoList.count-6.vbwn ul li.videoBox.grid_3:nth-child(4n) {\n\
  139. clear: none !important;\n\
  140. }\n\
  141. @media only screen and (max-width: 9999px) {\n\
  142. .videoList.count-6 ul li.videoBox.grid_3, [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3 {\n\
  143. margin: 0 1% 1% 0 !important;\n\
  144. }\n\
  145. }\n\
  146. @media only screen and (max-width: 1699px) and (min-width: 1280px) {\n\
  147. .videoList.count-6 ul li.videoBox.grid_3, [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3 {\n\
  148. width: 23.9% !important;\n\
  149. }\n\
  150. .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\
  151. margin-right: 0 !important;\n\
  152. }\n\
  153. .videoList ul li.videoBox.subscription.grid_3:last-child {\n\
  154. display: none;\n\
  155. }\n\
  156. }\n\
  157. @media only screen and (min-width: 1700px) {\n\
  158. .videoList.count-6 ul li.videoBox.grid_3, [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3 {\n\
  159. width: 18.9% !important;\n\
  160. }\n\
  161. [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3:nth-child(5n) {\n\
  162. margin-right: 0 !important;\n\
  163. }\n\
  164. }\n\
  165. /*.videoBox_6 {\n\
  166. display: none !important;\n\
  167. }\n*/" +
  168. /* Video page */
  169. // Enlarge video
  170. "#content, #videoCanvas {\n\
  171. position: static !important;\n\
  172. }\n\
  173. #videoWrapper {\n\
  174. display: block !important;\n\
  175. }\n\
  176. .container_15 .grid_10 {\n\
  177. width: 100% !important;\n\
  178. }\n\
  179. .container_15 #videoWrapper {\n\
  180. width: 90% !important;\n\
  181. max-width: 100% !important;\n\
  182. margin: auto !important;\n\
  183. }\n\
  184. #videoContainer {\n\
  185. min-height: 60em !important;\n\
  186. }\n\
  187. #categorizeSideBnt, #pornstarSideBnt {\n\
  188. border-radius: 12px !important;\n\
  189. }\n" +
  190. // User pages - Dashboard
  191. ".wrapTitle.grid_9 {\n\
  192. width: 100% !important;\n\
  193. }\n" +
  194. // Fix last element non-clickable on festive skins
  195. "#watchBottom {\n\
  196. position: relative;\n\
  197. z-index: 1;\n\
  198. }\n" +
  199. /* Channel pages */
  200. "#channelCanvas object {\n\
  201. width: 100% !important;\n\
  202. max-width: 100% !important;\n\
  203. }\n\
  204. #channelCanvas .grid_10 .grid_5.omega {\n\
  205. float: right;\n\
  206. }\n\
  207. #channelCanvas .videoList {\n\
  208. width: 67% !important;\n\
  209. display: inline-block !important;\n\
  210. }\n"
  211.  
  212. // Inject created CSS
  213. var eypnode = document.createElement("style")
  214. eypnode.type = "text/css"
  215. eypnode.id = "EYP-style"
  216. eypnode.appendChild(document.createTextNode(eypcss))
  217. document.head.appendChild(eypnode)
  218. }
  219. }();