Last active
August 29, 2015 14:17
-
-
Save Yonezpt/dc0309e31985b04a1f54 to your computer and use it in GitHub Desktop.
Disable share-panel and sidebar autoscroll in YouTube
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @version 1.0.1 | |
// @name Disable share-panel and sidebar autoscroll in YouTube | |
// @match *://www.youtube.com/* | |
// @run-at document-start | |
// @grant none | |
// @noframes | |
// ==/UserScript== | |
(function ytascrl() { | |
'use strict'; | |
var injection; | |
if (document.querySelector('[name="html5player/html5player"]')) { | |
window.location.reload(false); | |
} else if (!document.getElementById('ytascrl')) { | |
injection = document.createElement('script'); | |
injection.id = 'ytascrl'; | |
injection.textContent = '(' + ytascrl + '())'; | |
document.documentElement.appendChild(injection); | |
return; | |
} | |
function sidebarPolice(a){ | |
var parent = a.target.parentNode; | |
if (parent && parent.classList.contains('yt-uix-simple-thumb-wrap') && !a.target.getAttribute('data-thumb')) { | |
parent.classList.remove('yt-uix-simple-thumb-wrap'); | |
} | |
} | |
function scriptExit(a){ | |
function baseDetour(b) { | |
return function () { | |
b.apply(this, arguments); | |
window.yt.config_.SHARE_ON_VIDEO_END = false; | |
}; | |
} | |
if (a.target.getAttribute('name') === 'www/base') { | |
window.yt.setConfig = baseDetour(window.yt.setConfig); | |
} | |
} | |
if (window.chrome) { | |
document.documentElement.addEventListener('load', sidebarPolice, true) | |
document.documentElement.addEventListener('load', scriptExit, true); | |
} else { | |
document.addEventListener('load', sidebarPolice, true) | |
window.addEventListener('afterscriptexecute', scriptExit); | |
} | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment