增加youtube函数

This commit is contained in:
lingling 2024-08-26 14:34:55 +08:00
parent 1d1789d55c
commit 07b66a021d
2 changed files with 53 additions and 40 deletions

View File

@ -98,15 +98,20 @@ $(function () {
let a = await createTab("https://shopping.google.com/", "shopping"); let a = await createTab("https://shopping.google.com/", "shopping");
return a; return a;
} }
async function youtube() {
let a = await createTab("https://www.youtube.com/", "youtube");
return a;
}
//函数队列 //函数队列
let queue = []; let queue = [];
// queue.push(play_finance);//好像js注入不进去 // queue.push(play_finance);//好像js注入不进去
// queue.push(shopping); queue.push(shopping);
// queue.push(calendar); queue.push(calendar);
queue.push(mail); queue.push(mail);
// queue.push(play_google); // queue.push(youtube);
// queue.push(news_google); queue.push(play_google);
// queue.push(youtube_shorts); queue.push(news_google);
queue.push(youtube_shorts);
//乱序执行 此处有问题 //乱序执行 此处有问题
// queue=shuffleArray(queue) // queue=shuffleArray(queue)
//当前执行的队列索引 //当前执行的队列索引

View File

@ -1,7 +1,7 @@
/** /**
* 阻塞代码运行 * 阻塞代码运行
* @param {*} n 秒数 * @param {*} n 秒数
* @returns * @returns
*/ */
function delay(n) { function delay(n) {
return new Promise(function (resolve) { return new Promise(function (resolve) {
@ -12,7 +12,7 @@ function delay(n) {
* 随机数生成 * 随机数生成
* @param {*} min 最小值 * @param {*} min 最小值
* @param {*} max 最大值 * @param {*} max 最大值
* @returns * @returns
*/ */
function getRandomInt(min, max) { function getRandomInt(min, max) {
min = Math.ceil(min); min = Math.ceil(min);
@ -36,7 +36,7 @@ const naver = async (r, id) => {
send_close(id); send_close(id);
}; };
/** /**
* *
* @param {*} str 字符串 * @param {*} str 字符串
* @param {*} arr 需要匹配的字符串数组 * @param {*} arr 需要匹配的字符串数组
* @returns boole * @returns boole
@ -52,8 +52,8 @@ function searchStringContainsArrayKeywords(str, arr) {
/** /**
* 谷歌商城 * 谷歌商城
* @param {*} r * @param {*} r
* @param {*} id * @param {*} id
*/ */
async function shopping(r, id) { async function shopping(r, id) {
let number = getRandomInt(2, 10); let number = getRandomInt(2, 10);
@ -66,8 +66,8 @@ async function shopping(r, id) {
/** /**
* 谷歌日历 * 谷歌日历
* @param {*} r * @param {*} r
* @param {*} id * @param {*} id
*/ */
async function calendar(r, id) { async function calendar(r, id) {
await delay(3); await delay(3);
@ -90,36 +90,35 @@ async function calendar(r, id) {
/** /**
* 谷歌新闻 * 谷歌新闻
* @param {*} r * @param {*} r
* @param {*} id * @param {*} id
*/ */
async function news_google(r, id) { async function news_google(r, id) {
//等待五秒怕加载速度过慢 //等待五秒怕加载速度过慢
await delay(3); await delay(3);
//点击完整报道 //点击完整报道
try { try {
$('.jKHa4e')[0].click() $(".jKHa4e")[0].click();
for (let index = 0; index < getRandomInt(3,5); index++) { for (let index = 0; index < getRandomInt(3, 5); index++) {
RandomIntscrollBy() RandomIntscrollBy();
await delay(3) await delay(3);
} }
let new_array=$('.VDXfz') let new_array = $(".VDXfz");
let new_array_href=[] let new_array_href = [];
for (let index = 0; index < new_array.length; index++) { for (let index = 0; index < new_array.length; index++) {
const element = new_array[index]; const element = new_array[index];
console.log(element.getAttribute("href")) console.log(element.getAttribute("href"));
let url = element.getAttribute("href").replace(/\./g, ''); let url = element.getAttribute("href").replace(/\./g, "");
new_array_href.push(`https://news.google.com${url}`) new_array_href.push(`https://news.google.com${url}`);
} }
for (let index = 0; index < new_array_href.length; index++) { for (let index = 0; index < new_array_href.length; index++) {
const element = new_array_href[index]; const element = new_array_href[index];
let a= open(element) let a = open(element);
await delay(3) await delay(3);
a.close() a.close();
} }
} catch (error) { } catch (error) {
console.log(error) console.log(error);
} }
send_close(id); send_close(id);
} }
@ -151,8 +150,8 @@ async function play_google(r, id) {
} }
/** /**
* 谷歌财经 * 谷歌财经
* @param {*} r * @param {*} r
* @param {*} id * @param {*} id
*/ */
async function play_finance(r, id) { async function play_finance(r, id) {
await delay(5); await delay(5);
@ -177,8 +176,8 @@ async function play_finance(r, id) {
/** /**
* 谷歌邮箱 * 谷歌邮箱
* @param {*} r * @param {*} r
* @param {*} id * @param {*} id
*/ */
async function mail(r, id) { async function mail(r, id) {
let emailReply = [ let emailReply = [
@ -216,15 +215,22 @@ async function mail(r, id) {
// console.log(mails_is_google[index].getElementsByClassName('yX xY')[0].children[1].children[0].children[0].getAttribute("email")) // console.log(mails_is_google[index].getElementsByClassName('yX xY')[0].children[1].children[0].children[0].getAttribute("email"))
// console.log(mails_is_google[index].children[4].children[1].children[0].children[0].getAttribute("email")) // console.log(mails_is_google[index].children[4].children[1].children[0].children[0].getAttribute("email"))
//获取邮件发送人 //获取邮件发送人
let mail_for = mails_is_google[index].getElementsByClassName('yX xY')[0].children[1].children[0].children[0].getAttribute("email") let mail_for = mails_is_google[index]
.getElementsByClassName("yX xY")[0]
.children[1].children[0].children[0].getAttribute("email");
//是否回复 //是否回复
let whether_or_not_to_reply_to= searchStringContainsArrayKeywords(mail_for,['google','youtube','gbcloud']) let whether_or_not_to_reply_to = searchStringContainsArrayKeywords(
mail_for,
["google", "youtube", "gbcloud"]
);
//逻辑取反 //逻辑取反
whether_or_not_to_reply_to=!whether_or_not_to_reply_to whether_or_not_to_reply_to = !whether_or_not_to_reply_to;
console.log(`当前邮件发送人:${mail_for} 是否回复${whether_or_not_to_reply_to}`) console.log(
`当前邮件发送人:${mail_for} 是否回复${whether_or_not_to_reply_to}`
);
//邮箱回复 //邮箱回复
if (getRandomInt(0, 1) == 0&&whether_or_not_to_reply_to) { if (getRandomInt(0, 1) == 0 && whether_or_not_to_reply_to) {
$(".amn >.ams.bkH").click(); $(".amn >.ams.bkH").click();
await delay(getRandomInt(1, 5)); await delay(getRandomInt(1, 5));
let text = emailReply[getRandomInt(0, emailReply.length - 1)]; let text = emailReply[getRandomInt(0, emailReply.length - 1)];
@ -297,9 +303,8 @@ async function youtube_shorts2(r, id) {
} }
async function youtube(r, id) { async function youtube(r, id) {
alert("youto");
// 点击长视频观看 // 点击长视频观看
await delay(10); await delay(5);
//点击订阅 如果已经订阅过了就不用点 //点击订阅 如果已经订阅过了就不用点
if ( if (
$( $(
@ -401,6 +406,9 @@ chrome.runtime.sendMessage(
case "shopping": case "shopping":
shopping(r, id); shopping(r, id);
break; break;
case "youtube":
youtube(r, id);
break;
default: default:
break; break;
} }