您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Print the number of comments for each video in youtube playlists
// ==UserScript== // @name Videos Comment Counter on Youtube Playlist pages // @description Print the number of comments for each video in youtube playlists // @namespace https://gf.qytechs.cn/users/869370 // @icon https://s.ytimg.com/yts/img/favicon_96-vflW9Ec0w.png // @match *://www.youtube.com/playlist?list=WL // @require https://code.jquery.com/jquery-3.4.1.min.js // @version 1.0 // @author javalinex // @license MIT // ==/UserScript== $("<style type='text/css'> .numerodecomentarios:before{ content: attr(data-before);background-color: #b7b7b7;padding: 1px 8px;color: white;letter-spacing: 1px;border-radius: 4px;} </style>").appendTo("head"); $("h3 a.yt-simple-endpoint").addClass("numerodecomentarios"); $(document).ready(function () { let videos = Array.prototype.slice.call(document.querySelectorAll("h3 a.yt-simple-endpoint")); for (let videolistindex = 0; videolistindex < videos.length; videolistindex++) { let videoURL = videos[videolistindex].getAttribute("href"); console.log(videoURL); let videoID = videoURL.match(/[?&]v=([^#\&\?]+)/); console.log(videoID[1]); $.getJSON("https://www.googleapis.com/youtube/v3/videos?part=statistics&id="+videoID+"&key={{{{{{{{{{{{YOUR-API-KEY-HERE}}}}}}}}}}}}}", function(data) { videos[videolistindex].setAttribute("data-before", "💬 " + data.items[0].statistics.commentCount); }); } MutationObserver = window.MutationObserver || window.WebKitMutationObserver; var observer = new MutationObserver(function(mutations, observer) { // fired when a mutation occurs let videos = Array.prototype.slice.call(document.querySelectorAll("h3 a.yt-simple-endpoint")); for (let videolistindex = 0; videolistindex < videos.length; videolistindex++) { let videoURL = videos[videolistindex].getAttribute("href"); console.log(videoURL); let videoID = videoURL.match(/[?&]v=([^#\&\?]+)/); console.log(videoID[1]); $.getJSON("https://www.googleapis.com/youtube/v3/videos?part=statistics&id="+videoID+"&key={{{{{{{{{{{{YOUR-API-KEY-HERE}}}}}}}}}}}}}", function(data) { videos[videolistindex].setAttribute("data-before", "💬 " + data.items[0].statistics.commentCount); }); } $("h3 a.yt-simple-endpoint").addClass("numerodecomentarios"); }); // define what element should be observed by the observer // and what types of mutations trigger the callback observer.observe(document.querySelector('ytd-playlist-video-list-renderer'), { attributes: false, childList: true, characterData: false, subtree: true }); });
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址