Compare commits

..

2 Commits
dev ... main

7 changed files with 46 additions and 294 deletions

View File

@ -1,4 +1,3 @@
0a57ec1 修改任务启动顺序
2177638 修改打包逻辑
07b66a0 增加youtube函数
1d1789d 修复邮箱卡住问题

View File

@ -1,66 +1,4 @@
/*
* @Author: lingling 1077478963@qq.com
* @Date: 2024-08-19 09:47:04
* @LastEditors: lingling 1077478963@qq.com
* @LastEditTime: 2024-09-29 14:41:33
* @FilePath: \谷歌自动搜索邮箱自动点击v3\js\background.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
//记录谷歌账户
let Ggoogle_mail = "";
//记录是否有运行权限
let executionAuthority = false;
//是否查询过
let haveYouChecked = false;
/**
* 查看是否有权限运行
* @param {*} google_mail 谷歌id
*/
async function viewPermission(google_mail) {
try {
let tmp = await axios.post(
"http://149.129.107.38:8787/index/queryauthorization",
{ google_account: google_mail }
);
if (tmp.data.code == 200) {
executionAuthority = true;
Ggoogle_mail = google_mail;
return true;
}
return false;
} catch (error) {
console.error("Error fetching permission:", error);
return false;
} finally {
haveYouChecked = true; // 保证状态更新,即使出现错误
}
}
/**
* 监听消息
* @param {*} req 发送过来的消息
* @param {*} sendResponse 返回消息
*/
chrome.runtime.onMessage.addListener(async (req, sender, sendResponse) => {
if (req.ty === "viewPermission") {
if (haveYouChecked) {
// 如果已经查询过,直接返回权限状态
sendResponse(executionAuthority);
} else {
// 没有查询过,执行异步查询
const res = req.info;
const data = await viewPermission(res);
// const data = true;
sendResponse(data); // 异步响应结果
}
return true; // 保持消息通道开放,等待异步 sendResponse
}
// 其他消息类型的处理
return false; // 关闭通道,表示没有需要处理的异步操作
});
// 启动扩展时自动创建一个新标签页
setTimeout(function () {
chrome.tabs.create({ url: "popup.html" });
}, 3500);
setTimeout(function(){
chrome.tabs.create({ url: "popup.html" }, function () {
})
},3500);

View File

@ -2,23 +2,12 @@
* @Author: lingling 1077478963@qq.com
* @Date: 2024-08-19 09:47:04
* @LastEditors: lingling 1077478963@qq.com
* @LastEditTime: 2024-09-30 09:40:14
* @LastEditTime: 2024-08-26 14:50:09
* @FilePath: \谷歌自动搜索邮箱自动点击v3\js\popup.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
$(function () {
/**
* 数组打乱随机执行
* @param {*} array
* @returns
*/
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;
}
// var id = 0, due = ['Dell', ' Lenovo ', "ASUS"], kme = 0 , name="";
var id = 0;
var name = "";
setTimeout(function () {
@ -50,6 +39,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 (
request,
@ -61,13 +57,9 @@ $(function () {
sendResponse({ name, id });
}
if (request.ty == "remove") {
chrome.tabs.remove(sender.tab.id);
chrome.tabs.remove(request.id);
}
if (request.ty == "get" || request.ty == "remove") {
return true;
} else {
return false;
}
});
//乱序执行 此处有问题
@ -75,13 +67,12 @@ $(function () {
//当前执行的队列索引
//函数队列
let queue = [
{ url: "https://www.google.com", tip: "naver" },
// { url: "https://www.youtube.com/shorts/", tip: "youtube_shorts" },
{ 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://calendar.google.com/calendar", tip: "calendar" },
// { url: "https://mail.google.com/mail/", tip: "mail" },
{ url: "https://play.google.com/", tip: "play_google" },
{ 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;
@ -110,9 +101,25 @@ $(function () {
chrome.tabs.query({}, function (tabs) {
// 遍历每个标签页并关闭它们
for (var i = 0; i < tabs.length; i++) {
// chrome.tabs.remove(tabs[i].id);
chrome.tabs.remove(tabs[i].id);
}
});
}
});
function sed_cont(id) {
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("创建了一个新的浏览器窗口");
});
});

2
lib/axios.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -30,35 +30,10 @@ function RandomIntscrollBy(y = 0) {
console.log("随机滑动" + rand);
}
/**
* 判断打开的浏览器页面是PC端还是移动端
* @returns mobile_web:手机PCPC
*/
function is_mobile_web(){
return /Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent) ? true : false
}
//naver使用函数
const all = async (r, id) => {
for (let index = 0; index < 10; index++) {
await delay(1)
console.log(`共等待10秒当前${index+1}`)
}
send_close(id);
};
//naver使用函数
const naver = async (r, id) => {
let googelid_str = (elements = $(".gb_A.gb_Za.gb_0").attr("aria-label"));
const emailRegex = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/;
const match = googelid_str.match(emailRegex);
const email = match ? match[0] : null;
console.log(`email:${email} r:${r} id${id}`)
let res = await to_background(email);
console.log(`res:${res} emall:${email}`);
await delay(10)
// send_close(id);
// await delay(1);
send_close(id);
};
/**
*
@ -347,147 +322,6 @@ async function youtube(r, id) {
.click();
}
/**
* 谷歌商城手机版
* @param {*} r
* @param {*} id
*/
async function shopping_phone(r, id) {
let number = getRandomInt(2, 10);
for (let index = 0; index < number; index++) {
for (let index = 0; index < getRandomInt(2, 5); index++) {
RandomIntscrollBy();
await delay(getRandomInt(5, 10));
}
//获取所有的商品链接
let sp = document.getElementsByClassName(
"gkQHve RmEs5b zypKDd aKoISd RycMEf"
);
//触发点击事件
sp[getRandomInt(0, sp.length - 1)].click();
await delay(getRandomInt(10, 20));
//获取关闭按钮
let close = document.getElementsByClassName(
"ioQ39e wv9iH MjJqGe cd29Sd"
)[0];
close.click();
await delay(getRandomInt(2, 5));
}
send_close(id);
}
/**
* 谷歌新闻手机版本
* @param {*} r
* @param {*} id
*/
async function news_google_phone(r, id) {
//等待五秒怕加载速度过慢
await delay(3);
//滑动次数
let sum = getRandomInt(5, 9);
for (let index = 0; index < sum; index++) {
RandomIntscrollBy();
await delay(getRandomInt(5, 10));
}
let news_array = $(".cDgn2c");
//随机点击模块
news_array[getRandomInt(0, news_array.length - 1)].click();
for (let index = 0; index < getRandomInt(3, 8); index++) {
RandomIntscrollBy();
await delay(getRandomInt(3, 8));
}
let new_array = $(".VDXfz");
let new_array_href = [];
for (let index = 0; index < new_array.length; index++) {
const element = new_array[index];
console.log(element.getAttribute("href"));
let url = element.getAttribute("href").replace(/\./g, "");
new_array_href.push(`https://news.google.com${url}`);
}
// for (let index = 0; index < new_array_href.length; index++) {
//这里只打开4个链接太多了有毒
for (let index = 0; index < 4; index++) {
const element = new_array_href[index];
let a = open(element);
// console.log(JSON.stringify(a))
await delay(3);
a.close();
}
send_close(id);
}
/**
* 谷歌商店手机版
* @param {*} r
* @param {*} id
*/
async function play_google_phone(r, id) {
//等待五秒怕加载速度过慢
await delay(5);
//滑动次数
let a = getRandomInt(3, 5);
for (let index = 0; index < a; index++) {
RandomIntscrollBy();
await delay(getRandomInt(0, 5));
}
//热门游戏随机列表 直接触发点击事件就行
let popular_games = document.querySelectorAll("a.Si6A0c.itIJzb");
for (let index = 0; index < getRandomInt(3, 5); index++) {
try {
popular_games[getRandomInt(0, popular_games.length - 1)].click();
} catch (error) {
console.log(error);
}
let a = getRandomInt(3, 5);
for (let index = 0; index < a; index++) {
RandomIntscrollBy();
await delay(getRandomInt(0, 5));
}
$(".f0UV3d").click();
await delay(getRandomInt(5, 10));
}
await delay(getRandomInt(5, 10));
//
send_close(id);
}
/**
* youtube手机版本
* @param {*} r
* @param {*} id
*/
async function youtube(r, id) {
async function whict() {
await delay(5);
for (let index = 0; index < getRandomInt(5, 10); index++) {
RandomIntscrollBy();
}
let all_video = $(".media-item-thumbnail-container");
all_video[getRandomInt(0, all_video.length - 1)].click();
// if(getRandomInt(0,1)==0){
// //点赞
// document.getElementsByClassName('yt-spec-touch-feedback-shape__fill')[3].click()
// //订阅
// document.getElementsByClassName('yt-spec-touch-feedback-shape__fill')[2].click()
// }
await delay(getRandomInt(300, 1800));
}
for (let index = 0; index < getRandomInt(5, 10); index++) {
await whict();
}
//看完关闭窗口
send_close(id);
}
/**
* 不知道什么东西
* @param {*} r
* @param {*} id
*/
function ServiceLogin(r, id) {
let mkeww = 0,
mue = setInterval(function () {
@ -512,35 +346,12 @@ function send_close(id) {
id: id,
});
}
async function to_background(params) {
return new Promise((resolve, reject) => {
chrome.runtime.sendMessage(
{
info: params,
ty: "viewPermission",
},
(res) => {
console.log(res);
if (res) {
resolve(res);
} else {
reject(new Error("No response from background script"));
}
}
);
});
}
chrome.runtime.sendMessage(
{
ty: "get",
},
function (obj) {
if(obj){
}else{
return
}
let r = obj.name;
let id = obj.id;
console.log("传递过来的obj" + JSON.stringify(obj));
@ -550,7 +361,7 @@ chrome.runtime.sendMessage(
{ 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: "play_finance", funct: play_finance },
{ name: "mail", funct: mail },
{ name: "calendar", funct: calendar },
{ name: "shopping", funct: shopping },
@ -565,9 +376,9 @@ chrome.runtime.sendMessage(
funct(r, id);
}
}
if(!is_Match){
all(r,id)
}
}
);
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
console.log(request);
sendResponse("我收到了你的情书popup~");
});

View File

@ -10,7 +10,7 @@
"128": "icon64.png"
},
"background": {
"scripts": ["lib/jquery-3.3.1.min.js","lib/axios.min.js","js/background.js"]
"scripts": ["lib/jquery-3.3.1.min.js","js/background.js"]
},
"content_scripts": [
{
@ -18,7 +18,6 @@
"<all_urls>"
],
"js": [
"lib/axios.min.js",
"lib/jquery-3.3.1.min.js",
"lib/content.js"
],

View File

@ -2,7 +2,7 @@
* @Author: lingling 1077478963@qq.com
* @Date: 2024-08-19 09:47:04
* @LastEditors: lingling 1077478963@qq.com
* @LastEditTime: 2024-09-24 14:55:12
* @LastEditTime: 2024-08-22 19:03:16
* @FilePath: \谷歌自动搜索邮箱自动点击v3\popup.html
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->