From b928c796cb215f8513f4dcb6523ea80d1868db5e Mon Sep 17 00:00:00 2001 From: lingling <1077478963@qq.com> Date: Sun, 22 Sep 2024 22:14:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=B0=B7=E6=AD=8C=E5=95=86?= =?UTF-8?q?=E5=BA=97=20=E8=B0=B7=E6=AD=8C=E8=B4=AD=E7=89=A9=E6=A8=A1?= =?UTF-8?q?=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/popup.js | 6 ++--- lib/content.js | 73 +++++++++++++++++++++++++++++++++----------------- 2 files changed, 52 insertions(+), 27 deletions(-) diff --git a/js/popup.js b/js/popup.js index 9277927..4ca9dff 100644 --- a/js/popup.js +++ b/js/popup.js @@ -62,10 +62,10 @@ $(function () { }); //函数队列 let queue = [ - { url: "https://www.youtube.com/", tip: "youtube" }, - { url: "https://news.google.com/", tip: "news_google" }, - { url: "https://shopping.google.com/", tip: "shopping" }, + // { url: "https://www.youtube.com/watch?v=LZ7DMB6h-hs", tip: "youtube" }, + // { url: "https://shopping.google.com/", tip: "shopping" }, { url: "https://play.google.com/", tip: "play_google" }, + // { url: "https://news.google.com/", tip: "news_google" }, ]; //当前执行的队列索引 diff --git a/lib/content.js b/lib/content.js index 85b2f48..faf8f89 100644 --- a/lib/content.js +++ b/lib/content.js @@ -126,8 +126,23 @@ function searchStringContainsArrayKeywords(str, arr) { async function shopping(r, id) { let number = getRandomInt(2, 10); for (let index = 0; index < number; index++) { - RandomIntscrollBy(); - await delay(getRandomInt(3, 7)); + for (let index = 0; index < getRandomInt(2, 5); index++) { + RandomIntscrollBy(); + await delay(getRandomInt(5, 10)); + } + //获取所有的商品链接 + let sp = document.getElementsByClassName( + "gkQHve RmEs5b zypKDd aKoISd RycMEf" + ); + //触发点击事件 + sp[getRandomInt(0, sp.length - 1)].click(); + await delay(getRandomInt(10, 20)); + //获取关闭按钮 + let close = document.getElementsByClassName( + "ioQ39e wv9iH MjJqGe cd29Sd" + )[0]; + close.click(); + await delay(getRandomInt(2, 5)); } send_close(id); } @@ -140,7 +155,7 @@ async function shopping(r, id) { async function news_google(r, id) { //等待五秒怕加载速度过慢 await delay(3); - //点击完整报道 + //滑动次数 let sum = getRandomInt(10, 50); for (let index = 0; index < sum; index++) { RandomIntscrollBy(); @@ -158,18 +173,23 @@ async function play_google(r, id) { RandomIntscrollBy(); await delay(getRandomInt(0, 5)); } - //点击推荐 - if (getRandomInt(0, 1) == 0) { - $(".Pdcv8e").click(); - await delay(getRandomInt(5, 10)); - //返回主页 - $("#kO001e > header > nav > a").click(); - } //热门游戏随机列表 直接触发点击事件就行 - let popular_games = $( - "#yDmH0d > c-wiz.SSPGKf.glB9Ve > div > div > div.N4FjMb.Z97G4e > c-wiz > div > c-wiz > c-wiz:nth-child(4) > c-wiz > section > div > div > div > div > div.aoJE7e.b0ZfVe" - ).children; + let popular_games = document.querySelectorAll("a.Si6A0c.itIJzb"); + for (let index = 0; index < getRandomInt(3, 5); index++) { + try { + popular_games[getRandomInt(0, popular_games.length - 1)].click(); + } catch (error) { + console.log(error) + } + let a = getRandomInt(3, 5); + for (let index = 0; index < a; index++) { + RandomIntscrollBy(); + await delay(getRandomInt(0, 5)); + } + $(".f0UV3d").click(); + await delay(getRandomInt(5, 10)); + } await delay(getRandomInt(5, 10)); // send_close(id); @@ -193,12 +213,18 @@ async function youtube_shorts2(r, id) { } async function youtube(r, id) { - // 点击长视频观看 - await delay(5); - $( - "#app > div > ytm-browse > ytm-single-column-browse-results-renderer > div > div > ytm-tab-renderer > ytm-rich-grid-renderer > div > div.rich-grid-renderer-contents > ytm-rich-item-renderer:nth-child(2) > ytm-video-with-context-renderer > ytm-media-item > a > ytm-thumbnail-cover > img" - ).click(); - await delay(getRandomInt(2000, 3600)); + async function whict() { + await delay(5); + for (let index = 0; index < getRandomInt(5, 10); index++) { + RandomIntscrollBy(); + } + let all_video = $(".media-item-thumbnail-container"); + all_video[getRandomInt(0, all_video.length - 1)].click(); + await delay(getRandomInt(20, 60)); + } + for (let index = 0; index < getRandomInt(5, 10); index++) { + await whict(); + } //看完关闭窗口 send_close(id); } @@ -229,12 +255,11 @@ chrome.runtime.sendMessage( for (let index = 0; index < functoons.length; index++) { // const element = functoons[index]; - let name=functoons[index].name - let funct=functoons[index].funct - if(r==name){ - funct(r,id) + let name = functoons[index].name; + let funct = functoons[index].funct; + if (r == name) { + funct(r, id); } - } } );