ExtendYouPorn

Remove ads and makes the video better to be viewed. Stops autoplay keeping buffering. Auto-center video.

От 04.06.2014. Виж последната версия.

  1. // ==UserScript==
  2. // @author Jack_mustang
  3. // @version 3.6
  4. // @name ExtendYouPorn
  5. // @description Remove ads and makes the video better to be viewed. Stops autoplay keeping buffering. Auto-center video.
  6. // @date 2014 April 22
  7. // @include *youporn.com/*
  8. // @run-at document-start
  9. // @grant none
  10. // @icon http://public.bay.livefilestore.com/y1pSshvmSZkkqpfd9b6gp07U8-OpJIkZfKToFxXLn2M98janqOErccktUHWxF8gqQ6LdW5SrmzSRZONoPbE_YCaJw/ExtendYouPornIcon.png
  11. // @namespace https://greasyfork.org/users/2464
  12. // ==/UserScript==
  13. var ExtendYP = function ExtendYouPorn(){
  14. addStyle()
  15.  
  16. window.addEventListener('DOMContentLoaded', function(){
  17. // Remove ads functions
  18. function removeQuery(query) {
  19. var ifr = document.querySelectorAll(query)
  20. if(ifr.length > 0)
  21. for(var i=0; i < ifr.length; i++)
  22. ifr[i].parentNode.removeChild(ifr[i])
  23. }
  24. // Advertisements
  25. removeQuery(".advertisement")
  26. // Remove right banners in video page
  27. removeQuery(".adSpace")
  28. // Remove footer ad in video page
  29. removeQuery(".advertisement_watchFooter")
  30. // Remove video bottom ad
  31. removeQuery(".ad-bottom")
  32. // Remove iframes because they are ads
  33. removeQuery("iframe")
  34.  
  35. // Set tooltips for the titles
  36. var titles = document.getElementsByClassName('videoTitle')
  37. if(titles.length > 0)
  38. for(i=0; i < titles.length; i++)
  39. titles[i].setAttribute('title', titles[i].innerHTML)
  40.  
  41. /* Video page */
  42. if(document.getElementById('videoContainer')) {
  43. // Change player
  44. var player = document.querySelector('#videoContainer').parentNode.innerHTML
  45. player = player.replace(/autoplay=true/g,"autoplay=false&autoload=true")
  46. player = player.replace(/disablePauseroll=false/g,"disablePauseroll=true")
  47. player = player.replace(/disable_sharebar=false/g,"disable_sharebar=true")
  48. player = player.replace(/&pauseroll_url=http:\/\/ads(.*).php/g,"")
  49. document.querySelector('#videoContainer').parentNode.innerHTML = player
  50.  
  51. // Scroll video to middle of page
  52. function scrollthere() {
  53. var player = document.getElementById('videoContainer'),
  54. vh = player.offsetHeight,
  55. 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,
  56. fh = window.innerHeight;
  57. sc = vd-((fh-vh)/2)
  58. scrollTo(0, sc)
  59. console.info("top: "+vd+", height: "+vh+", scrolled: "+sc+", window: "+fh)
  60. }
  61. // Inject this function to page
  62. var script = document.createElement("script")
  63. script.setAttribute("type", "text/javascript")
  64. script.innerHTML = scrollthere.toString() + "scrollthere();"
  65. script.id = "EYP-scrollVid"
  66. document.body.appendChild(script)
  67.  
  68. // Include button in right corner to center video on screen
  69. var node = document.createElement("div")
  70. 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;")
  71. node.setAttribute("onclick", "scrollthere();")
  72. node.innerHTML = "Center video"
  73. node.id = "EYP-scroll"
  74. document.body.appendChild(node)
  75. }
  76. },false)
  77.  
  78. function addStyle() {
  79. // While <head> is not loaded we keep trying
  80. if (!document.querySelector("head"))
  81. return setTimeout(addStyle, 50)
  82.  
  83. // We create an object and start including its content to include in DOM at the end
  84. var eypcss =
  85. // Hide ads while we can't remove them
  86. ".advertisement, .adSpace, .advertisement_watchFooter, .ad-bottom {\n\
  87. display: none !important;\n\
  88. }\n" +
  89. // Fix ::selection
  90. "::selection {\n\
  91. background: #FFACC0;\n\
  92. color: #fff;\n\
  93. }\n\
  94. ::moz-selection {\n\
  95. background: #FFACC0;\n\
  96. color: #fff;\n\
  97. }\n" +
  98. // Videos Being Watched Right Now in one line
  99. ".videoList.count-6 ul .videoBox.grid_3.videoBox_4, .videoList.count-4 ul .videoBox.grid_3.videoBox_4 {\n\
  100. clear: none !important;\n\
  101. }\n\
  102. .videoList.vbwn ul {\n\
  103. margin: 0 !important;\n\
  104. width: 100% !important;\n\
  105. }\n\
  106. .videoBox_6 {\n\
  107. display: none !important;\n\
  108. }\n\
  109. @media only screen and (max-width:1279px) {\n\
  110. [data-current-action='browse'] .vbwn.videoList.count-6 ul .videoBox.grid_3.videoBox_4, [data-current-action='browse'] .vbwn.videoList.count-4 ul .videoBox.grid_3.videoBox_4, [data-current-action='browse'] .vbwn.videoList.count-6 ul .videoBox.grid_3.videoBox_5, [data-current-action='browse'] .vbwn.videoList.count-4 ul .videoBox.grid_3.videoBox_5, [data-current-action='category'] .vbwn.videoList.count-6 ul .videoBox.grid_3.videoBox_4, [data-current-action='external'] .vbwn.videoList.count-6 ul .videoBox.grid_3.videoBox_4, [data-current-action='porntags'] .vbwn.videoList.count-6 ul .videoBox.grid_3.videoBox_4, [data-current-action='category'] .vbwn.videoList.count-4 ul .videoBox.grid_3.videoBox_4, [data-current-action='external'] .vbwn.videoList.count-4 ul .videoBox.grid_3.videoBox_4, [data-current-action='porntags'] .vbwn.videoList.count-4 ul .videoBox.grid_3.videoBox_4, [data-current-action='category'] .vbwn.videoList.count-6 ul .videoBox.grid_3.videoBox_5, [data-current-action='external'] .vbwn.videoList.count-6 ul .videoBox.grid_3.videoBox_5, [data-current-action='porntags'] .vbwn.videoList.count-6 ul .videoBox.grid_3.videoBox_5, [data-current-action='category'] .vbwn.videoList.count-4 ul .videoBox.grid_3.videoBox_5, [data-current-action='external'] .vbwn.videoList.count-4 ul .videoBox.grid_3.videoBox_5, [data-current-action='porntags'] .vbwn.videoList.count-4 ul .videoBox.grid_3.videoBox_5 {\n\
  111. display: inline-block !important;\n\
  112. }\n\
  113. [data-current-action='browse'] .vbwn.videoList.count-6 ul .videoBox.grid_3, [data-current-action='browse'] .vbwn.videoList.count-4 ul .videoBox.grid_3, [data-current-action='category'] .vbwn.videoList.count-6 ul .videoBox.grid_3, [data-current-action='external'] .vbwn.videoList.count-6 ul .videoBox.grid_3, [data-current-action='porntags'] .vbwn.videoList.count-6 ul .videoBox.grid_3, [data-current-action='category'] .vbwn.videoList.count-4 ul .videoBox.grid_3, [data-current-action='external'] .vbwn.videoList.count-4 ul .videoBox.grid_3, [data-current-action='porntags'] .vbwn.videoList.count-4 ul .videoBox.grid_3 {\n\
  114. margin: 0 1% 1% 0 !important;\n\
  115. }\n\
  116. }\n\
  117. @media only screen and (max-width:9999px) {\n\
  118. [data-current-action='browse'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='browse'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='browse'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='browse'] .videoList.count-6 ul .videoBox.grid_3, [data-current-action='browse'] .videoList.count-4 ul .videoBox.grid_3, [data-current-action='browse'] .videoList.count-6 ul .videoBox.grid_3, [data-current-action='browse'] .videoList.count-4 ul .videoBox.grid_3, [data-current-action='category'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='external'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='recommended'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='favorites'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='search'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='advancedsearchrun'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='porntags'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='category'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='external'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='recommended'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='favorites'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='search'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='advancedsearchrun'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='porntags'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='category'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='external'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='recommended'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='favorites'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='search'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='advancedsearchrun'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='porntags'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='category'] .videoList.count-6 ul .videoBox.grid_3, [data-current-action='external'] .videoList.count-6 ul .videoBox.grid_3, [data-current-action='porntags'] .videoList.count-6 ul .videoBox.grid_3, [data-current-action='category'] .videoList.count-4 ul .videoBox.grid_3, [data-current-action='external'] .videoList.count-4 ul .videoBox.grid_3, [data-current-action='porntags'] .videoList.count-4 ul .videoBox.grid_3, [data-current-action='category'] .videoList.count-6 ul .videoBox.grid_3, [data-current-action='external'] .videoList.count-6 ul .videoBox.grid_3, [data-current-action='porntags'] .videoList.count-6 ul .videoBox.grid_3, [data-current-action='category'] .videoList.count-4 ul .videoBox.grid_3, [data-current-action='external'] .videoList.count-4 ul .videoBox.grid_3, [data-current-action='porntags'] .videoList.count-4 ul .videoBox.grid_3 {\n\ margin: 0 1% 1% 0 !important;\n\
  119. width: 23.7% !important;\n\
  120. }\n\
  121. }\n\
  122. @media only screen and (min-width:1700px) {\n\
  123. [data-current-action='browse'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='browse'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='browse'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='browse'] .videoList.count-6 ul .videoBox.grid_3, [data-current-action='browse'] .videoList.count-4 ul .videoBox.grid_3, [data-current-action='category'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='external'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='recommended'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='favorites'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='search'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='advancedsearchrun'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='porntags'] .vbwn.videoList ul li.videoBox.grid_3, [data-current-action='category'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='external'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='recommended'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='favorites'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='search'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='advancedsearchrun'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='porntags'] .videoList ul li.videoBox.grid_3.videoBox_3, [data-current-action='category'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='external'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='recommended'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='favorites'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='search'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='advancedsearchrun'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='porntags'] .videoList ul li.videoBox.grid_3.videoBox_6, [data-current-action='category'] .videoList.count-6 ul .videoBox.grid_3, [data-current-action='external'] .videoList.count-6 ul .videoBox.grid_3, [data-current-action='porntags'] .videoList.count-6 ul .videoBox.grid_3, [data-current-action='category'] .videoList.count-4 ul .videoBox.grid_3, [data-current-action='external'] .videoList.count-4 ul .videoBox.grid_3, [data-current-action='porntags'] .videoList.count-4 ul .videoBox.grid_3 {\n\
  124. margin: 0 .9% 1% 0 !important;\n\
  125. width: 18.1% !important;\n\
  126. }\n\
  127. }\n\
  128. [data-current-action='dashboard'] .videoList ul li.videoBox.grid_3 {\n\
  129. margin: 0 1% 1% 0 !important;\n\
  130. width: 18% !important;\n\
  131. }\n" +
  132. // Video titles bigger, 2 lines
  133. ".videoList ul li.videoBox.grid_3 .wrapping-video-box > a.videoTitle {\n\
  134. height: 2.9em !important;\n\
  135. }\n" +
  136. // Thumbnails in thumbs tab in video pages
  137. "#tab-thumbnails ul li {\n\
  138. height: auto !important;\n\
  139. width: 20% !important;\n\
  140. }\n" +
  141. /* Video page */
  142. // Enlarge video
  143. "#content, #videoCanvas {\n\
  144. position: static !important;\n\
  145. }\n\
  146. #videoWrapper {\n\
  147. display: block !important;\n\
  148. }\n\
  149. .container_15 .grid_10 {\n\
  150. width: 100% !important;\n\
  151. }\n\
  152. .container_15 #videoWrapper {\n\
  153. width: 90% !important;\n\
  154. max-width: 100% !important;\n\
  155. margin: auto !important;\n\
  156. }\n\
  157. #videoContainer {\n\
  158. min-height: 60em !important;\n\
  159. }\n\
  160. #categorizeSideBnt, #pornstarSideBnt {\n\
  161. border-radius: 12px !important;\n\
  162. }\n" +
  163. // User pages - Dashboard
  164. ".wrapTitle.grid_9 {\n\
  165. width: 100% !important;\n\
  166. }\n" +
  167. // Fix last element non-clickable on festive skins
  168. "#watchBottom {\n\
  169. position: relative;\n\
  170. z-index: 1;\n\
  171. }\n" +
  172. // Reccomended Videos
  173. "#watchBottom .folderContent .videoList {\n\
  174. min-height: 0 !important;\n\
  175. }\n" +
  176. /* Channel pages */
  177. "#channelCanvas object {\n\
  178. width: 100% !important;\n\
  179. max-width: 100% !important;\n\
  180. }\n\
  181. #channelCanvas .grid_5.omega {\n\
  182. float: right !important;\n\
  183. top: -840px;\n\
  184. height: 0;\n\
  185. position: relative;\n\
  186. }\n\
  187. #channelCanvas .videoList {\n\
  188. width: 67% !important;\n\
  189. display: inline-block !important;\n\
  190. }\n" +
  191. /* Studio Page */
  192. "#studioCanvas .grid_8 {\n\
  193. width: 100% !important;\n\
  194. }\n\
  195. #studioCanvas #videoWrapper {\n\
  196. height: auto !important;\n\
  197. }\n\
  198. .desktop .videoList ul li.videoBox.grid_3:nth-child(4n) {\n\
  199. margin-right: 1%;\n\
  200. }\n\
  201. .desktop .videoList ul li.videoBox.grid_3:nth-child(5n) {\n\
  202. margin-right: 0;\n\
  203. }\n"
  204.  
  205. // Inject created CSS
  206. var eypnode = document.createElement("style")
  207. eypnode.type = "text/css"
  208. eypnode.id = "EYP-style"
  209. eypnode.appendChild(document.createTextNode(eypcss))
  210. document.head.appendChild(eypnode)
  211. }
  212. }();