ExtendYouPorn

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

Versión del día 06/04/2016. Echa un vistazo a la versión más reciente.

  1. // ==UserScript==
  2. // @author Jack_mustang
  3. // @version 4.2
  4. // @name ExtendYouPorn
  5. // @description Remove ads, enlarges video, stops autoplay keeping buffering, fixes the overhaul style & block pop-ups
  6. // @date 2016 April 6
  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. window.g367CB268B1094004A3689751E7AC568F = {
  27. Core: "stop mouse tracking and popups"
  28. }
  29.  
  30. var ExtendYP = function ExtendYouPorn(){
  31. // Pop-up killer, we trick YP to think we are old Presto Opera, this kills the pop-ups
  32. if (!window.opera)
  33. window.opera = true
  34.  
  35. addStyle()
  36. changePlayer()
  37.  
  38. window.addEventListener('DOMContentLoaded', function(){
  39. // Remove ads functions
  40. function removeQuery(query) {
  41. var ifr = document.querySelectorAll(query)
  42. if(ifr.length > 0)
  43. for(var i=0; i < ifr.length; i++)
  44. ifr[i].parentNode.removeChild(ifr[i])
  45. }
  46. // Remove iframes because they are ads
  47. removeQuery("iframe")
  48.  
  49. // Video page
  50. if(document.getElementById('videoContainer') || document.querySelector(".channelDetailWrapper")) {
  51. if (document.querySelector('.playWrapper'))
  52. document.querySelector('.playWrapper').setAttribute('class', 'playWrapper sixteen-column')
  53.  
  54. // Scroll and extra manipulation only after the elements exist
  55. videoStuff()
  56. }
  57. },false)
  58.  
  59. function videoStuff() {
  60. if (!(document.querySelector("#videoContainer embed") || document.querySelector("#videoContainer video") || document.querySelector("#videoContainer object")))
  61. return setTimeout(videoStuff, 50)
  62.  
  63. // Scroll video to middle of page
  64. function scrollthere() {
  65. var player = document.getElementById('videoContainer'),
  66. vh = player.offsetHeight,
  67. 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),
  68. fh = window.innerHeight;
  69. sc = vd-((fh-vh)/2)
  70. scrollTo(0, sc)
  71. console.info("** ExtendYouPorn **\ntop: "+vd+", height: "+vh+", scrolled: "+sc+", window: "+fh)
  72. }
  73. // Inject this function to page
  74. var script = document.createElement("script")
  75. script.setAttribute("type", "text/javascript")
  76. script.innerHTML = scrollthere.toString() + "scrollthere();"
  77. script.id = "EYP-scrollVid"
  78. document.body.appendChild(script)
  79.  
  80. // Keyboard Shortcut for centring
  81. window.addEventListener('keyup', function(e) {
  82. if(e.ctrlKey && e.altKey && (e.code === "KeyC" || (e.code === undefined && e.keyCode === 67)))
  83. scrollthere()
  84. }, false)
  85.  
  86. // Include button in right corner to center video on screen
  87. var node = document.createElement("div")
  88. 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;")
  89. node.setAttribute("onclick", "scrollthere();")
  90. 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)")
  91. node.innerHTML = "Center video"
  92. node.id = "EYP-scroll"
  93. document.body.appendChild(node)
  94. }
  95.  
  96. function changePlayer() {
  97. if (!document.getElementById('videoWrapper'))
  98. return setTimeout(changePlayer, 50)
  99.  
  100. var newflashvars = document.createElement("script")
  101. newflashvars.setAttribute("type", "text/javascript")
  102. newflashvars.id = "EYP-newflashvars"
  103. newflashvars.innerHTML =
  104. 'page_params.video.playerParams.autoplay = false;'+
  105. 'page_params.video.playerParams.autoload = true;'
  106. document.head.appendChild(newflashvars)
  107. }
  108.  
  109. function addStyle() {
  110. // While <head> is not loaded we keep trying
  111. if (!document.querySelector("head"))
  112. return setTimeout(addStyle, 50)
  113.  
  114. // We create an object and start including its content to include in DOM at the end
  115. var eypcss =
  116. // Hide ads while we can't remove them, the last hides the HTML5 player in-vid ads
  117. "#adblock_1, footer>div:not([class^=footer]), .eight-column+.eight-column, .container>.row:first-child+.row>.eight-column, .trafficjunky-float-right, .channel-header, .channelSideAd, .watchVideo>.four-column>div:first-child, .watchVideo>.four-column>div:first-child+div, .watchVideo>.four-column>div:first-child+div+div, #videoWrapper+aside, #pb_template, #recommended-videos-first-row+.eight-column {\n\
  118. display: none !important;\n\
  119. }\n\
  120. .eight-column, .eight-column .row, .nine-column, .nine-column .row, #recommended-videos-first-row .row {\n\
  121. width: 100% !important;\n\
  122. }\n\
  123. #recommended-videos-first-row {\n\
  124. width: 50% !important;\n\
  125. }\n\
  126. .nine-column .porn-star-list:last-child {\n\
  127. display: none !important;\n\
  128. }\n"
  129.  
  130. // Inject created CSS
  131. var eypnode = document.createElement("style")
  132. eypnode.type = "text/css"
  133. eypnode.id = "EYP-style"
  134. eypnode.appendChild(document.createTextNode(eypcss))
  135. document.head.appendChild(eypnode)
  136. }
  137. }();