コトバノウタカタ

よしなしごとをつらつらとつづるばしょ。

YouTubeのショートやクリップを普通のページにするやつ

YouTubeのショートを普通のページにするやつ

javascript: (function () {
    var m = $("meta[itemprop='videoId']");
    if (m.length > 0) {
        location.href = "https://www.youtube.com/watch?v=" + m.attr("content");
        return;
    }
    else {
        var mt = /https:\/\/www\.youtube\.com\/shorts\/(.+)/i.exec(location.href);
        if (mt != null) {
            location.href = "https://www.youtube.com/watch?v=" + mt[1];
            return;
        }
    }
    alert("Invalid page!");
    return;
}
)()

クリップにも対応。

javascript: (
    function () {
        var code = "";
        var m = $("meta[itemprop='videoId'], meta[itemprop='identifier']");
        if (m.length > 0) {
            code = m.attr("content");
        }
        if (code == "") {
            var mt = /https:\/\/www\.youtube\.com\/shorts\/(.+)/i.exec(location.href);
            if (mt != null) {
                code = mt[1];
            }
        }

        if (code != "") {
            var url = "https://www.youtube.com/watch?v=" + code;
            location.href = url;
        }
        else {
            alert("Invalid page!");
        }
        return;
    }

)()


クリップの方は右クリックで「動画のURLをコピー」すればいいんですけどね。