ExtendXVideos

Remove ads, enlarge video, auto-centre video & block pop-ups

  1. // ==UserScript==
  2. // @author Jack_mustang
  3. // @version 1.0
  4. // @name ExtendXVideos
  5. // @description Remove ads, enlarge video, auto-centre video & block pop-ups
  6. // @date 2016 January 27
  7. // @include *xvideos.com/*
  8. // @run-at document-start
  9. // @grant none
  10. // @license Public Domain
  11. // @icon https://szvicq-dm2306.files.1drv.com/y3mUIY4UTuouBPHkXB4lw5qpXPSuf83fD-35aldAlxuWGjVUt0WEP8WQsZRV_-QcAsN5cKkWUFdZl6afpyfGNDpC1uFbsy3MSTftxjKzUnk1ZmCJemVtOTtS08eFYfEElGYwBcZbwE3tEescW3q7wEq7TMy0eGe8DmOYzWOD2qd5gM?width=145&height=145&cropmode=none
  12. // @namespace 88769cc55590fe09dfd8445da5193c9537a2d02c
  13. // ==/UserScript==
  14.  
  15. // Disable 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. (function extendXVideos() {
  27. var proxied = window.XMLHttpRequest.prototype.open;
  28. window.XMLHttpRequest.prototype.open = function() {
  29. // Allow video download logged out
  30. if (!window.xv.conf.data.login_info.is_logged && arguments[1].match(/video-download/)) {
  31. this.onreadystatechange = function() {
  32. Object.defineProperty(this, "responseText", {writable: true});
  33. var message = {
  34. "LOGGED": true,
  35. "URL": html5player.url_high,
  36. "URL_LOW": html5player.url_low
  37. };
  38. this.responseText = JSON.stringify(message);
  39. }
  40. return proxied.apply(this, [].slice.call(arguments));
  41. }
  42. // Block ads, allow from xvideos.com
  43. if (arguments[1].match(/^\/\w|xvideos\.com\//)) {
  44. return proxied.apply(this, [].slice.call(arguments));
  45. }
  46. return false;
  47. }
  48. // Page modification without CSS
  49. window.addEventListener("DOMContentLoaded", function() {
  50. // More tiles in pages that had side ads
  51. if (document.querySelector(".mozaique:not(.thumbs-4)")) {
  52. document.querySelector(".mozaique:not(.thumbs-4)").className = "mozaique thumbs-4";
  53. }
  54. // Scroll to center video
  55. if (document.querySelector("body > #page.video-page")) {
  56. document.querySelector("#page.video-page #content").className = "player-enlarged";
  57.  
  58. function scrollthere() {
  59. var vid = document.querySelector("#content"),
  60. vh = vid.offsetHeight,
  61. vd = vid.offsetTop,
  62. fh = window.innerHeight,
  63. sc = vd-((fh-vh)/2)
  64. console.log(vd)
  65. scrollTo(0, sc)
  66. }// Now inject this function
  67. var script = document.createElement("script")
  68. script.setAttribute("type","text/javascript")
  69. script.innerHTML = scrollthere.toString() + "scrollthere();"
  70. script.id = ("ERT-scrollVid")
  71. document.head.appendChild(script)
  72.  
  73. // Keyboard Shortcut for centring
  74. window.addEventListener("keyup", function(e) {
  75. if(e.ctrlKey && e.altKey && (e.code === "KeyC" || (e.code === undefined && e.keyCode === 67)))
  76. scrollthere()
  77. }, false)
  78.  
  79. // Include button in right corner to center video on screen;
  80. var node = document.createElement("div")
  81. node.setAttribute("style", "position:fixed; bottom:0; right:0; cursor:pointer; background:#f2f2f2; padding:5px 10px; border:1px solid #d9d9d9; border-top-left-radius: 5px; z-index: 10000")
  82. node.setAttribute("onclick", "scrollthere();")
  83. node.setAttribute("title", "Ctrl+Alt+C (Other layouts use the key where C would be on the QWERTY layout)")
  84. node.innerHTML = "Centre"
  85. document.body.appendChild(node)
  86. }
  87. });
  88. }());
  89.  
  90. // Inject CSS to modify page
  91. (function addStyle() {
  92. // While <head> is not loaded we keep trying
  93. if (!document.querySelector("head")) {
  94. return setTimeout(addStyle, 50);
  95. }
  96.  
  97. // We create an object and start including its content to include in DOM at the end.
  98. var exvcss =
  99. ".pagination ul {\
  100. display: table;\
  101. margin: auto;\
  102. font-size: 2em;\
  103. }\
  104. #main > div[id].mobile-hide:not([id=content]),\
  105. #content > div.mobile-hide:first-child,\
  106. .sponsor_popup {\
  107. display: none;\
  108. }";
  109. var exvnode = document.createElement("style");
  110. exvnode.type = "text/css";
  111. exvnode.id = "EAST-style";
  112. exvnode.appendChild(document.createTextNode(exvcss));
  113. document.head.appendChild(exvnode);
  114. }());