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

38 lines
1.1 KiB
JavaScript
Raw Normal View History

2020-11-20 22:06:15 +00:00
// ==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);
}
2021-03-16 17:03:38 +00:00
var addControls = function()
2020-11-20 22:06:15 +00:00
{
2021-03-16 17:03:38 +00:00
var elements = document.getElementsByClassName("html5-main-video")
var index = 0
2020-11-20 22:06:15 +00:00
for (index = 0; index < elements.length; index++) {
2021-03-16 17:03:38 +00:00
var element = elements[index]
2020-11-20 22:06:15 +00:00
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; }')
2020-11-20 22:06:15 +00:00
setInterval(addControls,1000)
})