yakumo_ran / YouTube Sanity - 1080p & Anti-Nextvid

// ==UserScript==
// @name          YouTube Sanity - 1080p & Anti-Nextvid
// @author        yakumo_ran
// @license       LGPL v3
// @include       *.youtube.com/watch*
// @version       1.2
// @grant         metadata
// ==/UserScript==

! function(e) {
    "use strict";

    function t() {
        var e = document.getElementsByClassName("autoplay-bar")[0];
        e && (e.removeAttribute("class"), document.getElementsByClassName(
            "checkbox-on-off")[0].remove())
    }

    function n(e) {
        return e && "function" == typeof XPCNativeWrapper && "function" ==
            typeof XPCNativeWrapper.unwrap ? XPCNativeWrapper.unwrap(e) : e
    }

    function a() {
        var e = i.document;
        return e.getElementById("movie_player")
    }

    function o() {
        r = !1, i = "undefined" != typeof unsafeWindow ? unsafeWindow : n(
            window)
    }
    window.addEventListener("readystatechange", t, !0), window.addEventListener(
        "spfdone", t), setTimeout(function() {
        var e, t, n = a();
        r = !0, t = 1 == i.ytplayer.config.html5, i.ytplayer && i.ytplayer
            .config && i.ytplayer.config.args && (e = i.ytplayer.config
                .args), t && "hd1080" !== n.getPlaybackQuality() && n.setPlaybackQuality(
                "hd1080")
    }, 0);
    var r, i;
    o()
}();