// ==UserScript==
// @name Youtube Fix
// @namespace http://tampermonkey.net/
// @version 1.1.1
// @description Helps removing garbage from your recommended videos, adds a scrollbar for videos while watching
// @author Bum
// @require http://code.jquery.com/jquery-3.4.1.min.js
// @grant GM_addStyle
// @match https://www.youtube.com/*
// @downloadURL none
// ==/UserScript==
var currentVideoId = "";
var exclusionListFix = null;
var betterBackgroundColour = "#212121";
var removeVideoBackground = true;
if (localStorage.getItem("excludeVideosFromYoutube") != null) {
exclusionListFix = localStorage.getItem("excludeVideosFromYoutube").toUpperCase().split(";");
}
if (localStorage.getItem("backgroundColourFix") != null) {
betterBackgroundColour = localStorage.getItem("backgroundColourFix");
document.querySelector(':root').style.setProperty('--yt-spec-base-background', betterBackgroundColour);
}
if (localStorage.getItem("removeVideoBackground") != null) {
betterBackgroundColour = localStorage.getItem("removeVideoBackground");
removeCinematics('none');
}
else{
removeVideoBackground = false;
}
function removeCinematics(display){
GM_addStyle(`
#cinematics{
display:` + display +` !important;
}
`);
}
jQuery(document).ready(_main);
function _addScrollBarComments() {
var isReady = $("ytd-comment-thread-renderer").length > 0;
if (!isReady) {
setTimeout(_addScrollBarComments, 500);
return;
}
jQuery("#comments").wrap("
");
$('div.scrollbar').bind('mousewheel DOMMouseScroll', function(e) {
var scrollTo = null;
if (e.type == 'mousewheel') {
scrollTo = (e.originalEvent.wheelDelta * -1);
} else if (e.type == 'DOMMouseScroll') {
scrollTo = 40 * e.originalEvent.detail;
}
if (scrollTo) {
$("#items").trigger( "mouseover" );
$("ytd-compact-video-renderer").trigger( "mouseover" );
$("ytd-thumbnail").trigger( "mouseover" );
$(".yt-simple-endpoint").trigger( "mouseover" );
$(".ytd-compact-video-renderer").trigger( "mouseover" );
$(".secondary-metadata").trigger( "mouseover" );
$(this).scrollTop(scrollTo + $(this).scrollTop());
}
});
}
function _main() {
var isReady = jQuery("ytd-compact-video-renderer").length > 0;
if (!isReady) {
setTimeout(_main, 500);
return;
}
$("#related").find("div#items").wrap("");
$('div.scrollbar').bind('mousewheel DOMMouseScroll', function(e) {
var scrollTo = null;
if (e.type == 'mousewheel') {
scrollTo = (e.originalEvent.wheelDelta * -1);
} else if (e.type == 'DOMMouseScroll') {
scrollTo = 40 * e.originalEvent.detail;
}
if (scrollTo) {
e.preventDefault();
$(this).scrollTop(scrollTo + $(this).scrollTop());
}
});
}
function getMenuItem(id, display, checked){
var res = "";
if (checked == "true" || checked == true)
res ='
';
else
res ='
';
return res;
}
function AddCleaner(){
var theButtonsMenu = $("#contents");
let isReady = theButtonsMenu.length > 0;
if (!isReady) {
setTimeout(AddCleaner, 2000);
return;
}
var targetNodeVideos = $("#contents").first().get(0);
var configRoot = { attributes: false, childList: true, subtree: true };
var callbackVideos = function(mutationsList, observer) {
for(var mutation of mutationsList) {
mutation.addedNodes.forEach(function(node) {
if ($(node).hasClass("ytd-rich-item-renderer")){
if (exclusionListFix != null){
var currentTitle = $(node).find("#video-title").text();
for (var i = 0; i < exclusionListFix.length; i++) {
if (currentTitle.trim().toUpperCase().indexOf(exclusionListFix[i].trim()) > -1) {
$(node).closest("ytd-rich-item-renderer").css("display","none");
}
}
}
}
});
}
};
var observerVideos = new MutationObserver(callbackVideos);
observerVideos.observe(targetNodeVideos, configRoot);
$("#masthead-container").find("#end").prepend(``);
var enhanceSettings = `
`;
$("body").append(enhanceSettings);
$(".enhancecontainer").append(``);
$(".enhancecontainer").append(`
Save');
$(".enhanceButton").click(function(){
$(".enhancecontainer").toggle();
$("#exclusionListFix").val(localStorage.getItem("excludeVideosFromYoutube"));
});
$("#enhanceSaveExclude").click(function(){
$(".enhancecontainer").toggle();
localStorage.setItem("excludeVideosFromYoutube", $("#exclusionListFix").val());
exclusionListFix = $("#exclusionListFix").val().toUpperCase().split(";");
//######## custom background
if ($("#custombgvalue").val() != ""){
localStorage.setItem("backgroundColourFix", $("#custombgvalue").val());
document.querySelector(':root').style.setProperty('--yt-spec-base-background', $("#custombgvalue").val());
}
else{
localStorage.removeItem("backgroundColourFix");
document.querySelector(':root').style.setProperty('--yt-spec-base-background', '#0f0f0f');
}
//########## remove retarded cinematics
if (removeVideoBackground == true ||removeVideoBackground == "true"){
removeCinematics("none");
localStorage.setItem("removeVideoBackground", $(this).prop('checked'));
}
else{
removeCinematics("block");
localStorage.removeItem("removeVideoBackground");
}
});
}
(function() {
AddCleaner();
GM_addStyle(`
.scrollbar
{
margin-left: 30px;
max-height: `+ ($( document ).height() - 300)+`px;
float: left;
overflow-y: scroll;
margin-bottom: 25px;
}
`);
GM_addStyle(`
.enhancecontainer {
display: flex;
flex-wrap: wrap;
justify-content: center;
background: rgb(40, 40, 40);
padding: 10px;
width: 200px;
position: fixed;
right: 100px;
z-index: 99999;
margin-top: 66px;
width: 500px;
height: auto;
flex-direction: column;
color: white;
font-size: small;
}
`);
GM_addStyle(`
.enhancecontainer div{
padding-bottom: 5px;
}
`);
function GM_addStyle(css) {
const style = document.getElementById("GM_addStyle") || (function() {
const style = document.createElement('style');
style.type = 'text/css';
style.id = "GM_addStyle";
document.head.appendChild(style);
return style;
})();
const sheet = style.sheet;
sheet.insertRule(css, (sheet.rules || sheet.cssRules || []).length);
}
function RemoveCssRule(css) {
const style = document.getElementById("GM_addStyle") || (function() {
const style = document.createElement('style');
style.type = 'text/css';
style.id = "GM_addStyle";
document.head.appendChild(style);
return style;
})();
const sheet = style.sheet;
for (var i=0; i