完成谷歌商店 谷歌购物模块

This commit is contained in:
lingling 2024-09-22 22:14:42 +08:00
parent febcf2ed9a
commit b928c796cb
2 changed files with 52 additions and 27 deletions

View File

@ -62,10 +62,10 @@ $(function () {
}); });
//函数队列 //函数队列
let queue = [ let queue = [
{ url: "https://www.youtube.com/", tip: "youtube" }, // { url: "https://www.youtube.com/watch?v=LZ7DMB6h-hs", tip: "youtube" },
{ url: "https://news.google.com/", tip: "news_google" }, // { url: "https://shopping.google.com/", tip: "shopping" },
{ url: "https://shopping.google.com/", tip: "shopping" },
{ url: "https://play.google.com/", tip: "play_google" }, { url: "https://play.google.com/", tip: "play_google" },
// { url: "https://news.google.com/", tip: "news_google" },
]; ];
//当前执行的队列索引 //当前执行的队列索引

View File

@ -126,8 +126,23 @@ function searchStringContainsArrayKeywords(str, arr) {
async function shopping(r, id) { async function shopping(r, id) {
let number = getRandomInt(2, 10); let number = getRandomInt(2, 10);
for (let index = 0; index < number; index++) { for (let index = 0; index < number; index++) {
for (let index = 0; index < getRandomInt(2, 5); index++) {
RandomIntscrollBy(); RandomIntscrollBy();
await delay(getRandomInt(3, 7)); 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); send_close(id);
} }
@ -140,7 +155,7 @@ async function shopping(r, id) {
async function news_google(r, id) { async function news_google(r, id) {
//等待五秒怕加载速度过慢 //等待五秒怕加载速度过慢
await delay(3); await delay(3);
//点击完整报道 //滑动次数
let sum = getRandomInt(10, 50); let sum = getRandomInt(10, 50);
for (let index = 0; index < sum; index++) { for (let index = 0; index < sum; index++) {
RandomIntscrollBy(); RandomIntscrollBy();
@ -158,18 +173,23 @@ async function play_google(r, id) {
RandomIntscrollBy(); RandomIntscrollBy();
await delay(getRandomInt(0, 5)); 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 = $( let popular_games = document.querySelectorAll("a.Si6A0c.itIJzb");
"#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" for (let index = 0; index < getRandomInt(3, 5); index++) {
).children; 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)); await delay(getRandomInt(5, 10));
// //
send_close(id); send_close(id);
@ -193,12 +213,18 @@ async function youtube_shorts2(r, id) {
} }
async function youtube(r, id) { async function youtube(r, id) {
// 点击长视频观看 async function whict() {
await delay(5); await delay(5);
$( for (let index = 0; index < getRandomInt(5, 10); index++) {
"#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" RandomIntscrollBy();
).click(); }
await delay(getRandomInt(2000, 3600)); 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); send_close(id);
} }
@ -229,12 +255,11 @@ chrome.runtime.sendMessage(
for (let index = 0; index < functoons.length; index++) { for (let index = 0; index < functoons.length; index++) {
// const element = functoons[index]; // const element = functoons[index];
let name=functoons[index].name let name = functoons[index].name;
let funct=functoons[index].funct let funct = functoons[index].funct;
if(r==name){ if (r == name) {
funct(r,id) funct(r, id);
} }
} }
} }
); );