ExtendYouPorn

Remove ads, enlarges video and stops autoplay keeping buffering

اعتبارا من 05-06-2014. شاهد أحدث إصدار.

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