有没有办法一次从这里删除所有的YouTube评论,https://www.youtube.com/feed/history/comment_历史?
发布于 2018-04-22 17:47:49
发布于 2022-08-18 18:49:20
派对有点晚了,但对于那些在2022年寻求解决方案的人来说:
function scrollDown(i) {
try {
window.scrollTo(0, document.body.scrollHeight);
}
catch (e) {
scrollDown();
}
setTimeout(function(){
var i = i - '20'; // just to make sure we dont skip any comments while scrolling
deleteComment(i);
}, 1000);
}
function deleteComment(i) {
var xPathRes = document.evaluate ('/html/body/c-wiz/div/div[2]/c-wiz/c-wiz/div/div[2]/div[1]/div', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (xPathRes) {
if (xPathRes.textContent == "Looks like you've reached the end") {
console.log("All done! Keep the page open until everything is gone including the grey date bubbles");
return;
}
}
console.log('Deleting comment: ' + i);
var xPathRes = document.evaluate ('/html/body/c-wiz/div/div[2]/c-wiz/c-wiz/div/div[1]/c-wiz[' + i + ']/div/div/div[1]/div[2]/div/button', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
var i = i + 1;
if (i > 500) {
return;
}
try {
xPathRes.singleNodeValue.click();
}
catch (e) {
scrollDown(i);
return;
}
deleteComment(i);
}
deleteComment(1);
!!请注意,此脚本并不完美。我急急忙忙地把它编码了。如果脚本没有删除所有内容,只需再次粘贴并保持页面打开,直到所有内容都结束(处理所有请求需要一段时间)。
脚本会在看到“看起来你已经到达终点”之后停止运行。
此脚本适用于:https://myactivity.google.com/page?utm_来源=&hl=en&page=youtube_评论
https://webapps.stackexchange.com/questions/116500
复制相似问题