javascript:(function() { if(!window.youtubeBG) { // Check if bookmarklet is active window.youtubeBG = function() { var videoId = yt.getConfig("VIDEO_ID"); // Get video id if(videoId) { // Check if video id exists var styleTag = document.createElement("style"); // Create styles styleTag.setAttribute("class", "youtubeBG"); document.getElementsByTagName("head")[0].appendChild(styleTag); var cssSheet = styleTag.sheet ? styleTag.sheet : styleTag.styleSheet; cssSheet.insertRule("#page{background: #222;}", 0); cssSheet.insertRule('.yt-card:before { visibility: visible; content: ""; width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0.55; pointer-events: none; transition: 0.25s; }', 0); cssSheet.insertRule(".yt-card:hover:before {opacity: 0;}", 0); cssSheet.insertRule(".yt-card {position: relative;}", 0); cssSheet.insertRule(".video-list .video-list-item .stat {color: #333;}", 0); cssSheet.insertRule(".yt-ui-ellipsis {background: transparent;}", 0); /* YouTube uses two sizes for high quality thumbnails */ var hq = 'url("https://i.ytimg.com/vi/' + videoId + '/hqdefault.jpg") no-repeat fixed 50% 50% / cover transparent'; var maxres = 'url("https://i.ytimg.com/vi/' + videoId + '/maxresdefault.jpg") no-repeat fixed 50% 50% / cover transparent'; var img = new Image(); img.src = 'https://i.ytimg.com/vi/' + videoId + '/maxresdefault.jpg'; img.onload = function() { if(img.width + "x" + img.height == "120x90") { // Check which thumbnail exists cssSheet.insertRule(".yt-card:before{background: " + hq + "}", 0); } else { cssSheet.insertRule(".yt-card:before{background: " + maxres + "}", 0); } if(document.querySelector(".youtubeBG") && document.querySelector(".youtubeBG") != styleTag) { document.querySelector(".youtubeBG").remove(); // Remove the old style tag when adding a new one } }; } }; window.youtubeBGDelay = function() { setTimeout(window.youtubeBG, 3000); // Call again after 3 seconds to catch delayed loading }; var video = document.querySelector(".html5-main-video"); if(video) { // Add event listeners to update on video change video.addEventListener("playing", window.youtubeBG); video.addEventListener("playing", window.youtubeBGDelay); } window.youtubeBG(); } else { // Deactivate the bookmarklet var styleTag = document.querySelector(".youtubeBG"); if(styleTag) { styleTag.remove(); } var video = document.querySelector(".html5-main-video"); if(video) { video.removeEventListener("playing", window.youtubeBG); video.removeEventListener("playing", window.youtubeBGDelay); } window.youtubeBG = undefined; } }());