修改了一部分

This commit is contained in:
lingling 2024-08-21 11:30:52 +08:00
parent e4929f6faa
commit 7084aedc74
3 changed files with 147 additions and 53 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-08-20 14:12:27 * @LastEditTime: 2024-08-21 11:27:44
* @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
*/ */
@ -20,7 +20,7 @@ $(function () {
id = e.id; id = e.id;
} }
); );
}, 2000); }, 1000);
function createTab(url, fname) { function createTab(url, fname) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
chrome.tabs.create( chrome.tabs.create(
@ -56,43 +56,65 @@ $(function () {
}); });
async function text() { async function text() {
let a= await createTab('https://www.youtube.com/','youtube') let a = await createTab("https://www.youtube.com/", "youtube");
return a return a;
}
// async function text2() {
// let a= await createTab('https://www.so.com/','360')
// return a
// }
async function text2() {
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 text2() {
// let a= await createTab('https://www.so.com/','360')
// return a
// }
//函数队列 //函数队列
let queue = []; let queue = [];
queue.push(text) // queue.push(text2)
// queue.push(text2) queue.push(news_google);
// queue.push(text2)
//当前执行的队列索引 //当前执行的队列索引
let closed_index=0; let closed_index = 0;
function sendMsg(obj){ function sendMsg(obj) {
chrome.runtime.sendMessage(obj, res => { chrome.runtime.sendMessage(obj, (res) => {
// 答复 // 答复
console.log('popup=>content') console.log("popup=>content");
console.log(res) console.log(res);
}) });
} }
// 浏览器监听事件 关闭标签页时就会执行 // 浏览器监听事件 关闭标签页时就会执行
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 tmp=await queue[closed_index]() let tmp = await queue[closed_index]();
// console.log(tmp) // console.log(tmp)
sendMsg(tmp) sendMsg(tmp);
closed_index++ closed_index++;
// sendResponse({ name, id }); // sendResponse({ name, id });
} }
}); });
chrome.tabs.onCreated.addListener( function sed_cont(id){
(e)=>{console.log(e);} let message = {
) info: '来自popup的情书💌'
}
chrome.tabs.sendMessage(id, message, res => {
console.log('popup=>content')
console.log(res)
})
}
chrome.tabs.onCreated.addListener((e) => {
sed_cont(id);
console.log(e);
console.log("创建了一个新的浏览器窗口")
});
}); });

View File

@ -28,7 +28,7 @@ const naver = async (r, id) => {
// RandomIntscrollBy() // RandomIntscrollBy()
// await delay(3); // await delay(3);
// } // }
await delay(3); await delay(1);
send_close(id); send_close(id);
}; };
@ -96,9 +96,14 @@ async function youtube_shorts(r, id) {
} }
// 执行 // 执行
var dingshiqi_duanshipin = setInterval(() => { // var dingshiqi_duanshipin = setInterval(() => {
run((randomTime = list[i])); // run((randomTime = list[i]));
}, list[i] + 2000); // }, list[i] + 2000);
while (true) {
await run((randomTime = list[i]));
// await delay((list[i] + 2000)/1000);
}
// 定义一个执行函数 // 定义一个执行函数
async function run(randomTime) { async function run(randomTime) {
@ -114,7 +119,7 @@ async function youtube_shorts(r, id) {
); );
if (i == randTime) { if (i == randTime) {
console.log("已经执行", randTime, "次,关闭当前标签页!"); console.log("已经执行", randTime, "次,关闭当前标签页!");
clearInterval(dingshiqi_duanshipin); // clearInterval(dingshiqi_duanshipin);
send_close(id); send_close(id);
} }
@ -177,8 +182,69 @@ async function youtube_shorts(r, id) {
send_close(id); send_close(id);
} }
async function news_google(r, id) {
console.log("加在完成开始等待8秒")
//等待五秒怕加载速度过慢
await delay(10);
console.log("等待8秒完成")
//焦点新闻 数量
let new_length = $(".KDoq1").length;
//点击会创建新标签暂时没办法控制
// let rand_new_index=getRandomInt(0,new_length)
//点击焦点新闻
$("#i10").click();
$(".KDoq1")[0].click();
// console.log( $("#i10"))
// await delay(10);
// let the_number_of_swipes = getRandomInt(3, 6);
// for (let index = 0; index < the_number_of_swipes; index++) {
// RandomIntscrollBy();
// await delay(getRandomInt(10, 30));
// }
send_close(id);
}
async function youtube_shorts2(r, id) {
//等待五秒怕加载速度过慢
await delay(5);
//观看次数
let views = getRandomInt(5, 10);
for (let index = 0; index < views; index++) {
//观看多少秒
let watch_time = getRandomInt(10, 30);
await delay(getRandomInt(2, 5));
//随机暂停播放
if (getRandomInt(0, 1) == 0) {
$(".video-stream.html5-main-video").click();
await delay(getRandomInt(2, 5));
$(".video-stream.html5-main-video").click();
await delay(watch_time);
}
//点赞
// $('.yt-spec-button-shape-next.yt-spec-button-shape-next--tonal.yt-spec-button-shape-next--mono.yt-spec-button-shape-next--size-l.yt-spec-button-shape-next--icon-button').click()
//评论区操作
if (getRandomInt(0, 1) == 0) {
//打开评论区
$(
"#comments-button > ytd-button-renderer > yt-button-shape > label > button > yt-touch-feedback-shape > div > div.yt-spec-touch-feedback-shape__fill"
).click();
await delay(getRandomInt(3, 5));
//随机滑动评论区
RandomIntscrollBy();
//关闭评论区
$(
"#visibility-button > ytd-button-renderer > yt-button-shape > button > yt-touch-feedback-shape > div > div.yt-spec-touch-feedback-shape__stroke"
).click();
}
RandomIntscrollBy(600);
}
//看完关闭窗口
send_close(id);
}
async function youtube(r, id) { async function youtube(r, id) {
alert("youto") alert("youto");
// 点击长视频观看 // 点击长视频观看
await delay(10); await delay(10);
wb = Math.round( wb = Math.round(
@ -303,6 +369,12 @@ chrome.runtime.sendMessage(
case "youtube": case "youtube":
youtube(r, id); youtube(r, id);
break; break;
case "youtube_shorts":
youtube_shorts2(r, id);
break;
case "news_google":
news_google(r, id);
break;
default: default:
break; break;
} }

View File

@ -15,7 +15,7 @@
"content_scripts": [ "content_scripts": [
{ {
"matches": [ "matches": [
"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*" "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*","https://news.google.com/*"
], ],
"js": [ "js": [
"lib/jquery-3.3.1.min.js", "lib/jquery-3.3.1.min.js",