From 95e3a23feb164f2d68145d9ad88a11c1d0d7ffce Mon Sep 17 00:00:00 2001 From: lingling <1077478963@qq.com> Date: Mon, 26 Aug 2024 09:20:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=94=A8=E4=B8=8D=E4=B8=8A?= =?UTF-8?q?=E7=9A=84=E4=BB=A3=E7=A0=81=20=E5=A2=9E=E5=8A=A0=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=20=E5=A2=9E=E5=8A=A0=E4=B9=B1=E5=BA=8F=E6=89=A7?= =?UTF-8?q?=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.txt | 3 + js/popup.js | 11 +++- lib/content.js | 146 +++++++++---------------------------------------- 3 files changed, 38 insertions(+), 122 deletions(-) diff --git a/README.txt b/README.txt index 13e0791..e38533d 100644 --- a/README.txt +++ b/README.txt @@ -1,3 +1,6 @@ +aa4f2a6 修复邮箱回复 会回复谷歌官方邮件 +720df83 增加标准注释 +006d6bb 重命名打包文件根据时间生成 删除不需要的代码 7d99c8f 增加谷歌购物浏览页面 295ae02 增加打包日志 9598f66 提交快速打包脚本 diff --git a/js/popup.js b/js/popup.js index 440be99..3ad03ac 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-24 09:25:13 + * @LastEditTime: 2024-08-26 09:19:35 * @FilePath: \谷歌自动搜索邮箱自动点击v3\js\popup.js * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -38,6 +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; + } } // 浏览器监听事件 每当有新页面生成就会执行 chrome.runtime.onMessage.addListener(function ( @@ -105,6 +112,8 @@ $(function () { queue.push(play_google); queue.push(news_google); queue.push(youtube_shorts); + //乱序执行 + queue=shuffleArray(queue) //当前执行的队列索引 let closed_index = 0; diff --git a/lib/content.js b/lib/content.js index 8b77935..ab8f79a 100644 --- a/lib/content.js +++ b/lib/content.js @@ -50,126 +50,11 @@ function searchStringContainsArrayKeywords(str, arr) { return false; } -//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); - - while (true) { - await run((randomTime = list[i])); - // await delay((list[i] + 2000)/1000); - } - - // 定义一个执行函数 - 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); -} - +/** + * 谷歌商城 + * @param {*} r + * @param {*} id + */ async function shopping(r, id) { let number = getRandomInt(2, 10); for (let index = 0; index < number; index++) { @@ -179,6 +64,11 @@ async function shopping(r, id) { send_close(id); } +/** + * 谷歌日历 + * @param {*} r + * @param {*} id + */ async function calendar(r, id) { await delay(3); let number = getRandomInt(2, 5); @@ -198,6 +88,11 @@ async function calendar(r, id) { send_close(id); } +/** + * 谷歌新闻 + * @param {*} r + * @param {*} id + */ async function news_google(r, id) { console.log("加在完成开始等待8秒"); //等待五秒怕加载速度过慢 @@ -250,7 +145,11 @@ async function play_google(r, id) { // send_close(id); } - +/** + * 谷歌财经 + * @param {*} r + * @param {*} id + */ async function play_finance(r, id) { await delay(5); let recommended_attention = $(".sbnBtf >li >a"); @@ -272,6 +171,11 @@ async function play_finance(r, id) { // send_close(id); } +/** + * 谷歌邮箱 + * @param {*} r + * @param {*} id + */ async function mail(r, id) { let emailReply = [ "우리 실장님이 승진을 축하하기 위해서 다음주 금요일에 (1월 21일에) 오후 5시에 XX 호텔에서 회식이 있습니다 첨부 파일에서 구체적이 정보을 참고하세요. ",