fiers-grease/YouTube Mobile - Native con...

38 lines
1.1 KiB
JavaScript

// ==UserScript==
// @name YouTube Mobile - Native controls
// @namespace youtube-nativectl
// @description Changes the video controls to your browser's native ones
// @include http://m.youtube.com/*
// @include https://m.youtube.com/*
// @version 1.0
// @grant none
// @run-at document-start
// ==/UserScript==
function addGlobalStyle(css) {
var head, style;
head = document.getElementsByTagName('head')[0];
if (!head) { return; }
style = document.createElement('style');
style.type = 'text/css';
style.innerHTML = css;
head.appendChild(style);
}
var addControls = function()
{
var elements = document.getElementsByClassName("html5-main-video")
var index = 0
for (index = 0; index < elements.length; index++) {
var element = elements[index]
if (element.getAttribute("controls") == null) {
element.setAttribute("controls","")
}
}
}
document.addEventListener("DOMContentLoaded", function() {
addGlobalStyle('#player-control-overlay { display: none !important }\n.ytp-autohide { cursor: auto !important }\n.player-controls-background { display: none !important; }')
setInterval(addControls,1000)
})