Unshort YouTube

Watch a YouTube Shorts video in the normal YouTube player

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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 });