wide video container on youtube
当前为
// ==UserScript==
// @name Youtube - Wide video container
// @namespace 1N07
// @author 1N07
// @icon https://i.imgur.com/VgEiyi3.png
// @description wide video container on youtube
// @include https://www.youtube.com/*
// @version 1.7.3
// @grant GM_registerMenuCommand
// @grant GM_unregisterMenuCommand
// @grant GM_getValue
// @grant GM_setValue
// ==/UserScript==
(function() {
var FPPHandle;
var FPPCompOn = GM_getValue("FPPCompOn", false);
SetFPPHandle();
var ForceCSSHandle;
var ForceCSSOn = GM_getValue("ForceCSSOn", false);
SetForceCSSHandle();
if(!!document.getElementById("early-body")) { //if old youtube
document.getElementById("content").setAttribute("style", "width: 99%;");
} else { //new youtube
addGlobalStyle(`
ytd-app #page-manager > ytd-browse:not([page-subtype="playlist"]) ytd-two-column-browse-results-renderer.ytd-browse
{
box-sizing: border-box`+(ForceCSSOn ? `!important`:``)+`;
width: auto`+(ForceCSSOn ? `!important`:``)+`;
margin: 10px`+(ForceCSSOn ? `!important`:``)+`;
}
`);
console.log("Youtube Wide video container style added to DOM");
if(FPPCompOn) {
addGlobalStyle(`
/*========== Fade++ Compatibility ==========*/
ytd-app #page-manager > ytd-browse:not([page-subtype="playlist"]) {
display: block;
}
ytd-app[guide-persistent-and-visible] #page-manager > ytd-browse:not([page-subtype="playlist"]) ytd-two-column-browse-results-renderer.ytd-browse
{
margin-left: 250px !important;
}
`);
console.log("Youtube Wide video container Fade++ compatibilty style added to DOM");
}
}
function SetFPPHandle() {
GM_unregisterMenuCommand(FPPHandle);
FPPHandle = GM_registerMenuCommand("Fade++ Compatibility mode (" + (FPPCompOn ? "On" : "Off") + ") -click to change-", function(){
FPPCompOn = !FPPCompOn;
GM_setValue("FPPCompOn", FPPCompOn);
SetFPPHandle();
if(confirm('Press "OK" to refresh the page to apply new settings'))
location.reload();
});
}
function SetForceCSSHandle() {
GM_unregisterMenuCommand(ForceCSSHandle);
ForceCSSHandle = GM_registerMenuCommand("CSS important rule mode (" + (ForceCSSOn ? "On" : "Off") + ") -click to change-", function(){
ForceCSSOn = !ForceCSSOn;
GM_setValue("ForceCSSOn", ForceCSSOn);
SetForceCSSHandle();
if(confirm('Press "OK" to refresh the page to apply new settings'))
location.reload();
});
}
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);
}
})();