// ==UserScript== // @name Resize Video To Window Size // @description Resize the video player for various sites to the window size. // @author Chris H (Zren / Shade) // @namespace http://xshade.ca // @version 8 // @include http://www.crunchyroll.com/* // @include https://docs.google.com/file/* // @include https://drive.google.com/drive/* // @include https://vimeo.com/* // @include http://onepieceofficial.com/videos.aspx* // @include http://www.onepieceofficial.com/videos.aspx* // @include http://eachvideo.com/watch* // @include http://olympics.cbc.ca/video/live/* // @grant GM_addStyle // @downloadURL none // ==/UserScript== (function() { var fixedOverlayPlayer = function(selector) { var css = selector + "{"; css += "position: fixed;"; css += "top: 0;"; css += "left: 0;"; css += "right: 0;"; css += "bottom: 0;"; css += "}"; GM_addStyle(css); }; var absoluteTopPlayer = function(selector, staticSelectors) { var css = selector + "{"; css += "position: absolute;"; css += "top: 0;"; css += "left: 0;"; css += "width: 100vw;"; css += "height: 100vh;"; css += "padding: 0;"; css += "margin: 0;"; css += "}"; css += "body {"; css += "margin-top: 100vh;"; css += "margin-top: 100vh;"; css += "padding-top: 0;"; css += "}"; if (staticSelectors) { css += staticSelectors + "{"; css += "position: static"; css += "}"; } GM_addStyle(css); }; var movedTopPlayer = function(videoBoxElement) { document.body.insertBefore(videoBoxElement, document.body.firstChild); videoBoxElement.style.width = '100%'; videoBoxElement.style.height = '100%'; videoBoxElement.style.backgroundColor = '#000'; }; var urlMatch = function(regexStr) { regexStr = regexStr.replace(/\//g, '\\/'); // Auto escape forward slashes to make url regexes more legible. var regex = new RegExp(regexStr); return regex.exec(window.location.href); }; if (window.location.href.match(/^http:\/\/www\.crunchyroll\.(com|ca)\/.+\/.+-\d+\/?/)) { var videoBoxElement = document.getElementById('showmedia_video_box') || document.getElementById('showmedia_video_box_wide'); if (!videoBoxElement) return; movedTopPlayer(videoBoxElement); var css = 'html, body { width: 100%; height: 100%; }'; css += '#showmedia_video_box, #showmedia_video_box_wide, #showmedia_video_player { width: 100%; height: calc(100vh + 32px) !important; }'; GM_addStyle(css); } else if (document.location.href.startsWith('https://docs.google.com/file/')) { fixedOverlayPlayer('#drive-viewer-video-player-object-0'); } else if (document.location.href.startsWith('https://drive.google.com/drive/')) { fixedOverlayPlayer('#drive-viewer-video-player-object-0'); } else if (document.location.href.startsWith('https://vimeo.com/')) { var css = '.player_area-wrapper, .player_area, .player_container, .player, .video-wrapper, .video, .video * { width: 100vw !important; height: 100vh !important; max-height: 100vh !important; }'; css += '.clip_main > *:not(.player_area-wrapper) { margin-top: 70px; }'; css += '.body_ribbon, .topnav_desktop, .topnav_mobile { position: absolute; top: 100vh; width: 100%; }'; css += '.topnav_desktop { top: calc(100vh + 5px); }'; GM_addStyle(css); // autoplay function tick() { var e = document.querySelector('button.play[aria-label="Play"]'); if (e) { e.click(); } else { setTimeout(tick, 100); } } setTimeout(tick, 100); } else if (document.location.host.endsWith('onepieceofficial.com')) { movedTopPlayer(document.querySelector('#FUNimationVideo')); } else if (document.location.host.endsWith('eachvideo.com')) { absoluteTopPlayer('.videoWrapper', '.navbar.navbar-default.navbar-fixed-top.bs-docs-nav, .col-md-8.row-border'); } else if (document.location.host == 'olympics.cbc.ca') { movedTopPlayer(document.querySelector('.cbc-video--player-wrapper')); function onResize() { var videoBoxElement = document.querySelector('.cbc-video--player-wrapper'); var height = 59 + window.innerWidth * 0.5625 + window.innerHeight * 0.06; if (height > window.innerHeight) { videoBoxElement.style.width = "calc((94vh - 59px) * 1.777777777)"; videoBoxElement.style.height = "100vh"; videoBoxElement.style.margin = '0 auto'; } else { videoBoxElement.style.width = "100vw"; videoBoxElement.style.height = "calc(59px + 56.25vw + 6vh)"; } } window.addEventListener('resize', onResize); onResize(); } })();