ExtendYouPorn

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

Pada tanggal 14 Juli 2015. Lihat %(latest_version_link).

  1. // ==UserScript==
  2. // @author Jack_mustang
  3. // @version 3.11
  4. // @name ExtendYouPorn
  5. // @description Remove ads, enlarges video, stops autoplay keeping buffering, fixes the overhaul style & block pop-ups
  6. // @date 2015 July 14
  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. // Change player
  55. var player = document.getElementById('videoContainer'),
  56. vidId = parseInt(videoJason.video_id),
  57. newflashvars = document.createElement("script")
  58. newflashvars.setAttribute("type", "text/javascript")
  59. newflashvars.id = "EYP-newflashvars"
  60. newflashvars.innerHTML =
  61. 'flashvars['+vidId+'].autoplay = false;'+
  62. 'flashvars['+vidId+'].autoload = true;'+
  63. 'flashvars['+vidId+'].disablePauseroll = true;'
  64. player.insertBefore(newflashvars, player.childNodes[0])
  65.  
  66. // Scroll video to middle of page
  67. function scrollthere() {
  68. var player = document.getElementById('videoContainer'),
  69. vh = (document.getElementById('videoWrapper').getAttribute('class') == 'large')? 640 : player.offsetHeight,
  70. 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,
  71. fh = window.innerHeight;
  72. sc = vd-((fh-vh)/2)
  73. scrollTo(0, sc)
  74. console.info("** ExtendYouPorn **\ntop: "+vd+", height: "+vh+", scrolled: "+sc+", window: "+fh)
  75. }
  76. // Inject this function to page
  77. var script = document.createElement("script")
  78. script.setAttribute("type", "text/javascript")
  79. script.innerHTML = scrollthere.toString() + "scrollthere();"
  80. script.id = "EYP-scrollVid"
  81. document.body.appendChild(script)
  82.  
  83. // Include button in right corner to center video on screen
  84. var node = document.createElement("div")
  85. 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;")
  86. node.setAttribute("onclick", "scrollthere();")
  87. node.innerHTML = "Center video"
  88. node.id = "EYP-scroll"
  89. document.body.appendChild(node)
  90. }
  91. },false)
  92.  
  93. function addStyle() {
  94. // While <head> is not loaded we keep trying
  95. if (!document.querySelector("head"))
  96. return setTimeout(addStyle, 50)
  97.  
  98. // We create an object and start including its content to include in DOM at the end
  99. var eypcss =
  100. // Hide ads while we can't remove them
  101. ".advertisement, .adSpace, .advertisement_watchFooter, .ad-bottom, #videoCanvas .grid_5, #adblock_1 {\n\
  102. display: none !important;\n\
  103. }\n" +
  104. // Fix ::selection
  105. "::selection {\n\
  106. background: #FFACC0;\n\
  107. color: #fff;\n\
  108. }\n\
  109. ::moz-selection {\n\
  110. background: #FFACC0;\n\
  111. color: #fff;\n\
  112. }\n" +
  113. // Videos Being Watched Right Now in one line
  114. ".videoList.vbwn ul {\n\
  115. margin: 0 !important;\n\
  116. width: 100% !important;\n\
  117. }\n\
  118. .videoList.count-6 ul li.videoBox.grid_3 {\n\
  119. margin: 0 10px 10px 0 !important;\n\
  120. }\n\
  121. .vbwn .omega {\n\
  122. display: none !important;\n\
  123. }\n\
  124. .videoList.count-6 ul .videoBox.grid_3:nth-child(5) {\n\
  125. margin-right: 0 !important;\n\
  126. }\n\
  127. .videoList.count-6.vbwn ul li.videoBox.grid_3:nth-child(4n) {\n\
  128. clear: none !important;\n\
  129. }\n\
  130. @media only screen and (max-width: 9999px) {\n\
  131. .videoList.count-6 ul li.videoBox.grid_3, [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3 {\n\
  132. margin: 0 1% 1% 0 !important;\n\
  133. }\n\
  134. }\n\
  135. @media only screen and (max-width: 1699px) and (min-width: 1280px) {\n\
  136. .videoList.count-6 ul li.videoBox.grid_3, [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3 {\n\
  137. width: 23.9% !important;\n\
  138. }\n\
  139. .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\
  140. margin-right: 0 !important;\n\
  141. }\n\
  142. .videoList ul li.videoBox.subscription.grid_3:last-child {\n\
  143. display: none;\n\
  144. }\n\
  145. }\n\
  146. @media only screen and (min-width: 1700px) {\n\
  147. .videoList.count-6 ul li.videoBox.grid_3, [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3 {\n\
  148. width: 18.9% !important;\n\
  149. }\n\
  150. [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3:nth-child(5n) {\n\
  151. margin-right: 0 !important;\n\
  152. }\n\
  153. }\n" +
  154. // Video page
  155. "#no_flash_player_message {\n\
  156. display: block !important;\n\
  157. }\n" +
  158. // User pages - Dashboard
  159. ".wrapTitle.grid_9 {\n\
  160. width: 100% !important;\n\
  161. }\n" +
  162. // Fix last element non-clickable on festive skins
  163. "#watchBottom {\n\
  164. position: relative;\n\
  165. z-index: 1;\n\
  166. }\n" +
  167. /* Channel pages */
  168. "#channelCanvas .grid_3 {\n\
  169. width: 25% !important;\n\
  170. }\n"
  171.  
  172. // Inject created CSS
  173. var eypnode = document.createElement("style")
  174. eypnode.type = "text/css"
  175. eypnode.id = "EYP-style"
  176. eypnode.appendChild(document.createTextNode(eypcss))
  177. document.head.appendChild(eypnode)
  178. }
  179. }();