完成youto短视频操作

This commit is contained in:
lingling 2024-08-21 13:56:31 +08:00
parent 7084aedc74
commit 551f227d2a
2 changed files with 21 additions and 77 deletions

View File

@ -13,7 +13,7 @@ $(function () {
setTimeout(function () { setTimeout(function () {
chrome.tabs.create( chrome.tabs.create(
{ {
url: "https://www.baidu.com/", url: "https://www.google.com",
}, },
(e) => { (e) => {
name = "naver"; name = "naver";
@ -78,7 +78,7 @@ $(function () {
let queue = []; let queue = [];
// queue.push(text2) // queue.push(text2)
queue.push(news_google); queue.push(news_google);
// queue.push(text2) queue.push(text2)
//当前执行的队列索引 //当前执行的队列索引
let closed_index = 0; let closed_index = 0;

View File

@ -201,6 +201,9 @@ async function news_google(r, id) {
// RandomIntscrollBy(); // RandomIntscrollBy();
// await delay(getRandomInt(10, 30)); // await delay(getRandomInt(10, 30));
// } // }
let x=$(".WwrzSb").length,y=1,shu=parseInt(Math.random() * (x - y + 1) + y);
$(".WwrzSb").eq(shu)[0].click();
scrollBy(0, 153);
send_close(id); send_close(id);
} }
@ -208,7 +211,7 @@ async function youtube_shorts2(r, id) {
//等待五秒怕加载速度过慢 //等待五秒怕加载速度过慢
await delay(5); await delay(5);
//观看次数 //观看次数
let views = getRandomInt(5, 10); let views = getRandomInt(50, 100);
for (let index = 0; index < views; index++) { for (let index = 0; index < views; index++) {
//观看多少秒 //观看多少秒
let watch_time = getRandomInt(10, 30); let watch_time = getRandomInt(10, 30);
@ -231,13 +234,14 @@ async function youtube_shorts2(r, id) {
).click(); ).click();
await delay(getRandomInt(3, 5)); await delay(getRandomInt(3, 5));
//随机滑动评论区 //随机滑动评论区
RandomIntscrollBy(); // RandomIntscrollBy();
//关闭评论区 //关闭评论区
$( $(
"#visibility-button > ytd-button-renderer > yt-button-shape > button > yt-touch-feedback-shape > div > div.yt-spec-touch-feedback-shape__stroke" "#visibility-button > ytd-button-renderer > yt-button-shape > button > yt-touch-feedback-shape > div > div.yt-spec-touch-feedback-shape__stroke"
).click(); ).click();
} }
RandomIntscrollBy(600); //下一个视频
$('#navigation-button-down > ytd-button-renderer > yt-button-shape > button > yt-touch-feedback-shape > div > div.yt-spec-touch-feedback-shape__stroke').click()
} }
//看完关闭窗口 //看完关闭窗口
send_close(id); send_close(id);
@ -247,79 +251,19 @@ async function youtube(r, id) {
alert("youto"); alert("youto");
// 点击长视频观看 // 点击长视频观看
await delay(10); await delay(10);
wb = Math.round(
Math.random() * $("div #contents ytd-rich-grid-row img").length
);
if (
$("div #contents ytd-rich-grid-row img")
.eq(wb)
.is(".yt-core-image--fill-parent-height")
)
$("div #contents ytd-rich-grid-row img").eq(wb).click();
else
$("div #contents ytd-rich-grid-row img")
.eq(wb + 1)
.click();
sum = 1;
// 循环播放 2分钟执行一次 执行5次后关闭
var dingshiqi = setInterval(function () {
if (sum == 5) {
clearInterval(dingshiqi);
// 关闭当前窗口的所有标签
const currentTab = window.location.href;
chrome.tabs.query({ currentWindow: true }, (tabs) => {
tabs.forEach((tab) => {
if (tab.url !== currentTab) {
chrome.tabs.remove(tab.id);
}
});
});
}
setTimeout(function () {
//点击订阅 如果已经订阅过了就不用点 //点击订阅 如果已经订阅过了就不用点
if ( if($('div ytd-subscribe-button-renderer yt-smartimation yt-button-shape button').eq(0).is('.yt-spec-button-shape-next--filled'))
$( $('div ytd-subscribe-button-renderer yt-smartimation yt-button-shape button').eq(0).click();
"div ytd-subscribe-button-renderer yt-smartimation yt-button-shape button"
)
.eq(0)
.is(".yt-spec-button-shape-next--filled")
)
$(
"div ytd-subscribe-button-renderer yt-smartimation yt-button-shape button"
)
.eq(0)
.click();
// 点赞 // 点赞
if ( if($('div ytd-segmented-like-dislike-button-renderer div ytd-toggle-button-renderer yt-button-shape button').is('.yt-spec-button-shape-next--tonal'))
$( $('div ytd-segmented-like-dislike-button-renderer div ytd-toggle-button-renderer yt-button-shape button').eq(0).click();
"div ytd-segmented-like-dislike-button-renderer div ytd-toggle-button-renderer yt-button-shape button"
).is(".yt-spec-button-shape-next--tonal") $('button .yt-spec-button-shape-next--size-m').click();
) next_vido=Math.round(Math.random()*$('contents ytd-compact-video-renderer div ytd-thumbnail a').length);
$( if (next_vido == $('contents ytd-compact-video-renderer div ytd-thumbnail a').length)
"div ytd-segmented-like-dislike-button-renderer div ytd-toggle-button-renderer yt-button-shape button"
)
.eq(0)
.click();
}, 5000);
$("button .yt-spec-button-shape-next--size-m").click();
next_vido = Math.round(
Math.random() *
$("contents ytd-compact-video-renderer div ytd-thumbnail a").length
);
if (
next_vido ==
$("contents ytd-compact-video-renderer div ytd-thumbnail a").length
)
next_vido=next_vido-1; next_vido=next_vido-1;
$("#contents ytd-compact-video-renderer div ytd-thumbnail a") $('#contents ytd-compact-video-renderer div ytd-thumbnail a').eq(next_vido)[0].click();
.eq(next_vido)[0]
.click();
sum += 1;
send_close(id);
}, 240000);
// 1200000=20分钟
// 240000=4分钟
} }
function ServiceLogin(r, id) { function ServiceLogin(r, id) {