// ==UserScript== // @name Youtube Fix // @namespace http://tampermonkey.net/ // @version 0.1.3.1 // @description Scrollbar + more videos on main page. // @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 itemsPerRow = 9; var currentVideoId = ""; if ($(window).width() < 2000) { itemsPerRow = 6; } else { itemsPerRow = 9; } if (localStorage.getItem("itemsPerRow") != null) { itemsPerRow = localStorage.getItem("itemsPerRow"); } 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()); } }); /* var divComments = $("#comments").detach(); var divSecondary = $("#secondary").detach(); divSecondary.css("margin-left","-430px"); divSecondary.css("width","500px"); divSecondary.css("margin-right","107px"); $("#columns").append(divComments); $("#columns").prepend(divSecondary); var config = { attributes: false, childList: true, subtree: true }; var targetNodeRoot = $("#movie_player").get(0); var configRoot = { attributes: false, childList: true, subtree: true }; var callbackRoot = function(mutationsList, observer) { var htmlPlayer = $("video"); if (currentVideoId != htmlPlayer.attr("src")){ currentVideoId = htmlPlayer.attr("src"); var moviePlayer = $("#movie_player"); htmlPlayer.attr("style","height: "+moviePlayer.height()+"px !important; width: " + moviePlayer.width() + "px !important"); $(".ytp-chrome-bottom").attr("style","width: " + moviePlayer.width() + "px !important"); }; }; // Create an observer instance linked to the callback function var observerroot = new MutationObserver(callbackRoot); // Start observing the target node for configured mutations observerroot.observe(targetNodeRoot, config); _addScrollBarComments(); */ } (function() { 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