Skip to content

Instantly share code, notes, and snippets.

@livibetter
Last active May 1, 2016 01:02
Show Gist options
  • Save livibetter/04392a117f0418f174b9 to your computer and use it in GitHub Desktop.
Save livibetter/04392a117f0418f174b9 to your computer and use it in GitHub Desktop.
YouTube Decluttered (userscript)

YouTube Decluttered

This is Greasemonkey user script and Stylish user style for my personal usage.

  • Minimize the top bars to just YouTube logo at top-left corner

    This is not perfect, I'd just fix them at page top, but unfortunately, YouTube JavaScript scroll down to fixed position, for instance, switch to user's videos tab. If the top bars are fixed at page top, the scroll wouldn't be perfect.

    This also left a significant amount of blank spaces at top.

  • Kill the channel trailers

This script has been placed in public domain, or via UNLICENSE, if not applicable.

This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
/* Written by Yu-Jie Lin
* This stylesheet has been placed in public domain, or via UNLICENSE, if not
* applicable.
*
* Gist: https://gist.github.com/livibetter/04392a117f0418f174b9
*/
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document url-prefix("https://www.youtube.com/") {
/* Top bars */
#masthead-positioner {
left: calc(-23px - 38px);
right: calc(100% - 78px);
}
#masthead-positioner #yt-masthead-container {
background-color: transparent;
border: none;
}
#masthead-positioner #yt-masthead-user,
#masthead-positioner #yt-masthead-content,
#masthead-positioner #masthead-appbar-container {
display: none;
}
#masthead-positioner:hover {
left: 0px;
right: 0px;
}
#masthead-positioner:hover #yt-masthead-container {
background: #FFF;
border-bottom: 1px solid #E8E8E8;
}
#masthead-positioner:hover #yt-masthead-user,
#masthead-positioner:hover #yt-masthead-content,
#masthead-positioner:hover #masthead-appbar-container {
display: block;
}
}
@-moz-document url("https://www.youtube.com/"),
url-prefix("https://www.youtube.com/feed/subscriptions")
{
.yt-uix-menu-content-hidden {
padding: 0;
display: block;
right: 8px !important;
z-index: 0;
}
button.yt-uix-menu-trigger {
display: none;
}
.yt-uix-menu-content-hidden .yt-ui-menu-item {
padding-right: 18px;
line-height: 1.1em;
}
}
@-moz-document url-prefix("https://www.youtube.com/watch?v=") {
/* Share shits */
#action-panel-share {
display: none;
}
}
// ==UserScript==
// @name YouTube Decluttered
// @namespace http://localhost/youtube-decluttered
// @include https://www.youtube.com/channel/*
// @include https://www.youtube.com/user/*
// @version 0.1.0
// @grant none
// ==/UserScript==
// License Public Domain, or via UNLICENSE, if not applicable
// Gist https://gist.github.com/livibetter/04392a117f0418f174b9
YT_DEBUG_MORE = false;
function __ytd_remove_trailer()
{
console.debug('__ytd_remove_trailer called');
document.querySelector('.c4-player-container').remove();
}
function __ytd_callback(items)
{
console.debug('__ytd_callback called');
for (let item of items)
{
let t = item.target;
if (YT_DEBUG_MORE)
{
console.debug(item.type, item.attributeName, t, t.id)
}
__ytd_remove_trailer()
}
}
function ytd()
{
console.debug('ytd called');
__ytd_remove_trailer();
new MutationObserver(__ytd_callback).observe(
document.querySelector('#player'),
{
attributes: true
}
);
}
ytd();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment