Youtube Auto Expand Video Description

Youtube Auto Expand Video Description! YT自动展开视频描述详细!

目前為 2024-02-08 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Youtube Auto Expand Video Description
// @namespace    http://tampermonkey.net/
// @version      1.9
// @description  Youtube Auto Expand Video Description! YT自动展开视频描述详细!
// @author       Martin______X
// @match        https://www.youtube.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=youtube.com
// @grant        none
// @license      MIT
// ==/UserScript==

let __$url = "";
let __$videoTitle = "";
//Async
const expandDescriptionClick = (async (expandObj) => {
    expandObj.click();
});
//set URL
const setUrl = ((url) => {
    console.warn("Description Expanded!");
    __$url = url;
});
//Loop
const urlCheckDesInterval = setInterval(() => {
    let url = document.URL;
    let paperButtons = document.getElementsByClassName("button style-scope ytd-text-inline-expander");
    let i = paperButtons.length;
    //
    if (__$url != url && url.includes("watch?v=")) {
        // "Show more" button
        let expandObj = paperButtons[i - 2];
        // "Show less" button
        let collapseObj = paperButtons[i - 1];
        //Click it
        expandDescriptionClick(expandObj);
        //check visibility
        if (collapseObj.checkVisibility()) {
            //Watching In Non-playlist
            if (!url.includes("&list=")) {
                setUrl(url);
            }
            //Watching In Playlist
            else {
                let videoTitle = document.getElementById("video-title");
                if (__$videoTitle != videoTitle) {
                    setUrl(url);
                    __$videoTitle = videoTitle;
                }
            }
        }
    }
}, 100);