您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Video description, long comments and list of subscriptions are expanded automatically; all the replies are shown after pressing "View all N replies" button
当前为
- // ==UserScript==
- // @name Youtube: expand description and long comments; show all the replies
- // @description Video description, long comments and list of subscriptions are expanded automatically; all the replies are shown after pressing "View all N replies" button
- // @author MK
- // @namespace max44
- // @homepage https://greasyfork.org/en/users/309172-max44
- // @match *://*.youtube.com/*
- // @match *://*.youtu.be/*
- // @icon https://cdn.icon-icons.com/icons2/1488/PNG/512/5295-youtube-i_102568.png
- // @version 1.0.7
- // @license MIT
- // @grant none
- // @require https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
- // @run-at document-idle
- // ==/UserScript==
- (function () {
- 'use strict';
- var urlAtLastCheck = "";
- var nameAtLastCheck = "";
- var btnClick = null;
- var i;
- setInterval(function() { //Check page content constantly
- //Check whether URL and channel name have changed. If yes, clear the attribute clicked-by-script, because it survives change of the page
- if (urlAtLastCheck != window.location.href && nameAtLastCheck != document.title) {
- urlAtLastCheck = window.location.href;
- nameAtLastCheck = document.title;
- btnClick = $( "div#description ytd-text-inline-expander tp-yt-paper-button#expand[role='button'][clicked-by-script='true']" );
- if (btnClick != null && btnClick.length > 0) btnClick[0].removeAttribute("clicked-by-script");
- btnClick = $( "div#meta-contents ytd-video-secondary-info-renderer div ytd-expander tp-yt-paper-button#more[clicked-by-script='true']" );
- if (btnClick != null && btnClick.length > 0) btnClick[0].removeAttribute("clicked-by-script");
- }
- //Check whether description has been expanded by another script or addon. If yes, mark it as if it was expanded by the script to avoid double processing
- btnClick = $( "div#description ytd-text-inline-expander tp-yt-paper-button#expand[role='button']:not([clicked-by-script='true'])[hidden='']" ); //Description was expanded by another script or addon
- if (btnClick != null && btnClick.length > 0) {
- btnClick[0].setAttribute("clicked-by-script", "true"); //Do not click it again
- }
- //Expand description
- btnClick = $( "div#description ytd-text-inline-expander tp-yt-paper-button#expand[role='button']:not([clicked-by-script='true']):not([hidden=''])" );
- if (btnClick != null && btnClick.length > 0) {
- btnClick[0].click();
- btnClick[0].setAttribute("clicked-by-script", "true"); //Do not click it again
- }
- //Expand description for 7ktTube | 2016 REDUX script
- btnClick = $( "div#meta-contents ytd-video-secondary-info-renderer div ytd-expander tp-yt-paper-button#more:not([clicked-by-script='true'])" );
- if (btnClick != null && btnClick.length > 0) {
- btnClick[0].click();
- btnClick[0].setAttribute("clicked-by-script", "true"); //Do not click it again
- }
- //Expand long comments and hide "show less" button in comments section
- btnClick = $( "#primary ytd-comment-renderer #comment-content tp-yt-paper-button#more:not([hidden='']) > span.more-button[slot='more-button']:not([clicked-by-script='true'])" );
- if (btnClick != null) {
- for (i = 0; i < btnClick.length; i++) {
- btnClick[i].click();
- btnClick[i].setAttribute("clicked-by-script", "true"); //Do not click it again
- btnClick[i].parentNode.previousElementSibling.setAttribute("style", "display:none;"); //Hide "Show less" button
- }
- }
- //Expand long comments and hide "show less" button in notification submenu
- btnClick = $( "#submenu ytd-comment-renderer #comment-content tp-yt-paper-button#more:not([hidden='']) > span.more-button[slot='more-button']:not([clicked-by-script='true'])" );
- if (btnClick != null) {
- for (i = 0; i < btnClick.length; i++) {
- btnClick[i].click();
- btnClick[i].setAttribute("clicked-by-script", "true"); //Do not click it again
- btnClick[i].parentNode.previousElementSibling.setAttribute("style", "display:none;"); //Hide "Show less" button
- }
- }
- //Expand post in community section
- btnClick = $( "div#post ytd-expander#contentTextExpander tp-yt-paper-button#more[role='button']:not([clicked-by-script='true']):not([hidden=''])" );
- if (btnClick != null && btnClick.length > 0) {
- btnClick[0].click();
- btnClick[0].setAttribute("clicked-by-script", "true"); //Do not click it again
- }
- //Show all replies upon pressing "View all N replies" button
- btnClick = $( "div#replies div#expander div#button.ytd-continuation-item-renderer ytd-button-renderer tp-yt-paper-button#button[role='button']:not([clicked-by-script='true'])" );
- if (btnClick != null) {
- for (i = 0; i < btnClick.length; i++) {
- btnClick[i].click();
- btnClick[i].setAttribute("clicked-by-script", "true"); //Do not click it again
- }
- }
- //Show all subscriptions
- btnClick = $( "#guide div#sections div#items ytd-guide-collapsible-entry-renderer.ytd-guide-section-renderer[can-show-more=''] #expander-item:not([clicked-by-script='true'])" );
- if (btnClick != null) {
- for (i = 0; i < btnClick.length; i++) {
- btnClick[i].click();
- btnClick[i].setAttribute("clicked-by-script", "true"); //Do not click it again
- }
- }
- }, 250); //Interval to check page content
- })();