ExtendYouPorn

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

Versão de: 12/08/2016. Veja: a última versão.

  1. // ==UserScript==
  2. // @author Jack_mustang
  3. // @version 4.5
  4. // @name ExtendYouPorn
  5. // @description Remove ads, enlarges video, stops autoplay keeping buffering, fixes the overhaul style & block pop-ups
  6. // @date 2016 August 12
  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. // Block popups
  16. function NoOpen(e){return 1}
  17. parent.open=NoOpen;
  18. this.open=NoOpen;
  19. window.open=NoOpen;
  20. open=NoOpen;
  21. window.open = function(){return;}
  22. open = function(){return;}
  23. this.open = function(){return;}
  24. parent.open = function(){return;}
  25.  
  26. // Block ads
  27. window.__defineGetter__("adDelivery", function() {return null})
  28. window.__defineSetter__("adDelivery", function() {return null})
  29.  
  30. window.g367CB268B1094004A3689751E7AC568F = {
  31. Core: "stop mouse tracking and popups"
  32. }
  33. window.__defineSetter__("f8CB2C22AA84415BA2272F8261AED24C", function() {
  34. return "Seriously, STOP!"
  35. })
  36.  
  37. var ExtendYP = function ExtendYouPorn(){
  38. // Pop-up killer, we trick YP to think we are old Presto Opera, this kills the pop-ups
  39. if (!window.opera)
  40. window.opera = true
  41.  
  42. addStyle()
  43. changePlayer()
  44.  
  45. window.addEventListener('DOMContentLoaded', function(){
  46. // Remove ads functions
  47. function removeQuery(query) {
  48. var ifr = document.querySelectorAll(query)
  49. if(ifr.length > 0)
  50. for(var i=0; i < ifr.length; i++)
  51. ifr[i].parentNode.removeChild(ifr[i])
  52. }
  53. // Remove iframes because they are ads
  54. removeQuery("iframe")
  55.  
  56. // Video page
  57. if(document.getElementById('videoContainer') || document.querySelector(".channelDetailWrapper")) {
  58. if (document.querySelector('.playWrapper'))
  59. document.querySelector('.playWrapper').setAttribute('class', 'playWrapper sixteen-column')
  60.  
  61. // Scroll and extra manipulation only after the elements exist
  62. videoStuff()
  63. }
  64. },false)
  65.  
  66. function videoStuff() {
  67. if (!(document.querySelector("#videoContainer embed") || document.querySelector("#videoContainer video") || document.querySelector("#videoContainer object")))
  68. return setTimeout(videoStuff, 50)
  69.  
  70. // Scroll video to middle of page
  71. function scrollthere() {
  72. var player = document.getElementById('videoContainer'),
  73. vh = player.offsetHeight,
  74. vd = ((document.querySelector("#network-bar").offsetHeight > 0) ? 0 : 25) + ((player.parentNode.offsetTop == 0)? ((document.querySelector('#studioCanvas'))? document.querySelector('.grid_8.alpha').offsetTop : document.querySelector('.watchWrapper').offsetTop+document.querySelector('#videoCanvas').offsetTop ) : player.parentNode.offsetTop),
  75. fh = window.innerHeight;
  76. sc = vd-((fh-vh)/2)
  77. scrollVid(0, sc)
  78. //console.info("** ExtendYouPorn **\ntop: "+vd+", height: "+vh+", scrolled: "+sc+", window: "+fh)
  79. }
  80. // Inject this function to page
  81. var script = document.createElement("script")
  82. script.setAttribute("type", "text/javascript")
  83. script.innerHTML = "window.scrollVid = window.scrollTo; " + scrollthere.toString() + " scrollthere();"
  84. script.id = "EYP-scrollVid"
  85. document.body.appendChild(script)
  86.  
  87. // Keyboard Shortcut for centring
  88. window.addEventListener('keyup', function(e) {
  89. if(e.ctrlKey && e.altKey && (e.code === "KeyC" || (e.code === undefined && e.keyCode === 67)))
  90. scrollthere()
  91. }, false)
  92.  
  93. // Include button in right corner to center video on screen
  94. var node = document.createElement("div")
  95. node.setAttribute("style","position: fixed; bottom: 0; right: 0; cursor: pointer; color: #fff; text-transform: uppercase; background: #ec567c; text-align: center; font-size: 1.2em; padding: 7px;z-index: 999999;")
  96. node.setAttribute("onclick", "scrollthere();")
  97. node.setAttribute("title", "Use the keyboard shortcut Ctrl+Alt+C (For other keyboard layouts use the key where C should be on the QWERTY layout)")
  98. node.innerHTML = "Center video"
  99. node.id = "EYP-scroll"
  100. document.body.appendChild(node)
  101. }
  102.  
  103. function changePlayer() {
  104. if (!document.getElementById('videoWrapper'))
  105. return setTimeout(changePlayer, 50)
  106.  
  107. var newflashvars = document.createElement("script")
  108. newflashvars.setAttribute("type", "text/javascript")
  109. newflashvars.id = "EYP-newflashvars"
  110. newflashvars.innerHTML =
  111. 'page_params.video.playerParams.autoplay = false;'+
  112. 'page_params.video.playerParams.autoload = true;'
  113. document.head.appendChild(newflashvars)
  114. }
  115.  
  116. function addStyle() {
  117. // While <head> is not loaded we keep trying
  118. if (!document.querySelector("head"))
  119. return setTimeout(addStyle, 50)
  120.  
  121. // We create an object and start including its content to include in DOM at the end
  122. var eypcss =
  123. // Hide ads while we can't remove them
  124. "iframe, figure, aside," +
  125. // Ad spaces
  126. ".row > .eight-column > div:not(.row), .trafficjunky-float-right," +
  127. // Remove Ads links, Ads by TrafficJunkie notice
  128. ".ad-remove, .ad-bottom-text, .ad-links-text," +
  129. // Ad block message
  130. "#adblock_1," +
  131. // Pornstars page, pornstars in one line
  132. ".nine-column .porn-star-list:last-child {\
  133. display: none !important;\
  134. }" +
  135. // vids in one line, on pornstars page
  136. "div.eight-column:not(.title-select), div.eight-column .row,\
  137. .nine-column, .nine-column .row {\
  138. width: 100% !important;\
  139. }" +
  140. // Remove ad space on pornstar page
  141. "body[data-current-action=pornstar] div.twelve-column > .row:first-child {\
  142. float: left;\
  143. width: auto;\
  144. }"
  145.  
  146. // Inject created CSS
  147. var eypnode = document.createElement("style")
  148. eypnode.type = "text/css"
  149. eypnode.id = "EYP-style"
  150. eypnode.appendChild(document.createTextNode(eypcss))
  151. document.head.appendChild(eypnode)
  152. }
  153. }();