ExtendYouPorn

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

Verzia zo dňa 19.08.2016. Pozri najnovšiu verziu.

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