Crunchyroll: Resize Player To Window Size

Moves the video to the top of the website and resizes it to the screen size.

  1. // ==UserScript==
  2. // @name Crunchyroll: Resize Player To Window Size
  3. // @description Moves the video to the top of the website and resizes it to the screen size.
  4. // @author Chris H (Zren / Shade)
  5. // @icon http://crunchyroll.com/favicon.ico
  6. // @homepageURL http://userscripts.org/scripts/show/157272
  7. // @namespace http://xshade.ca
  8. // @version 1.1
  9. // @include http*://*.crunchyroll.c*/*
  10. // @include http*://crunchyroll.c*/*
  11. // ==/UserScript==
  12. (function() {
  13. // Can't use !important with javascript element.style.___ so we need to inject CSS.
  14. // http://stackoverflow.com/a/462603/947742
  15. function addNewStyle(newStyle) {
  16. var styleElement = document.getElementById('styles_js');
  17. if (!styleElement) {
  18. styleElement = document.createElement('style');
  19. styleElement.type = 'text/css';
  20. styleElement.id = 'styles_js';
  21. document.getElementsByTagName('head')[0].appendChild(styleElement);
  22. }
  23. styleElement.appendChild(document.createTextNode(newStyle));
  24. }
  25. var style = "html, body, #showmedia_video_box, #showmedia_video_box_wide, #showmedia_video_player { width: 100%; height: 100%; }";
  26. var videoBox = document.getElementById('showmedia_video_box') || document.getElementById('showmedia_video_box_wide');
  27. if (!videoBox) return;
  28. document.body.insertBefore(videoBox, document.body.firstChild);
  29. videoBox.style.width = '100%';
  30. videoBox.style.height = '100%';
  31. videoBox.style.backgroundColor = '#000';
  32. var videoPlayer = document.getElementById('showmedia_video_player');
  33. if (!videoPlayer) return;
  34. //var videoObject = videoBox.getElementsByTagName('object')[0];
  35. videoPlayer.width = '100%';
  36. videoPlayer.height = '100%';
  37. addNewStyle(style);
  38. })();