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