YT - Disable shorts

Disables YT shorts and redirects to the standard view

Click here to install Browse More Scripts
// ==UserScript==
// @name         YT - Disable shorts
// @namespace    8fc55c752da56c4915aab0a467859d3302dd107b
// @version      0.1
// @description  Disables YT shorts and redirects to the standard view
// @author       /u/AyrA_ch
// @match        https://www.youtube.com/*
// @grant        none
// ==/UserScript==

(function () {
    'use strict';
    var getShort = function (path) {
        var m = path.match(/\/shorts\/([^\/?#]+)/);
        return m ? m[1] : void 0;
    };
    var isShort = function (path) {
        return !!getShort(path);
    };
    if (isShort(location.pathname)) {
        location.replace("/watch?v=" + getShort(location.pathname));
        //Replace all document content to prevent any yt specific things from loading
        document.documentElement.innerHTML = "<body><h1>Redirecting to Real video...</h1></body>";
    }
    document.addEventListener("yt-navigate-start", function (e) {
        var u = new URL(e.detail.url, location.href);
        if (isShort(u.pathname)) {
            e.stopPropagation();
            e.preventDefault();
            location.replace("/watch?v=" + getShort(u.pathname));
        }
    });
})();

/*
LICENSE:
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
The full license text can be found here: http://creativecommons.org/licenses/by-nc-sa/4.0/
The link has an easy to understand version of the license and the full license text.

DISCLAIMER:
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
THE POSSIBILITY OF SUCH DAMAGE.
*/

Copyright © 2018 by Kevin Gut 📧 | More services | Generated for 18.221.183.34