为手机版做准备

This commit is contained in:
lingling 2024-09-21 21:58:25 +08:00
parent 21776380d3
commit bd71f3ac18
4 changed files with 94 additions and 310 deletions

View File

@ -1,23 +0,0 @@
07b66a0 增加youtube函数
1d1789d 修复邮箱卡住问题
499c1bd 修复乱序执行错误 增加谷歌新闻阅读
95e3a23 删除用不上的代码 增加注释 增加乱序执行
aa4f2a6 修复邮箱回复 会回复谷歌官方邮件
720df83 增加标准注释
006d6bb 重命名打包文件根据时间生成 删除不需要的代码
7d99c8f 增加谷歌购物浏览页面
295ae02 增加打包日志
9598f66 提交快速打包脚本
bc05112 添加谷歌财经代码但是并没有测试
e5e3741 完成谷歌邮箱自动回复邮件功能
970c8ba 完成谷歌日历脚本编写
28a6a62 修改邮件写法但是还是没办法发送消息
b57d8dc 添加忽略的文件夹
551f227 完成youto短视频操作
7084aed 修改了一部分
e4929f6 需要自己修改 脚本 导入进来的脚本都有问题
3bec4bf 完成队列和自动关闭的代码实现
3faa458 准备更新v3
b74e21e 增加一些功能
a3125fd 测试
a054956 第一次提交

View File

@ -7,7 +7,13 @@
* @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
*/ */
$(function () { $(function () {
// var id = 0, due = ['Dell', ' Lenovo ', "ASUS"], kme = 0 , name=""; 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; var id = 0;
var name = ""; var name = "";
setTimeout(function () { setTimeout(function () {
@ -38,13 +44,6 @@ $(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 ( chrome.runtime.onMessage.addListener(function (
@ -57,16 +56,11 @@ $(function () {
sendResponse({ name, id }); sendResponse({ name, id });
} }
if (request.ty == "remove") { if (request.ty == "remove") {
chrome.tabs.remove(request.id); chrome.tabs.remove(request.id);
} }
return true; return true;
}); });
// async function text() {
// let a = await createTab("https://www.youtube.com/", "youtube");
// return a;
// }
async function youtube_shorts() { async function youtube_shorts() {
let a = await createTab( let a = await createTab(
"https://www.youtube.com/shorts/", "https://www.youtube.com/shorts/",
@ -82,18 +76,6 @@ $(function () {
let a = await createTab("https://play.google.com/", "play_google"); let a = await createTab("https://play.google.com/", "play_google");
return a; 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() { async function shopping() {
let a = await createTab("https://shopping.google.com/", "shopping"); let a = await createTab("https://shopping.google.com/", "shopping");
return a; return a;
@ -104,16 +86,9 @@ $(function () {
} }
//函数队列 //函数队列
let queue = []; let queue = [];
// queue.push(play_finance);//好像js注入不进去
queue.push(shopping); queue.push(shopping);
queue.push(calendar);
queue.push(mail);
// queue.push(youtube);
queue.push(play_google); queue.push(play_google);
queue.push(news_google); queue.push(news_google);
queue.push(youtube_shorts);
//乱序执行 此处有问题
// queue=shuffleArray(queue)
//当前执行的队列索引 //当前执行的队列索引
let closed_index = 0; let closed_index = 0;
@ -127,7 +102,6 @@ $(function () {
// 浏览器监听事件 关闭标签页时就会执行 // 浏览器监听事件 关闭标签页时就会执行
chrome.tabs.onRemoved.addListener(async (windowId) => { chrome.tabs.onRemoved.addListener(async (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)

View File

@ -30,9 +30,77 @@ function RandomIntscrollBy(y = 0) {
console.log("随机滑动" + rand); console.log("随机滑动" + rand);
} }
/**
*
* @param {*} element html对象
* @param {*} direction 操作 down|up|left|right
*/
function triggerSwipeEvent(element, direction) {
const touchStart = new Touch({
identifier: Date.now(),
target: element,
clientX: 0,
clientY: 0,
screenX: 0,
screenY: 0,
pageX: 0,
pageY: 0,
});
const touchEnd = new Touch({
identifier: Date.now() + 1,
target: element,
clientX: direction === 'left' ? -100 : direction === 'right' ? 100 : 0,
clientY: direction === 'up' ? -500 : direction === 'down' ? 100 : 0,
screenX: direction === 'left' ? -100 : direction === 'right' ? 100 : 0,
screenY: direction === 'up' ? -500 : direction === 'down' ? 100 : 0,
pageX: direction === 'left' ? -100 : direction === 'right' ? 100 : 0,
pageY: direction === 'up' ? -500 : direction === 'down' ? 100 : 0,
});
const touchMove = new Touch({
identifier: Date.now() + 2,
target: element,
clientX: direction === 'left' ? -50 : direction === 'right' ? 50 : 0,
clientY: direction === 'up' ? -500 : direction === 'down' ? 50 : 0,
screenX: direction === 'left' ? -50 : direction === 'right' ? 50 : 0,
screenY: direction === 'up' ? -500 : direction === 'down' ? 50 : 0,
pageX: direction === 'left' ? -50 : direction === 'right' ? 50 : 0,
pageY: direction === 'up' ? -500 : direction === 'down' ? 50 : 0,
});
const touchStartEvent = new TouchEvent('touchstart', {
touches: [touchStart],
targetTouches: [touchStart],
changedTouches: [touchStart],
cancelable: true,
bubbles: true,
});
const touchMoveEvent = new TouchEvent('touchmove', {
touches: [touchMove],
targetTouches: [touchMove],
changedTouches: [touchMove],
cancelable: true,
bubbles: true,
});
const touchEndEvent = new TouchEvent('touchend', {
touches: [],
targetTouches: [],
changedTouches: [touchEnd],
cancelable: true,
bubbles: true,
});
element.dispatchEvent(touchStartEvent);
element.dispatchEvent(touchMoveEvent);
element.dispatchEvent(touchEndEvent);
}
//naver使用函数 //naver使用函数
const naver = async (r, id) => { const naver = async (r, id) => {
// await delay(1);
send_close(id); send_close(id);
}; };
/** /**
@ -64,29 +132,6 @@ async function shopping(r, id) {
send_close(id); send_close(id);
} }
/**
* 谷歌日历
* @param {*} r
* @param {*} id
*/
async function calendar(r, id) {
await delay(3);
let number = getRandomInt(2, 5);
console.log($);
for (let index = 0; index < number; index++) {
//上一页
// $$('.T5GQA >span')[1].querySelectorAll('button')[0].click()
$(".T5GQA > span").eq(1).find("button").eq(0).click();
await delay(getRandomInt(2, 5));
//今天
$(".L09ZLe >div >div >span >div >button").click();
await delay(getRandomInt(2, 5));
}
//下一页
$(".T5GQA > span").eq(2).find("button").eq(0).click();
await delay(getRandomInt(2, 5));
send_close(id);
}
/** /**
* 谷歌新闻 * 谷歌新闻
@ -97,28 +142,10 @@ async function news_google(r, id) {
//等待五秒怕加载速度过慢 //等待五秒怕加载速度过慢
await delay(3); await delay(3);
//点击完整报道 //点击完整报道
try { let sum=getRandomInt(10,50)
$(".jKHa4e")[0].click(); for (let index = 0; index < sum; index++) {
for (let index = 0; index < getRandomInt(3, 5); index++) { RandomIntscrollBy()
RandomIntscrollBy(); await delay(getRandomInt(5,10));
await delay(3);
}
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++) {
const element = new_array_href[index];
let a = open(element);
await delay(3);
a.close();
}
} catch (error) {
console.log(error);
} }
send_close(id); send_close(id);
} }
@ -148,155 +175,19 @@ async function play_google(r, id) {
// //
send_close(id); send_close(id);
} }
/**
* 谷歌财经
* @param {*} r
* @param {*} id
*/
async function play_finance(r, id) {
await delay(5);
let recommended_attention = $(".sbnBtf >li >a");
for (
let index = 0;
index < getRandomInt(0, recommended_attention.length);
index++
) {
recommended_attention[index].click();
await delay(getRandomInt(5, 10));
for (let indexx = 0; indexx < getRandomInt(0, 5); indexx++) {
RandomIntscrollBy();
await delay(getRandomInt(5, 10));
}
//返回主页
$(".gb_Bc >a").click();
}
// send_close(id);
}
/**
* 谷歌邮箱
* @param {*} r
* @param {*} id
*/
async function mail(r, id) {
let emailReply = [
"우리 실장님이 승진을 축하하기 위해서 다음주 금요일에 (1월 21일에) 오후 5시에 XX 호텔에서 회식이 있습니다 첨부 파일에서 구체적이 정보을 참고하세요. ",
"회장님의 회의 잘료을 준비위해서 16년에 상품 기획부의 목표 달성 상황을 필요합니다. 다음주 화요일전에 첨부 파일에 형식으로 준비 됬으면 좋겠습니다.많이 감사 드립니다",
"좋은 하루 지내세요.",
"연휴에 잘 지내세요.",
"감사합니다",
"이번주의 판매 보고을 보내드립니다. 세해 세일때문에 판매 목표를 잘 달성했슴니다. 첨부 파일을 참고하세요. ",
"좋습니다 좋아요",
"안녕하세요",
"좋습니다",
"좋아요",
"화이팅",
"모르겠습니다",
"모르지만 해도 좋아요",
"저는 동현 입니다",
"해도 좋습니까?",
"괜찮아요?",
"몇살이에요?",
"감사합니다",
"미안합니다",
"저 갑니다",
"사랑해요",
];
await delay(8);
let mails = document.querySelectorAll(".zA");
let mails_is_google = $(".zA");
for (let index = 0; index < mails.length; index++) {
//挨个查看
mails[index].click();
RandomIntscrollBy();
await delay(getRandomInt(1, 5));
//.yP未读邮件
// console.log(mails_is_google[index].getElementsByClassName('yX xY')[0].children[1].children[0].children[0].getAttribute("email"))
// console.log(mails_is_google[index].children[4].children[1].children[0].children[0].getAttribute("email"))
//获取邮件发送人
let mail_for = mails_is_google[index]
.getElementsByClassName("yX xY")[0]
.children[1].children[0].children[0].getAttribute("email");
//是否回复
let whether_or_not_to_reply_to = searchStringContainsArrayKeywords(
mail_for,
["google", "youtube", "gbcloud"]
);
//逻辑取反
whether_or_not_to_reply_to = !whether_or_not_to_reply_to;
console.log(
`当前邮件发送人:${mail_for} 是否回复${whether_or_not_to_reply_to}`
);
//邮箱回复
if (getRandomInt(0, 1) == 0 && whether_or_not_to_reply_to) {
$(".amn >.ams.bkH").click();
await delay(getRandomInt(1, 5));
let text = emailReply[getRandomInt(0, emailReply.length - 1)];
console.log("注入内容为" + text);
// $(".Ar.Au >div >div").html = text;
let tmp_ele = $(".Ar.Au >div");
$(".Ar.Au >div >div").html(tmp_ele.html(text));
await delay(3);
$(".dC >div").click();
await delay(getRandomInt(1, 5));
}
//返回
$(".aim.ain >div >div >div + div").click();
await delay(getRandomInt(5, 10));
}
send_close(id);
}
async function youtube_shorts2(r, id) { async function youtube_shorts2(r, id) {
//等待五秒怕加载速度过慢 //等待五秒怕加载速度过慢
await delay(5); await delay(5);
//观看次数 //观看次数
let views = getRandomInt(50, 100); for (let index = 0; index < 5; index++) {
for (let index = 0; index < views; index++) { // 使用示例:
//观看多少秒 // let element = $('.YtShortsCarouselCarouselItem.carousel-item[aria-hidden$="false"]')
let watch_time = getRandomInt(10, 20); let element = document.querySelector('.YtShortsCarouselCarouselItem.carousel-item')
await delay(getRandomInt(2, 5)); triggerSwipeEvent(element, 'up'); // 触发向左滑动事件
//随机暂停播放 await delay(getRandomInt(10, 30))
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);
}
//点赞
if (getRandomInt(0, 5) == 3) {
//点赞
document.querySelector("#like-button > yt-button-shape > label").click();
}
if (getRandomInt(0, 5) == 2) {
//不爱看
document
.querySelector("#dislike-button > yt-button-shape > label")
.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(5, 15));
//随机滑动评论区
// RandomIntscrollBy();
//关闭评论区
$(
"#visibility-button > ytd-button-renderer > yt-button-shape > button > yt-touch-feedback-shape > div > div.yt-spec-touch-feedback-shape__stroke"
).click();
}
await delay(getRandomInt(3, 5));
//下一个视频
$(
"#navigation-button-down > ytd-button-renderer > yt-button-shape > button > yt-touch-feedback-shape > div > div.yt-spec-touch-feedback-shape__stroke"
).click();
} }
//看完关闭窗口 //看完关闭窗口
send_close(id); send_close(id);
@ -305,64 +196,14 @@ async function youtube_shorts2(r, id) {
async function youtube(r, id) { async function youtube(r, id) {
// 点击长视频观看 // 点击长视频观看
await delay(5); await delay(5);
//点击订阅 如果已经订阅过了就不用点 $('#app > div > ytm-browse > ytm-single-column-browse-results-renderer > div > div > ytm-tab-renderer > ytm-rich-grid-renderer > div > div.rich-grid-renderer-contents > ytm-rich-item-renderer:nth-child(2) > ytm-video-with-context-renderer > ytm-media-item > a > ytm-thumbnail-cover > img').click()
if ( await delay(getRandomInt(2000, 3600));
$( //看完关闭窗口
"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();
}
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); send_close(id);
} }
function send_close(id) { function send_close(id) {
chrome.runtime.sendMessage({ chrome.runtime.sendMessage({
ty: "remove", ty: "remove",
@ -394,15 +235,6 @@ chrome.runtime.sendMessage(
case "play_google": case "play_google":
play_google(r, id); play_google(r, id);
break; break;
case "play_finance":
play_finance(r, id);
break;
case "mail":
mail(r, id);
break;
case "calendar":
calendar(r, id);
break;
case "shopping": case "shopping":
shopping(r, id); shopping(r, id);
break; break;
@ -410,6 +242,7 @@ chrome.runtime.sendMessage(
youtube(r, id); youtube(r, id);
break; break;
default: default:
naver(r, id);
break; break;
} }
} }

View File

@ -11,14 +11,14 @@
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>这是一个测试</title> <title>谷歌养号脚本手机版</title>
<link href="css/popup.css" rel="stylesheet" type="text/css" /> <link href="css/popup.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="lib/jquery-3.3.1.min.js"></script> <script type="text/javascript" src="lib/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="js/popup.js"></script> <script type="text/javascript" src="js/popup.js"></script>
</head> </head>
<body> <body>
<div style="width: 520px;height: 470px;text-align: center;margin: auto;"> <div style="width: 520px;height: 470px;text-align: center;margin: auto;">
<h2 style="color: #2159f3;">测试是否成功打开</h2> <h2 style="color: #2159f3;">谷歌养号脚本手机版</h2>
</div> </div>
</body> </body>