Youtube Shorts to Normal Video

EN: Convert Youtube Shorts videos to normal videos with one button. TR: Youtube Shorts videolarını bir buton ile normal videoya dönüştürün.

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Youtube Shorts to Normal Video
// @namespace    https://linktr.ee/DeadLyBro
// @description  EN: Convert Youtube Shorts videos to normal videos with one button. TR: Youtube Shorts videolarını bir buton ile normal videoya dönüştürün.
// @author       DeadLyBro
// @copyright    2023, DeadLyBro (https://openuserjs.org/users/DeadLyBro)
// @version      1.7
// @match        https://www.youtube.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// @license      MIT
// ==/UserScript==

// ==OpenUserJS==
// @author       DeadLyBro
// @updateURL    https://openuserjs.org/meta/DeadLyBro/Youtube_Shorts_to_Normal_Video.meta.js
// @downloadURL  https://openuserjs.org/install/DeadLyBro/Youtube_Shorts_to_Normal_Video.user.js
// ==/OpenUserJS==

(function() {
    'use strict';

    // Buton stilini ekleme fonksiyonu
    function addCustomCSS() {
        if (!document.querySelector('.NormalVideoButtonCSS')) {
            const myCSS = document.createElement('style');
            myCSS.classList.add('NormalVideoButtonCSS');
            myCSS.textContent = `
                .NormalVideoButton {
                    background: #272727;
                    color: white;
                    border: none;
                    border-radius: 5px;
                    margin-bottom: 10px;
                }
                .NormalVideoButton:hover {
                    cursor: pointer;
                }
            `;
            document.body.append(myCSS);
        }
    }

    // Custom buton ekleme fonksiyonu
    function addCustomButton() {
        const activeElements = document.querySelectorAll('[is-active]');

        activeElements.forEach((activeElement) => {
            const likeButton = activeElement.querySelector('like-button-view-model');

            if (likeButton && !likeButton.querySelector('.NormalVideoButton')) {
                const myButton = document.createElement("button");
                myButton.innerText = `Normal Video`;
                myButton.classList.add('NormalVideoButton');
                myButton.addEventListener("click", () => {
                    const videoId = document.URL.split('/shorts/')[1];
                    if (videoId) {
                        location.href = `https://www.youtube.com/watch?v=${videoId}`;
                    }
                });
                likeButton.prepend(myButton);
            }
        });
    }

    // Shorts URL'sini kontrol edip, işlemi başlatma
    function checkAndRun() {
        if (document.baseURI.startsWith("https://www.youtube.com/shorts")) {
            addCustomCSS();  // CSS sadece bir kez eklenir
            addCustomButton();  // Buton ekleme her seferinde kontrol edilir
        }
    }

    // Sadece her saniyede bir URL kontrolü yapılır
    setInterval(checkAndRun, 1000);

})();