From e4929f6faa2647b9ac69faa01338395890dfc06b Mon Sep 17 00:00:00 2001 From: lingling <1077478963@qq.com> Date: Tue, 20 Aug 2024 14:26:52 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9C=80=E8=A6=81=E8=87=AA=E5=B7=B1=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=20=E8=84=9A=E6=9C=AC=20=E5=AF=BC=E5=85=A5=E8=BF=9B?= =?UTF-8?q?=E6=9D=A5=E7=9A=84=E8=84=9A=E6=9C=AC=E9=83=BD=E6=9C=89=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/popup.js | 14 +- lib/content.js | 338 ++++++++++++++++++++++++++++++++++++++++--------- manifest.json | 2 +- 3 files changed, 283 insertions(+), 71 deletions(-) diff --git a/js/popup.js b/js/popup.js index 6006b28..0e4e7f0 100644 --- a/js/popup.js +++ b/js/popup.js @@ -2,7 +2,7 @@ * @Author: lingling 1077478963@qq.com * @Date: 2024-08-19 09:47:04 * @LastEditors: lingling 1077478963@qq.com - * @LastEditTime: 2024-08-20 10:57:32 + * @LastEditTime: 2024-08-20 14:12:27 * @FilePath: \谷歌自动搜索邮箱自动点击v3\js\popup.js * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -56,18 +56,18 @@ $(function () { }); async function text() { - let a= await createTab('https://www.baidu.com/','baidu') - return a - } - async function text2() { - let a= await createTab('https://www.so.com/','360') + let a= await createTab('https://www.youtube.com/','youtube') return a } +// async function text2() { +// let a= await createTab('https://www.so.com/','360') +// return a +// } //函数队列 let queue = []; queue.push(text) - queue.push(text2) +// queue.push(text2) //当前执行的队列索引 let closed_index=0; diff --git a/lib/content.js b/lib/content.js index 59ab0c0..a5a3a8b 100644 --- a/lib/content.js +++ b/lib/content.js @@ -6,90 +6,302 @@ function delay(n) { } //随机数生成器 function getRandomInt(min, max) { - min = Math.ceil(min); - max = Math.floor(max); - return Math.floor(Math.random() * (max - min + 1)) + min; - } + min = Math.ceil(min); + max = Math.floor(max); + return Math.floor(Math.random() * (max - min + 1)) + min; +} //随机滑动函数 -function RandomIntscrollBy(y=0){ - let rand = getRandomInt(100,600) - scrollBy(0,y==0?rand:y); - console.log("随机滑动"+rand); +function RandomIntscrollBy(y = 0) { + let rand = getRandomInt(100, 600); + scrollBy(0, y == 0 ? rand : y); + console.log("随机滑动" + rand); } //naver使用函数 const naver = async (r, id) => { -// $("#kw").val("docker"); -// await delay(1); -// $("#su").click(); -// await delay(3); -// for (let index = 0; index < 4; index++) { -// RandomIntscrollBy() -// await delay(3); -// } + // $("#kw").val("docker"); + // await delay(1); + // $("#su").click(); + // await delay(3); + // for (let index = 0; index < 4; index++) { + // RandomIntscrollBy() + // await delay(3); + // } await delay(3); - send_close(id) + send_close(id); }; //naver使用函数 const sll360 = async (r, id) => { - // $("#kw").val("docker"); - // await delay(1); - // $("#su").click(); - // await delay(3); - // for (let index = 0; index < 4; index++) { - // RandomIntscrollBy() - // await delay(3); - // } - - console.log("??360") - await delay(3); - send_close(id) - }; + // $("#kw").val("docker"); + // await delay(1); + // $("#su").click(); + // await delay(3); + // for (let index = 0; index < 4; index++) { + // RandomIntscrollBy() + // await delay(3); + // } - const baidu = async (r, id) => { - // $("#kw").val("docker"); - // await delay(1); - // $("#su").click(); - // await delay(3); - // for (let index = 0; index < 4; index++) { - // RandomIntscrollBy() - // await delay(3); - // } - - console.log("??baidu") - await delay(30); - send_close(id) - }; + console.log("??360"); + await delay(3); + send_close(id); +}; - function send_close(id){ - chrome.runtime.sendMessage( - { - ty: "remove", - id:id - },) - } +const baidu = async (r, id) => { + // $("#kw").val("docker"); + // await delay(1); + // $("#su").click(); + // await delay(3); + // for (let index = 0; index < 4; index++) { + // RandomIntscrollBy() + // await delay(3); + // } + + console.log("??baidu"); + await delay(30); + send_close(id); +}; +//youto短视频 +async function youtube_shorts(r, id) { + i = 0; + // 随机执行次数 + randTime = Math.floor(Math.random() * 16) + 15; + console.log("执行", randTime, "次"); + + // 根据次数随机每次观看的时长 + const list = []; + for (let i = 0; i < randTime; i++) { + // 生成 1 到 5 之间的随机整数 + const randomNum = Math.floor(Math.random() * 44) + 5; //44 + // 将随机数添加到列表中 + list.push(randomNum * 1000); + } + console.log("每个视频的观看时长:", list); + + // 首次进入判断是否播放 + var playing = + document.querySelector("div.playing-mode") == null ? false : true; + var paused = document.querySelector("div.paused-mode") == null ? false : true; + console.log("playing", playing, "paused", paused); + if (playing) { + console.log("首次进入在播放!"); + } else { + await delay(5); + var playButton = document.getElementsByClassName( + "ytp-large-play-button ytp-button" + )[0]; + playButton.click(); + console.log("点击了播放!"); + } + + // 执行 + var dingshiqi_duanshipin = setInterval(() => { + run((randomTime = list[i])); + }, list[i] + 2000); + + // 定义一个执行函数 + async function run(randomTime) { + // 执行randTime次后停止 + console.log( + "总计:", + randTime, + "次,当前第:", + i + 1, + "次,观看时长:", + randomTime / 1000, + "s" + ); + if (i == randTime) { + console.log("已经执行", randTime, "次,关闭当前标签页!"); + clearInterval(dingshiqi_duanshipin); + send_close(id); + } + + // 点赞 + var button = document.querySelector( + ".yt-spec-button-shape-next--icon-button" + ); + console.log("是否已点赞:", button.getAttribute("aria-pressed")); + button.click(); + + bao = $("#shorts-inner-container ytd-reel-video-renderer"); + for (j = 0; j < bao.length; j++) { + // 如果是当前正在播放的视频 点赞+订阅 + if (typeof $(bao[j]).attr("is-active") == "string") { + dianzan = $(bao[j]).find("button")[23]; + dingyue = $(bao[j]).find("button")[20]; + // 点赞 + if ($(dianzan).is(".yt-spec-button-shape-next--tonal")) + $(dianzan).click(); + // 订阅 + if ($(dingyue).is(".yt-spec-button-shape-next--filled")) + $(dingyue).click(); + j = bao.length; + } + } + // 下一集 randomTime - 2s + await delay(randomTime); + $("div #navigation-button-down button").click(); + console.log("点击了下一个视频"); + i++; + } + + // 定时器 + let timer = setTimeout(function () { + location.reload(); + console.log("页面长时间无响应"); + }, 60000); // 设置超时时间为 5 秒钟 + + // 在每次页面有响应的时候,清除计时器即可 + window.addEventListener("click", function () { + console.log("页面有响应"); + // 清除计时器 + clearTimeout(timer); + // 判断是否再播放 + var playing = + document.querySelector("div.playing-mode") == null ? false : true; + var paused = + document.querySelector("div.paused-mode") == null ? false : true; + console.log("播放:", playing, "暂停:", paused); + if (playing) { + console.log("已播放!"); + } else { + var playButton = document.getElementsByClassName( + "ytp-large-play-button ytp-button" + )[0]; + playButton.click(); + console.log("点击了播放!"); + } + }); + send_close(id); +} + +async function youtube(r, id) { + alert("youto") + // 点击长视频观看 + await delay(10); + wb = Math.round( + Math.random() * $("div #contents ytd-rich-grid-row img").length + ); + if ( + $("div #contents ytd-rich-grid-row img") + .eq(wb) + .is(".yt-core-image--fill-parent-height") + ) + $("div #contents ytd-rich-grid-row img").eq(wb).click(); + else + $("div #contents ytd-rich-grid-row img") + .eq(wb + 1) + .click(); + + sum = 1; + // 循环播放 2分钟执行一次 执行5次后关闭 + var dingshiqi = setInterval(function () { + if (sum == 5) { + clearInterval(dingshiqi); + // 关闭当前窗口的所有标签 + const currentTab = window.location.href; + chrome.tabs.query({ currentWindow: true }, (tabs) => { + tabs.forEach((tab) => { + if (tab.url !== currentTab) { + chrome.tabs.remove(tab.id); + } + }); + }); + } + setTimeout(function () { + //点击订阅 如果已经订阅过了就不用点 + 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(); + }, 5000); + $("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(); + sum += 1; + send_close(id); + }, 240000); + // 1200000=20分钟 + // 240000=4分钟 +} + +function ServiceLogin(r, id) { + let mkeww = 0, + mue = setInterval(function () { + if ($("form ul>li img").length) { + clearInterval(mue); + setTimeout(function () { + $("form ul>li img").eq(0)[0].click(); + }, 1900); + } else { + mkeww++; + if (mkeww > 106) { + clearInterval(mue); + } + } + }, 500); + send_close(id); +} + +function send_close(id) { + chrome.runtime.sendMessage({ + ty: "remove", + id: id, + }); +} chrome.runtime.sendMessage( { ty: "get", }, function (obj) { - - let r=obj.name - let id=obj.id - console.log("传递过来的obj"+obj) + let r = obj.name; + let id = obj.id; + console.log("传递过来的obj" + JSON.stringify(obj)); switch (r) { case "naver": - naver(r, id); + naver(r, id); break; - case "360": - sll360(r, id); + case "360": + sll360(r, id); break; - case "baidu": - baidu(r, id); + case "baidu": + baidu(r, id); + break; + case "youtube": + youtube(r, id); break; default: break; @@ -97,6 +309,6 @@ chrome.runtime.sendMessage( } ); chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { - console.log(request) - sendResponse('我收到了你的情书,popup~') -}) \ No newline at end of file + console.log(request); + sendResponse("我收到了你的情书,popup~"); +}); diff --git a/manifest.json b/manifest.json index 359afd1..e1b4e48 100644 --- a/manifest.json +++ b/manifest.json @@ -15,7 +15,7 @@ "content_scripts": [ { "matches": [ - "https://www.naver.com/*","https://www.baidu.com/*","https://www.so.com/*" + "https://www.naver.com/*","https://www.baidu.com/*","https://www.so.com/*","https://www.youtube.com/*","https://www.youtube.com/shorts/*","https://www.google.com.hk/","https://www.google.com.hk/search?q=*","https://www.google.com/","https://www.google.com/search?q=*","https://mail.google.com/*","https://accounts.google.com/ServiceLogin*" ], "js": [ "lib/jquery-3.3.1.min.js",