完成谷歌新闻模块

This commit is contained in:
lingling 2024-09-22 22:54:01 +08:00
parent b928c796cb
commit 0fe91973f4
3 changed files with 32 additions and 7 deletions

View File

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

View File

@ -156,11 +156,35 @@ async function news_google(r, id) {
//等待五秒怕加载速度过慢 //等待五秒怕加载速度过慢
await delay(3); await delay(3);
//滑动次数 //滑动次数
let sum = getRandomInt(10, 50); let sum = getRandomInt(5, 9);
for (let index = 0; index < sum; index++) { for (let index = 0; index < sum; index++) {
RandomIntscrollBy(); RandomIntscrollBy();
await delay(getRandomInt(5, 10)); await delay(getRandomInt(5, 10));
} }
let news_array = $(".cDgn2c");
//随机点击模块
news_array[getRandomInt(0, news_array.length - 1)].click();
for (let index = 0; index < getRandomInt(3, 8); index++) {
RandomIntscrollBy();
await delay(getRandomInt(3, 8));
}
let new_array = $(".VDXfz");
let new_array_href = [];
for (let index = 0; index < new_array.length; index++) {
const element = new_array[index];
console.log(element.getAttribute("href"));
let url = element.getAttribute("href").replace(/\./g, "");
new_array_href.push(`https://news.google.com${url}`);
}
// for (let index = 0; index < new_array_href.length; index++) {
//这里只打开4个链接太多了有毒
for (let index = 0; index < 4; index++) {
const element = new_array_href[index];
let a = open(element);
// console.log(JSON.stringify(a))
await delay(3);
a.close();
}
send_close(id); send_close(id);
} }
//谷歌商店浏览 //谷歌商店浏览
@ -180,7 +204,7 @@ async function play_google(r, id) {
try { try {
popular_games[getRandomInt(0, popular_games.length - 1)].click(); popular_games[getRandomInt(0, popular_games.length - 1)].click();
} catch (error) { } catch (error) {
console.log(error) console.log(error);
} }
let a = getRandomInt(3, 5); let a = getRandomInt(3, 5);
for (let index = 0; index < a; index++) { for (let index = 0; index < a; index++) {
@ -252,12 +276,13 @@ chrome.runtime.sendMessage(
{ name: "play_google", funct: play_google }, { name: "play_google", funct: play_google },
{ name: "shopping", funct: shopping }, { name: "shopping", funct: shopping },
]; ];
let is_Match = false;
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) {
is_Match = true;
funct(r, id); funct(r, id);
} }
} }

View File

@ -17,7 +17,7 @@
<script type="text/javascript" src="js/popup.js"></script> <script type="text/javascript" src="js/popup.js"></script>
</head> </head>
<body> <body>
<div style="width: 520px;height: 470px;text-align: center;margin: auto;"> <div style="text-align: center;margin: auto;">
<h2 style="color: #2159f3;">谷歌养号脚本手机版</h2> <h2 style="color: #2159f3;">谷歌养号脚本手机版</h2>
</div> </div>
</body> </body>