Greasy Fork 还支持 简体中文。

Resize Video To Window Size

Resize the video player for various sites to the window size.

目前為 2016-04-10 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Resize Video To Window Size
  3. // @description Resize the video player for various sites to the window size.
  4. // @author Chris H (Zren / Shade)
  5. // @namespace http://xshade.ca
  6. // @version 5
  7. // @include http://www.crunchyroll.com/*
  8. // @include https://docs.google.com/file/*
  9. // @include https://drive.google.com/drive/*
  10. // @include https://vimeo.com/*
  11. // @grant GM_addStyle
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. var fixedOverlayPlayer = function(selector) {
  16. var css = selector + "{";
  17. css += "position: fixed;";
  18. css += "top: 0;";
  19. css += "left: 0;";
  20. css += "right: 0;";
  21. css += "bottom: 0;";
  22. css += "}";
  23. GM_addStyle(css);
  24. };
  25. var topPlayer = function(videoBoxElement) {
  26. document.body.insertBefore(videoBoxElement, document.body.firstChild);
  27. videoBoxElement.style.width = '100%';
  28. videoBoxElement.style.height = '100%';
  29. videoBoxElement.style.backgroundColor = '#000';
  30. };
  31.  
  32. var urlMatch = function(regexStr) {
  33. regexStr = regexStr.replace(/\//g, '\\/'); // Auto escape forward slashes to make url regexes more legible.
  34. var regex = new RegExp(regexStr);
  35. return regex.exec(window.location.href);
  36. };
  37.  
  38. if (window.location.href.match(/^http:\/\/www\.crunchyroll\.(com|ca)\/.+\/.+-\d+\/?/)) {
  39. var videoBoxElement = document.getElementById('showmedia_video_box') || document.getElementById('showmedia_video_box_wide');
  40. if (!videoBoxElement) return;
  41. topPlayer(videoBoxElement);
  42. var css = 'html, body { width: 100%; height: 100%; }';
  43. css += '#showmedia_video_box, #showmedia_video_box_wide, #showmedia_video_player { width: 100%; height: calc(100vh + 32px) !important; }';
  44. GM_addStyle(css);
  45. } else if (document.location.href.startsWith('https://docs.google.com/file/')) {
  46. fixedOverlayPlayer('#drive-viewer-video-player-object-0');
  47. } else if (document.location.href.startsWith('https://drive.google.com/drive/')) {
  48. fixedOverlayPlayer('#drive-viewer-video-player-object-0');
  49. } else if (document.location.href.startsWith('https://vimeo.com/')) {
  50. var css = '.player_area-wrapper, .player_area, .player_container, .player, .video-wrapper, .video, .video * { width: 100vw !important; height: 100vh !important; max-height: 100vh !important; }';
  51. css += '.clip_main > *:not(.player_area-wrapper) { margin-top: 70px; }';
  52. css += '.body_ribbon, .topnav_desktop, .topnav_mobile { position: absolute; top: 100vh; width: 100%; }';
  53. css += '.topnav_desktop { top: calc(100vh + 5px); }';
  54. GM_addStyle(css);
  55. // autoplay
  56. function tick() {
  57. var e = document.querySelector('button.play[aria-label="Play"]');
  58. if (e) {
  59. e.click();
  60. } else {
  61. setTimeout(tick, 100);
  62. }
  63. }
  64. setTimeout(tick, 100);
  65. }
  66. })();