Compare commits

..

No commits in common. "97c552695e4d2d82d65cf7381f6c7467fa056c10" and "d57fe2b04dfb33b9d18362da80cb90d40247732f" have entirely different histories.

2 changed files with 120 additions and 48 deletions

View File

@ -2,7 +2,7 @@
* @Author: lingling 1077478963@qq.com * @Author: lingling 1077478963@qq.com
* @Date: 2024-08-19 09:47:04 * @Date: 2024-08-19 09:47:04
* @LastEditors: lingling 1077478963@qq.com * @LastEditors: lingling 1077478963@qq.com
* @LastEditTime: 2024-09-30 09:38:57 * @LastEditTime: 2024-09-29 14:07:35
* @FilePath: \谷歌自动搜索邮箱自动点击v3\js\popup.js * @FilePath: \谷歌自动搜索邮箱自动点击v3\js\popup.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
@ -72,19 +72,56 @@ $(function () {
}); });
//乱序执行 此处有问题 async function google() {
// queue=shuffleArray(queue) let a = await createTab("https://www.google.com", "naver");
//当前执行的队列索引 return a;
}
async function youtube_shorts() {
let a = await createTab(
"https://www.youtube.com/shorts/",
"youtube_shorts"
);
return a;
}
async function news_google() {
let a = await createTab("https://news.google.com/", "news_google");
return a;
}
async function play_google() {
let a = await createTab("https://play.google.com/", "play_google");
return a;
}
async function play_finance() {
let a = await createTab("https://www.google.com/finance/", "play_finance");
return a;
}
async function mail() {
let a = await createTab("https://mail.google.com/mail/", "mail");
return a;
}
async function calendar() {
let a = await createTab("https://calendar.google.com/calendar", "calendar");
return a;
}
async function shopping() {
let a = await createTab("https://shopping.google.com/", "shopping");
return a;
}
async function youtube() {
let a = await createTab("https://www.youtube.com/", "youtube");
return a;
}
//函数队列 //函数队列
let queue = [ let queue = [];
{ url: "https://www.youtube.com/shorts/", tip: "youtube_shorts" }, queue.push(google);
// { url: "https://www.youtube.com/watch?v=LZ7DMB6h-hs", tip: "youtube" }, // queue.push(play_finance);//好像js注入不进去
{ url: "https://play.google.com/", tip: "play_google" }, // queue.push(shopping);
{ url: "https://shopping.google.com/", tip: "shopping" }, // queue.push(calendar);
{ url: "https://calendar.google.com/calendar", tip: "calendar" }, // queue.push(mail);
{ url: "https://mail.google.com/mail/", tip: "mail" }, // queue.push(youtube);
// { url: "https://www.google.com/finance/", tip: "play_finance" }, // queue.push(play_google);
]; // queue.push(youtube_shorts);
// queue.push(news_google);
let closed_index = 0; let closed_index = 0;
function sendMsg(obj) { function sendMsg(obj) {
@ -99,9 +136,7 @@ $(function () {
chrome.tabs.onRemoved.addListener(async (windowId) => { chrome.tabs.onRemoved.addListener(async (windowId) => {
console.log("Closed window: " + windowId); console.log("Closed window: " + windowId);
if (closed_index < queue.length) { if (closed_index < queue.length) {
let url = queue[closed_index].url; let tmp = await queue[closed_index]();
let tip = queue[closed_index].tip;
let tmp = await createTab(url, tip);
// console.log(tmp) // console.log(tmp)
sendMsg(tmp); sendMsg(tmp);
closed_index++; closed_index++;

View File

@ -330,20 +330,43 @@ async function youtube_shorts2(r, id) {
async function youtube(r, id) { async function youtube(r, id) {
// 点击长视频观看 // 点击长视频观看
await delay(5); await delay(5);
let vido_array = $( //点击订阅 如果已经订阅过了就不用点
".yt-core-image.yt-core-image--fill-parent-height.yt-core-image--fill-parent-width.yt-core-image--content-mode-scale-aspect-fill.yt-core-image--loaded" 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();
// 点赞
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();
$("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
); );
vido_array[getRandomInt(0, vido_array.length - 1)].click(); if (
await delay(5); next_vido ==
$( $("contents ytd-compact-video-renderer div ytd-thumbnail a").length
".yt-spec-button-shape-next.yt-spec-button-shape-next--tonal.yt-spec-button-shape-next--mono.yt-spec-button-shape-next--size-m.yt-spec-button-shape-next--icon-leading.yt-spec-button-shape-next--segmented-start"
) )
.eq(0) next_vido = next_vido - 1;
.click(); $("#contents ytd-compact-video-renderer div ytd-thumbnail a")
$( .eq(next_vido)[0]
".yt-spec-button-shape-next.yt-spec-button-shape-next--filled.yt-spec-button-shape-next--mono.yt-spec-button-shape-next--size-m"
)
.eq(0)
.click(); .click();
} }
@ -398,26 +421,40 @@ chrome.runtime.sendMessage(
let r = obj.name; let r = obj.name;
let id = obj.id; let id = obj.id;
console.log("传递过来的obj" + JSON.stringify(obj)); console.log("传递过来的obj" + JSON.stringify(obj));
let functoons = [ switch (r) {
{ name: "naver", funct: naver }, case "naver":
{ name: "youtube", funct: youtube }, naver(r, id);
{ name: "youtube_shorts", funct: youtube_shorts2 }, break;
{ name: "news_google", funct: news_google }, case "youtube":
{ name: "play_google", funct: play_google }, youtube(r, id);
{ name: "play_finance", funct: play_finance }, break;
{ name: "mail", funct: mail }, case "youtube_shorts":
{ name: "calendar", funct: calendar }, youtube_shorts2(r, id);
{ name: "shopping", funct: shopping }, break;
]; case "news_google":
let is_Match = false; news_google(r, id);
for (let index = 0; index < functoons.length; index++) { break;
// const element = functoons[index]; case "play_google":
let name = functoons[index].name; play_google(r, id);
let funct = functoons[index].funct; break;
if (r == name) { case "play_finance":
is_Match = true; play_finance(r, id);
funct(r, id); break;
} case "mail":
mail(r, id);
break;
case "calendar":
calendar(r, id);
break;
case "shopping":
shopping(r, id);
break;
case "youtube":
youtube(r, id);
break;
default:
all()
break;
} }
} }
); );