Youtube Auto Expand Video Description! YT自动展开视频描述详细!
当前为
// ==UserScript==
// @name Youtube - Auto Expand Video Description
// @namespace http://tampermonkey.net/
// @version 2.4
// @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 $videoId = "";
let $clicked = false;
let $times = 0;
/*ASYNC*/
const simpleClick = (async (obj, clicked) => {
obj.click();
if(clicked){
$clicked = true;
}
});
/*LOOP*/
const videoIdCheckDesInterval = setInterval(() => {
try{
let video_des = document.getElementsByClassName("watch-active-metadata style-scope ytd-watch-flexy style-scope ytd-watch-flexy")[0];
let videoId = video_des.getAttribute("video-id");
let expand = video_des.querySelector("#expand");
let collapse = video_des.querySelector("#collapse");
/**/
if ($videoId != videoId) {
window.onscroll = (() => {
window.scrollTo(0, 0);
});
/**/
simpleClick(expand, true);
/**/
if (collapse.checkVisibility()) {
console.warn("Description Expanded!");
$videoId = videoId;
}
}
/**/
if ($clicked) {
if($times > 30){
window.onscroll = null;
simpleClick(document.body, false);
$times = 0;
$clicked = false;
}else{
$times++;
}
}
}catch(error){
//console.warn(error);
}
}, 1);