Resize Video To Window Size

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

当前为 2015-07-06 提交的版本,查看 最新版本

  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 3
  7. // @include http://www.crunchyroll.com/*
  8. // @include https://docs.google.com/file/*
  9. // @include https://drive.google.com/drive/*
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. var fixedOverlayPlayer = function(selector) {
  14. var css = selector + "{";
  15. css += "position: fixed;";
  16. css += "top: 0;";
  17. css += "left: 0;";
  18. css += "right: 0;";
  19. css += "bottom: 0;";
  20. css += "}";
  21. GM_addStyle(css);
  22. };
  23. var topPlayer = function(videoBoxElement) {
  24. document.body.insertBefore(videoBoxElement, document.body.firstChild);
  25. videoBoxElement.style.width = '100%';
  26. videoBoxElement.style.height = '100%';
  27. videoBoxElement.style.backgroundColor = '#000';
  28. };
  29.  
  30. var urlMatch = function(regexStr) {
  31. regexStr = regexStr.replace(/\//g, '\\/'); // Auto escape forward slashes to make url regexes more legible.
  32. var regex = new RegExp(regexStr);
  33. return regex.exec(window.location.href);
  34. };
  35.  
  36. if (window.location.href.match(/^http:\/\/www\.crunchyroll\.(com|ca)\/.+\/.+-\d+\/?/)) {
  37. var videoBoxElement = document.getElementById('showmedia_video_box') || document.getElementById('showmedia_video_box_wide');
  38. if (!videoBoxElement) return;
  39. topPlayer(videoBoxElement);
  40. var css = 'html, body { width: 100%; height: 100%; }';
  41. css += '#showmedia_video_box, #showmedia_video_box_wide, #showmedia_video_player { width: 100%; height: 100%; }';
  42. GM_addStyle(css);
  43. } else if (document.location.href.startsWith('https://docs.google.com/file/')) {
  44. fixedOverlayPlayer('#drive-viewer-video-player-object-0');
  45. } else if (document.location.href.startsWith('https://drive.google.com/drive/')) {
  46. fixedOverlayPlayer('#drive-viewer-video-player-object-0');
  47. }
  48. })();