From a442efffc80c862f2c490a9d85b3f47cf412daa9 Mon Sep 17 00:00:00 2001 From: lingling <1077478963@qq.com> Date: Tue, 24 Sep 2024 12:12:32 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=B8=BA=E4=BC=98=E5=8C=96=E5=81=9A?= =?UTF-8?q?=E5=87=86=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/popup.js | 18 +++++++----------- lib/content.js | 43 +++++-------------------------------------- 2 files changed, 12 insertions(+), 49 deletions(-) diff --git a/js/popup.js b/js/popup.js index 863fa26..a48955f 100644 --- a/js/popup.js +++ b/js/popup.js @@ -63,10 +63,6 @@ $(function () { return true; }); - // async function text() { - // let a = await createTab("https://www.youtube.com/", "youtube"); - // return a; - // } async function youtube_shorts() { let a = await createTab( "https://www.youtube.com/shorts/", @@ -105,13 +101,13 @@ $(function () { //函数队列 let queue = []; // queue.push(play_finance);//好像js注入不进去 - queue.push(shopping); - queue.push(calendar); - queue.push(mail); - // queue.push(youtube); - queue.push(play_google); - queue.push(news_google); - queue.push(youtube_shorts); + // queue.push(shopping); + // queue.push(calendar); + // queue.push(mail); + queue.push(youtube); + // queue.push(play_google); + // queue.push(news_google); + // queue.push(youtube_shorts); //乱序执行 此处有问题 // queue=shuffleArray(queue) //当前执行的队列索引 diff --git a/lib/content.js b/lib/content.js index 5c446ae..cb4389e 100644 --- a/lib/content.js +++ b/lib/content.js @@ -305,44 +305,11 @@ async function youtube_shorts2(r, id) { async function youtube(r, id) { // 点击长视频观看 await delay(5); - //点击订阅 如果已经订阅过了就不用点 - 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 - ); - if ( - next_vido == - $("contents ytd-compact-video-renderer div ytd-thumbnail a").length - ) - next_vido = next_vido - 1; - $("#contents ytd-compact-video-renderer div ytd-thumbnail a") - .eq(next_vido)[0] - .click(); + 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") + vido_array[getRandomInt(0,vido_array.length-1)].click() + await delay(5) + $(".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).click() + $(".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() } function ServiceLogin(r, id) { From 478c9ea959d1ea28abef3bf78a572420dbab384c Mon Sep 17 00:00:00 2001 From: lingling <1077478963@qq.com> Date: Tue, 24 Sep 2024 19:24:09 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/popup.js | 73 ++++++++++++++------------------------------------ lib/content.js | 73 ++++++++++++++++++++++++-------------------------- 2 files changed, 55 insertions(+), 91 deletions(-) diff --git a/js/popup.js b/js/popup.js index a48955f..d7934e5 100644 --- a/js/popup.js +++ b/js/popup.js @@ -38,13 +38,13 @@ $(function () { } ); }); - function shuffleArray(array) { - for (let i = array.length - 1; i > 0; i--) { - const j = Math.floor(Math.random() * (i + 1)); - [array[i], array[j]] = [array[j], array[i]]; - } - return array; } + function shuffleArray(array) { + for (let i = array.length - 1; i > 0; i--) { + const j = Math.floor(Math.random() * (i + 1)); + [array[i], array[j]] = [array[j], array[i]]; + } + return array; } // 浏览器监听事件 每当有新页面生成就会执行 chrome.runtime.onMessage.addListener(function ( @@ -57,60 +57,25 @@ $(function () { sendResponse({ name, id }); } if (request.ty == "remove") { - chrome.tabs.remove(request.id); } return true; }); - 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 = []; - // queue.push(play_finance);//好像js注入不进去 - // queue.push(shopping); - // queue.push(calendar); - // queue.push(mail); - queue.push(youtube); - // queue.push(play_google); - // queue.push(news_google); - // queue.push(youtube_shorts); //乱序执行 此处有问题 // queue=shuffleArray(queue) //当前执行的队列索引 + //函数队列 + let queue = [ + { url: "https://www.youtube.com/shorts/", tip: "youtube_shorts" }, + { url: "https://www.youtube.com/watch?v=LZ7DMB6h-hs", tip: "youtube" }, + { url: "https://play.google.com/", tip: "play_google" }, + { url: "https://shopping.google.com/", tip: "shopping" }, + { url: "https://shopping.google.com/", tip: "shopping" }, + { url: "https://calendar.google.com/calendar", tip: "calendar" }, + { url: "https://mail.google.com/mail/", tip: "mail" }, + { url: "https://www.google.com/finance/", tip: "play_finance" }, + ]; let closed_index = 0; function sendMsg(obj) { @@ -125,7 +90,9 @@ $(function () { chrome.tabs.onRemoved.addListener(async (windowId) => { console.log("Closed window: " + windowId); if (closed_index < queue.length) { - let tmp = await queue[closed_index](); + let url = queue[closed_index].url; + let tip = queue[closed_index].tip; + let tmp = await createTab(url, tip); // console.log(tmp) sendMsg(tmp); closed_index++; diff --git a/lib/content.js b/lib/content.js index cb4389e..39acdfb 100644 --- a/lib/content.js +++ b/lib/content.js @@ -305,11 +305,21 @@ async function youtube_shorts2(r, id) { async function youtube(r, id) { // 点击长视频观看 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") - vido_array[getRandomInt(0,vido_array.length-1)].click() - await delay(5) - $(".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).click() - $(".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() + 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" + ); + vido_array[getRandomInt(0, vido_array.length - 1)].click(); + await delay(5); + $( + ".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) + .click(); + $( + ".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(); } function ServiceLogin(r, id) { @@ -345,39 +355,26 @@ chrome.runtime.sendMessage( let r = obj.name; let id = obj.id; console.log("传递过来的obj" + JSON.stringify(obj)); - switch (r) { - case "naver": - naver(r, id); - break; - case "youtube": - youtube(r, id); - break; - case "youtube_shorts": - youtube_shorts2(r, id); - break; - case "news_google": - news_google(r, id); - break; - case "play_google": - play_google(r, id); - break; - case "play_finance": - play_finance(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: - break; + let functoons = [ + { name: "naver", funct: naver }, + { name: "youtube", funct: youtube }, + { name: "youtube_shorts", funct: youtube_shorts2 }, + { name: "news_google", funct: news_google }, + { name: "play_google", funct: play_google }, + { name: "play_finance", funct: play_finance }, + { name: "mail", funct: mail }, + { name: "calendar", funct: calendar }, + { name: "shopping", funct: shopping }, + ]; + let is_Match = false; + 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) { + is_Match = true; + funct(r, id); + } } } ); From e753f095c0d4525cbf8b2108aac11f9f3625483a Mon Sep 17 00:00:00 2001 From: lingling <1077478963@qq.com> Date: Thu, 26 Sep 2024 14:51:50 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E9=80=9A=E8=BF=87=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/popup.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/js/popup.js b/js/popup.js index d7934e5..d49833f 100644 --- a/js/popup.js +++ b/js/popup.js @@ -68,13 +68,12 @@ $(function () { //函数队列 let queue = [ { url: "https://www.youtube.com/shorts/", tip: "youtube_shorts" }, - { url: "https://www.youtube.com/watch?v=LZ7DMB6h-hs", tip: "youtube" }, + // { url: "https://www.youtube.com/watch?v=LZ7DMB6h-hs", tip: "youtube" }, { url: "https://play.google.com/", tip: "play_google" }, { url: "https://shopping.google.com/", tip: "shopping" }, - { url: "https://shopping.google.com/", tip: "shopping" }, { url: "https://calendar.google.com/calendar", tip: "calendar" }, { url: "https://mail.google.com/mail/", tip: "mail" }, - { url: "https://www.google.com/finance/", tip: "play_finance" }, + // { url: "https://www.google.com/finance/", tip: "play_finance" }, ]; let closed_index = 0;