sirx / Video-Js for Chrome

// ==UserScript==
// @name         Video-Js for Chrome
// @namespace    https://openuserjs.org
// @version      0.1
// @description  Because Chromium Devs don't know what a decent video player looks like
// @author       sirx
// @run-at       document-start
// @copyright    2018 sirx
// @include      *mp4
// @include      *webm
// @nocompat     Chrome
// @grant        GM_addStyle
// @license      MIT
// ==/UserScript==

(function () {
  'use strict';

  GM_addStyle(".vjs-chrome { position: absolute!important; top: 0px; right: 0px; bottom: 0px; left: 0px; max-height: 100%; max-width: 100%; margin: auto; }");

  (function () {
    var scriptElement = document.createElement("script");
    scriptElement.type = "text/javascript";
    scriptElement.src = "https://vjs.zencdn.net/7.0.3/video.js";
    document.head.appendChild(scriptElement);
  })();

  var cssId = 'myCss';
  if (!document.getElementById(cssId)) {
    var head = document.getElementsByTagName('head')[0];
    var link = document.createElement('link');
    link.id = cssId;
    link.rel = 'stylesheet';
    link.type = 'text/css';
    link.href = 'https://vjs.zencdn.net/7.0.3/video-js.css';
    link.media = 'all';
    head.appendChild(link);
  }

  var vid = document.querySelector("video");
  vid.volume = 0.2;
  vid.autoplay = true;
  //vid.controls = false;
  vid.loop = true;

  vid.setAttribute("class", "video-js vjs-chrome");
  vid.setAttribute("data-setup", "{ autoplay: true }");
})();