Unshort YouTube

Watch a YouTube Shorts video in the normal YouTube player

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Unshort YouTube
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Watch a YouTube Shorts video in the normal YouTube player
// @author       [email protected]
// @match        https://www.youtube.com/shorts/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// @license MIT
// ==/UserScript==
'use strict';

var containerObserver = new MutationObserver(function() {
    var container_contents = document.querySelector("#center");
    if (container_contents !== null) {
        var unshort_button = document.querySelector("#unshort-button");
        if (unshort_button === null) {
            var new_button = document.createElement("button");
            new_button.setAttribute("id", "unshort-button");
            new_button.setAttribute("style", "color: var(--yt-spec-text-primary); background-color: var(--yt-spec-white-3); border-radius: 18em; padding-top: 10px; padding-bottom: 10px; padding-left: 12px; padding-right: 12px; margin: 5px; border-width: 0px; cursor: pointer; ");
            new_button.setAttribute("aria-label", "Unshort the video");
            new_button.setAttribute("title", "Unshort the video");
            new_button.setAttribute("onclick", "(function() {var new_url = document.URL.replace('/shorts/', '/watch?v='); window.location.href = new_url;})();");
            new_button.innerText = "Unshort";
            container_contents.appendChild(new_button);
        }
    }
});
containerObserver.observe(document, { subtree: true, childList: true });