Skip to content

Instantly share code, notes, and snippets.

@ThenTech
Last active June 12, 2016 14:54
Show Gist options
  • Save ThenTech/3c2a31bceebc658e4c411c1efc8c6576 to your computer and use it in GitHub Desktop.
Save ThenTech/3c2a31bceebc658e4c411c1efc8c6576 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name YouTube Sidebar Sticky
// @namespace https://gist.github.com/Wosser1sProductions/
// @version 0.1
// @description Prevent side-bar from closing on click.
// @author Wosser1sProductions
// @include http*://*.youtube.com/*
// @include http*://youtube.com/*
// @include http*://*.youtu.be/*
// @include http*://youtu.be/*
// @exclude http*://*.youtube.com/watch*
// @grant none
// ==/UserScript==
(function() {
'use strict';
var D = document;
var root = D.documentElement;
function getDocHeight() {
return Math.max(
D.body.scrollHeight, root.scrollHeight,
D.body.offsetHeight, root.offsetHeight,
D.body.clientHeight, root.clientHeight
);
}
function getDocWidth() {
return Math.max(
D.body.scrollWidth, root.scrollWidth,
D.body.offsetWidth, root.offsetWidth,
D.body.clientWidth, root.clientWidth
);
}
function stickSidebar() {
if (!root.classList.contains("show-guide"))
if ((document.body.scrollTop + 1200) < getDocHeight() && getDocWidth() > 1734)
root.className += ' show-guide';
}
if (root.addEventListener) { // For all major browsers, except IE 8 and earlier
root.addEventListener("mousemove", stickSidebar);
} else if (x.attachEvent) { // For IE 8 and earlier versions
root.attachEvent("mousemove", stickSidebar);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment