ExtendYouPorn

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

La data de 28-01-2015. Vezi ultima versiune.

  1. // ==UserScript==
  2. // @author Jack_mustang
  3. // @version 3.9.1
  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. // @include *youporngay.com/*
  9. // @run-at document-start
  10. // @grant none
  11. // @license Public Domain
  12. // @namespace 14fac5d83892686b90beea51d35d1d7dbcfe49b6
  13. // @icon https://gmgmla.dm2301.livefilestore.com/y2pYluU8jK3EnLV1U8D92pYCC9wU5O04Il4j64Ft_pjKGpUG_I5L0fUHrsLpUB4oDCLIJdWp9Bwmr0RPMdhJhl5Bo362RwjatCFUpNjEdMosGA/EYP-logo.jpg
  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. rightColumnNode = rightColumn.cloneNode(true)
  51. document.getElementById('videoCanvas').removeChild(rightColumn)
  52. document.querySelector('.left-column').appendChild(rightColumnNode)
  53.  
  54. // Change player
  55. var player = document.querySelector('#videoContainer').parentNode.innerHTML
  56. player = player.replace(/autoplay=true/g,"autoplay=false&autoload=true")
  57. player = player.replace(/disablePauseroll=false/g,"disablePauseroll=true")
  58. player = player.replace(/disable_sharebar=false/g,"disable_sharebar=true")
  59. player = player.replace(/&pauseroll_url=http:\/\/ads(.*).php/g,"")
  60. document.querySelector('#videoContainer').parentNode.innerHTML = player
  61.  
  62. // Scroll video to middle of page
  63. function scrollthere() {
  64. var player = document.getElementById('videoContainer'),
  65. vh = player.offsetHeight,
  66. 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,
  67. fh = window.innerHeight;
  68. sc = vd-((fh-vh)/2)
  69. scrollTo(0, sc)
  70. console.info("top: "+vd+", height: "+vh+", scrolled: "+sc+", window: "+fh)
  71. }
  72. // Inject this function to page
  73. var script = document.createElement("script")
  74. script.setAttribute("type", "text/javascript")
  75. script.innerHTML = scrollthere.toString() + "scrollthere();"
  76. script.id = "EYP-scrollVid"
  77. document.body.appendChild(script)
  78.  
  79. // Include button in right corner to center video on screen
  80. var node = document.createElement("div")
  81. 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;")
  82. node.setAttribute("onclick", "scrollthere();")
  83. node.innerHTML = "Center video"
  84. node.id = "EYP-scroll"
  85. document.body.appendChild(node)
  86. }
  87. },false)
  88.  
  89. function addStyle() {
  90. // While <head> is not loaded we keep trying
  91. if (!document.querySelector("head"))
  92. return setTimeout(addStyle, 50)
  93.  
  94. // Block popups and let middle mouse click on thumbs open link
  95. function popupBlocker (event) {
  96. window.g367CB268B1094004A3689751E7AC568F = "EYP-Blocker"
  97. }
  98. var popblock = document.createElement("script")
  99. popblock.setAttribute("type", "text/javascript")
  100. popblock.id = "ERT-popupBlock"
  101. popblock.innerHTML = 'window.addEventListener("DOMContentLoaded", function blockPop() {\n'+
  102. 'var name = document.querySelectorAll(".te")\n'+
  103. 'if(name.length > 0)\n'+
  104. 'for(var i=0; i < name.length; i++)\n'+
  105. '$("#"+name[i].id).off("click")\n'+
  106. '}, false)\n'+
  107. 'window.addEventListener("DOMNodeInserted", '+ popupBlocker.toString() +', false)'
  108. var targ = document.head
  109. targ.appendChild(popblock)
  110.  
  111. // We create an object and start including its content to include in DOM at the end
  112. var eypcss =
  113. // Hide ads while we can't remove them
  114. ".advertisement, .adSpace, .advertisement_watchFooter, .ad-bottom, #videoCanvas .grid_5 {\n\
  115. display: none !important;\n\
  116. }\n" +
  117. // Fix ::selection
  118. "::selection {\n\
  119. background: #FFACC0;\n\
  120. color: #fff;\n\
  121. }\n\
  122. ::moz-selection {\n\
  123. background: #FFACC0;\n\
  124. color: #fff;\n\
  125. }\n" +
  126. // Videos Being Watched Right Now in one line
  127. ".videoList.vbwn ul {\n\
  128. margin: 0 !important;\n\
  129. width: 100% !important;\n\
  130. }\n\
  131. .videoList.count-6 ul li.videoBox.grid_3 {\n\
  132. margin: 0 10px 10px 0 !important;\n\
  133. }\n\
  134. .vbwn .omega {\n\
  135. display: none !important;\n\
  136. }\n\
  137. .videoList.count-6 ul .videoBox.grid_3:nth-child(5) {\n\
  138. margin-right: 0 !important;\n\
  139. }\n\
  140. .videoList.count-6.vbwn ul li.videoBox.grid_3:nth-child(4n) {\n\
  141. clear: none !important;\n\
  142. }\n\
  143. @media only screen and (max-width: 9999px) {\n\
  144. .videoList.count-6 ul li.videoBox.grid_3, [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3 {\n\
  145. margin: 0 1% 1% 0 !important;\n\
  146. }\n\
  147. }\n\
  148. @media only screen and (max-width: 1699px) and (min-width: 1280px) {\n\
  149. .videoList.count-6 ul li.videoBox.grid_3, [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3 {\n\
  150. width: 23.9% !important;\n\
  151. }\n\
  152. .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\
  153. margin-right: 0 !important;\n\
  154. }\n\
  155. .videoList ul li.videoBox.subscription.grid_3:last-child {\n\
  156. display: none;\n\
  157. }\n\
  158. }\n\
  159. @media only screen and (min-width: 1700px) {\n\
  160. .videoList.count-6 ul li.videoBox.grid_3, [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3 {\n\
  161. width: 18.9% !important;\n\
  162. }\n\
  163. [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3:nth-child(5n) {\n\
  164. margin-right: 0 !important;\n\
  165. }\n\
  166. }\n" +
  167. /* Video page */
  168. // Enlarge video
  169. ".left-column, #videoCanvas #videoWrapper {\n\
  170. width: 100% !important;\n\
  171. }\n\
  172. .underplayer-tabs {\n\
  173. float: left;\n\
  174. }\n" +
  175. // User pages - Dashboard
  176. ".wrapTitle.grid_9 {\n\
  177. width: 100% !important;\n\
  178. }\n" +
  179. // Fix last element non-clickable on festive skins
  180. "#watchBottom {\n\
  181. position: relative;\n\
  182. z-index: 1;\n\
  183. }\n" +
  184. /* Channel pages */
  185. "#channelCanvas .grid_3 {\n\
  186. width: 25% !important;\n\
  187. }\n"
  188.  
  189. // Inject created CSS
  190. var eypnode = document.createElement("style")
  191. eypnode.type = "text/css"
  192. eypnode.id = "EYP-style"
  193. eypnode.appendChild(document.createTextNode(eypcss))
  194. document.head.appendChild(eypnode)
  195. }
  196. }();