YouTube Watch Page Return

Resizes Youtube player to the old, smaller configuration

当前为 2014-11-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name YouTube Watch Page Return
  3. // @namespace http://users.atw.hu/geriboss
  4. // @description Resizes Youtube player to the old, smaller configuration
  5. // @include https://www.youtube.com/watch*
  6. // @include http://www.youtube.com/watch*
  7. // @version 1.9
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. //For more information about this script, visit https://github.com/GeriBoss/youtube_smaller
  12. // or watch the tutorial video: https://www.youtube.com/watch?v=jJus7CQvfqc
  13.  
  14. runScript();
  15.  
  16. //Chrome (or Tampermonkey) has a bug which prevents the script from running properly.
  17. //This code checks for the bug every half a second and corrects it
  18. setInterval(function(){
  19. if (document.getElementById('watch7-content').style.width != '640px')
  20. runScript();
  21. }, 500);
  22.  
  23. function runScript(){
  24. document.getElementById('player').style.width = '1040px';
  25. document.getElementById('watch7-content').style.width = '640px';
  26. document.getElementById('content').style.maxWidth = '1040px';
  27. document.getElementById('watch7-sidebar').style.top = '0px';
  28. document.getElementById('watch7-sidebar').style.marginLeft = '640px';
  29. document.getElementById('watch7-sidebar-contents').style.minHeight = '390px';
  30. var i, nodes = document.getElementsByClassName('action-panel-content');
  31. for (i = 0; i < nodes.length; i++)
  32. nodes[i].style.width = '600px';
  33. nodes = document.getElementsByClassName('player-width');
  34. for (i = 0; i < nodes.length; i++)
  35. nodes[i].style.width = '640px';
  36. nodes = document.getElementsByClassName('player-height');
  37. for (i = 0; i < nodes.length; i++)
  38. nodes[i].style.height = '390px';
  39. document.getElementById('theater-background').style.height = '520px';
  40. nodes = document.getElementsByClassName('watch-playlist');
  41. for (i = 0; i < nodes.length; i++)
  42. nodes[i].style.minHeight = '390px';
  43. nodes = document.getElementsByClassName('playlist-videos-list');
  44. for (i = 0; i < nodes.length; i++)
  45. nodes[i].style.maxHeight = '290px';
  46. }
  47.  
  48. window.addEventListener("popstate",function(e){
  49. JS();
  50. });
  51. function JS(){
  52. var script = document.createElement("script");
  53. script.type = "text/javascript";
  54. script.textContent = 'document.createElement("video").constructor.prototype.canPlayType = function(type){return ""}';
  55. document.documentElement.appendChild(script);
  56. }
  57. JS();