2024-08-24 11:17:58 +08:00
/ * *
* 阻塞代码运行
* @ param { * } n 秒数
2024-08-26 14:34:55 +08:00
* @ returns
2024-08-24 11:17:58 +08:00
* /
2024-08-19 17:05:34 +08:00
function delay ( n ) {
return new Promise ( function ( resolve ) {
setTimeout ( resolve , n * 1000 ) ;
} ) ;
}
2024-08-24 11:17:58 +08:00
/ * *
* 随机数生成
* @ param { * } min 最小值
* @ param { * } max 最大值
2024-08-26 14:34:55 +08:00
* @ returns
2024-08-24 11:17:58 +08:00
* /
2024-08-19 18:02:42 +08:00
function getRandomInt ( min , max ) {
2024-08-20 14:26:52 +08:00
min = Math . ceil ( min ) ;
max = Math . floor ( max ) ;
return Math . floor ( Math . random ( ) * ( max - min + 1 ) ) + min ;
}
2024-08-19 18:02:42 +08:00
2024-08-24 11:17:58 +08:00
/ * *
* 随机滑动函数
* @ param { * } y 滑动像素 不传递默认随机
* /
2024-08-20 14:26:52 +08:00
function RandomIntscrollBy ( y = 0 ) {
let rand = getRandomInt ( 100 , 600 ) ;
scrollBy ( 0 , y == 0 ? rand : y ) ;
console . log ( "随机滑动" + rand ) ;
2024-08-19 18:02:42 +08:00
}
2024-08-19 17:05:34 +08:00
//naver使用函数
const naver = async ( r , id ) => {
2024-08-24 09:24:11 +08:00
// await delay(1);
2024-08-20 14:26:52 +08:00
send _close ( id ) ;
2024-08-19 17:05:34 +08:00
} ;
2024-08-24 11:17:58 +08:00
/ * *
2024-08-26 14:34:55 +08:00
*
2024-08-24 11:17:58 +08:00
* @ param { * } str 字符串
* @ param { * } arr 需要匹配的字符串数组
* @ returns boole
* /
function searchStringContainsArrayKeywords ( str , arr ) {
for ( let i = 0 ; i < arr . length ; i ++ ) {
if ( str . includes ( arr [ i ] ) ) {
return true ;
}
}
return false ;
}
2024-08-20 14:26:52 +08:00
2024-08-26 09:20:29 +08:00
/ * *
* 谷歌商城
2024-08-26 14:34:55 +08:00
* @ param { * } r
* @ param { * } id
2024-08-26 09:20:29 +08:00
* /
2024-08-22 16:25:33 +08:00
async function shopping ( r , id ) {
let number = getRandomInt ( 2 , 10 ) ;
for ( let index = 0 ; index < number ; index ++ ) {
RandomIntscrollBy ( ) ;
await delay ( getRandomInt ( 3 , 7 ) ) ;
}
send _close ( id ) ;
}
2024-08-26 09:20:29 +08:00
/ * *
* 谷歌日历
2024-08-26 14:34:55 +08:00
* @ param { * } r
* @ param { * } id
2024-08-26 09:20:29 +08:00
* /
2024-08-22 14:06:42 +08:00
async function calendar ( r , id ) {
await delay ( 3 ) ;
let number = getRandomInt ( 2 , 5 ) ;
2024-08-22 16:25:33 +08:00
console . log ( $ ) ;
2024-08-22 14:06:42 +08:00
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 ) ;
}
2024-08-26 09:20:29 +08:00
/ * *
* 谷歌新闻
2024-08-26 14:34:55 +08:00
* @ param { * } r
* @ param { * } id
2024-08-26 09:20:29 +08:00
* /
2024-08-21 11:30:52 +08:00
async function news _google ( r , id ) {
//等待五秒怕加载速度过慢
2024-08-26 11:01:59 +08:00
await delay ( 3 ) ;
//点击完整报道
try {
2024-08-26 14:34:55 +08:00
$ ( ".jKHa4e" ) [ 0 ] . click ( ) ;
for ( let index = 0 ; index < getRandomInt ( 3 , 5 ) ; index ++ ) {
RandomIntscrollBy ( ) ;
await delay ( 3 ) ;
2024-08-26 11:01:59 +08:00
}
2024-08-26 14:34:55 +08:00
let new _array = $ ( ".VDXfz" ) ;
let new _array _href = [ ] ;
2024-08-26 11:01:59 +08:00
for ( let index = 0 ; index < new _array . length ; index ++ ) {
const element = new _array [ index ] ;
2024-08-26 14:34:55 +08:00
console . log ( element . getAttribute ( "href" ) ) ;
let url = element . getAttribute ( "href" ) . replace ( /\./g , "" ) ;
new _array _href . push ( ` https://news.google.com ${ url } ` ) ;
2024-08-26 11:01:59 +08:00
}
for ( let index = 0 ; index < new _array _href . length ; index ++ ) {
const element = new _array _href [ index ] ;
2024-08-26 14:34:55 +08:00
let a = open ( element ) ;
await delay ( 3 ) ;
a . close ( ) ;
2024-08-26 11:01:59 +08:00
}
} catch ( error ) {
2024-08-26 14:34:55 +08:00
console . log ( error ) ;
2024-08-26 11:01:59 +08:00
}
2024-08-21 17:35:28 +08:00
send _close ( id ) ;
}
//谷歌商店浏览
async function play _google ( r , id ) {
//等待五秒怕加载速度过慢
await delay ( 5 ) ;
//滑动次数
let a = getRandomInt ( 3 , 5 ) ;
for ( let index = 0 ; index < a ; index ++ ) {
RandomIntscrollBy ( ) ;
await delay ( getRandomInt ( 0 , 5 ) ) ;
}
//点击推荐
if ( getRandomInt ( 0 , 1 ) == 0 ) {
$ ( ".Pdcv8e" ) . click ( ) ;
await delay ( getRandomInt ( 5 , 10 ) ) ;
//返回主页
$ ( "#kO001e > header > nav > a" ) . click ( ) ;
}
//热门游戏随机列表 直接触发点击事件就行
let popular _games = $ (
"#yDmH0d > c-wiz.SSPGKf.glB9Ve > div > div > div.N4FjMb.Z97G4e > c-wiz > div > c-wiz > c-wiz:nth-child(4) > c-wiz > section > div > div > div > div > div.aoJE7e.b0ZfVe"
) . children ;
await delay ( getRandomInt ( 5 , 10 ) ) ;
//
send _close ( id ) ;
}
2024-08-26 09:20:29 +08:00
/ * *
* 谷歌财经
2024-08-26 14:34:55 +08:00
* @ param { * } r
* @ param { * } id
2024-08-26 09:20:29 +08:00
* /
2024-08-21 17:35:28 +08:00
async function play _finance ( r , id ) {
2024-08-24 09:24:11 +08:00
await delay ( 5 ) ;
2024-08-22 16:25:33 +08:00
let recommended _attention = $ ( ".sbnBtf >li >a" ) ;
2024-08-24 09:24:11 +08:00
2024-08-22 16:25:33 +08:00
for (
let index = 0 ;
2024-08-24 09:24:11 +08:00
index < getRandomInt ( 0 , recommended _attention . length ) ;
2024-08-22 16:25:33 +08:00
index ++
) {
2024-08-22 15:52:05 +08:00
recommended _attention [ index ] . click ( ) ;
2024-08-22 16:25:33 +08:00
await delay ( getRandomInt ( 5 , 10 ) ) ;
for ( let indexx = 0 ; indexx < getRandomInt ( 0 , 5 ) ; indexx ++ ) {
RandomIntscrollBy ( ) ;
await delay ( getRandomInt ( 5 , 10 ) ) ;
2024-08-22 15:52:05 +08:00
}
//返回主页
2024-08-22 16:25:33 +08:00
$ ( ".gb_Bc >a" ) . click ( ) ;
2024-08-22 15:52:05 +08:00
}
2024-08-24 09:24:11 +08:00
// send_close(id);
2024-08-21 17:35:28 +08:00
}
2024-08-26 09:20:29 +08:00
/ * *
* 谷歌邮箱
2024-08-26 14:34:55 +08:00
* @ param { * } r
* @ param { * } id
2024-08-26 09:20:29 +08:00
* /
2024-08-21 17:35:28 +08:00
async function mail ( r , id ) {
let emailReply = [
"우리 실장님이 승진을 축하하기 위해서 다음주 금요일에 (1월 21일에) 오후 5시에 XX 호텔에서 회식이 있습니다 첨부 파일에서 구체적이 정보을 참고하세요. " ,
"회장님의 회의 잘료을 준비위해서 16년에 상품 기획부의 목표 달성 상황을 필요합니다. 다음주 화요일전에 첨부 파일에 형식으로 준비 됬으면 좋겠습니다.많이 감사 드립니다" ,
"좋은 하루 지내세요." ,
"연휴에 잘 지내세요." ,
"감사합니다" ,
"이번주의 판매 보고을 보내드립니다. 세해 세일때문에 판매 목표를 잘 달성했슴니다. 첨부 파일을 참고하세요. " ,
2024-08-22 14:27:34 +08:00
"좋습니다 좋아요" ,
"안녕하세요" ,
"좋습니다" ,
"좋아요" ,
"화이팅" ,
"모르겠습니다" ,
"모르지만 해도 좋아요" ,
"저는 동현 입니다" ,
"해도 좋습니까?" ,
"괜찮아요?" ,
"몇살이에요?" ,
"감사합니다" ,
"미안합니다" ,
"저 갑니다" ,
2024-08-22 16:25:33 +08:00
"사랑해요" ,
2024-08-21 17:35:28 +08:00
] ;
2024-08-21 19:24:51 +08:00
await delay ( 8 ) ;
2024-08-21 17:35:28 +08:00
let mails = document . querySelectorAll ( ".zA" ) ;
2024-08-24 11:17:58 +08:00
let mails _is _google = $ ( ".zA" ) ;
2024-08-21 17:35:28 +08:00
for ( let index = 0 ; index < mails . length ; index ++ ) {
//挨个查看
mails [ index ] . click ( ) ;
RandomIntscrollBy ( ) ;
await delay ( getRandomInt ( 1 , 5 ) ) ;
2024-08-26 14:10:07 +08:00
//.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"))
2024-08-24 11:17:58 +08:00
//获取邮件发送人
2024-08-26 14:34:55 +08:00
let mail _for = mails _is _google [ index ]
. getElementsByClassName ( "yX xY" ) [ 0 ]
. children [ 1 ] . children [ 0 ] . children [ 0 ] . getAttribute ( "email" ) ;
2024-08-24 11:17:58 +08:00
//是否回复
2024-08-26 14:34:55 +08:00
let whether _or _not _to _reply _to = searchStringContainsArrayKeywords (
mail _for ,
[ "google" , "youtube" , "gbcloud" ]
) ;
2024-08-25 18:25:07 +08:00
//逻辑取反
2024-08-26 14:34:55 +08:00
whether _or _not _to _reply _to = ! whether _or _not _to _reply _to ;
console . log (
` 当前邮件发送人: ${ mail _for } 是否回复 ${ whether _or _not _to _reply _to } `
) ;
2024-08-21 17:35:28 +08:00
//邮箱回复
2024-08-26 14:34:55 +08:00
if ( getRandomInt ( 0 , 1 ) == 0 && whether _or _not _to _reply _to ) {
2024-08-22 14:06:42 +08:00
$ ( ".amn >.ams.bkH" ) . click ( ) ;
2024-08-21 19:24:51 +08:00
await delay ( getRandomInt ( 1 , 5 ) ) ;
2024-08-22 14:06:42 +08:00
let text = emailReply [ getRandomInt ( 0 , emailReply . length - 1 ) ] ;
console . log ( "注入内容为" + text ) ;
2024-08-22 14:27:34 +08:00
// $(".Ar.Au >div >div").html = text;
2024-08-22 16:25:33 +08:00
let tmp _ele = $ ( ".Ar.Au >div" ) ;
$ ( ".Ar.Au >div >div" ) . html ( tmp _ele . html ( text ) ) ;
2024-08-21 19:24:51 +08:00
await delay ( 3 ) ;
2024-08-22 14:06:42 +08:00
$ ( ".dC >div" ) . click ( ) ;
2024-08-21 17:35:28 +08:00
await delay ( getRandomInt ( 1 , 5 ) ) ;
}
//返回
2024-08-22 14:06:42 +08:00
$ ( ".aim.ain >div >div >div + div" ) . click ( ) ;
2024-08-21 17:35:28 +08:00
await delay ( getRandomInt ( 5 , 10 ) ) ;
}
2024-08-21 11:30:52 +08:00
send _close ( id ) ;
}
async function youtube _shorts2 ( r , id ) {
//等待五秒怕加载速度过慢
await delay ( 5 ) ;
//观看次数
2024-08-21 13:56:31 +08:00
let views = getRandomInt ( 50 , 100 ) ;
2024-08-21 11:30:52 +08:00
for ( let index = 0 ; index < views ; index ++ ) {
//观看多少秒
2024-08-21 19:24:51 +08:00
let watch _time = getRandomInt ( 10 , 20 ) ;
2024-08-21 11:30:52 +08:00
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 ) ;
}
//点赞
2024-08-21 17:35:28 +08:00
if ( getRandomInt ( 0 , 5 ) == 3 ) {
2024-08-22 14:06:42 +08:00
//点赞
2024-08-21 17:35:28 +08:00
document . querySelector ( "#like-button > yt-button-shape > label" ) . click ( ) ;
}
2024-08-22 14:06:42 +08:00
if ( getRandomInt ( 0 , 5 ) == 2 ) {
2024-08-21 17:35:28 +08:00
//不爱看
document
. querySelector ( "#dislike-button > yt-button-shape > label" )
. click ( ) ;
}
2024-08-22 14:06:42 +08:00
//论区操作
2024-08-21 11:30:52 +08:00
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 ( ) ;
2024-08-21 19:24:51 +08:00
await delay ( getRandomInt ( 5 , 15 ) ) ;
2024-08-21 11:30:52 +08:00
//随机滑动评论区
2024-08-21 13:56:31 +08:00
// RandomIntscrollBy();
2024-08-21 11:30:52 +08:00
//关闭评论区
$ (
"#visibility-button > ytd-button-renderer > yt-button-shape > button > yt-touch-feedback-shape > div > div.yt-spec-touch-feedback-shape__stroke"
) . click ( ) ;
}
2024-08-22 14:06:42 +08:00
await delay ( getRandomInt ( 3 , 5 ) ) ;
2024-08-21 13:56:31 +08:00
//下一个视频
2024-08-21 17:35:28 +08:00
$ (
"#navigation-button-down > ytd-button-renderer > yt-button-shape > button > yt-touch-feedback-shape > div > div.yt-spec-touch-feedback-shape__stroke"
) . click ( ) ;
2024-08-21 11:30:52 +08:00
}
//看完关闭窗口
send _close ( id ) ;
}
2024-08-20 14:26:52 +08:00
async function youtube ( r , id ) {
// 点击长视频观看
2024-08-26 14:34:55 +08:00
await delay ( 5 ) ;
2024-09-24 12:12:32 +08:00
let vido _array = $ ( ".yt-core-image.yt-core-image--fill-parent-height.yt-core-image--fill-parent-width.yt-core-image--content-mode-scale-aspect-fill.yt-core-image--loaded" )
vido _array [ getRandomInt ( 0 , vido _array . length - 1 ) ] . click ( )
await delay ( 5 )
$ ( ".yt-spec-button-shape-next.yt-spec-button-shape-next--tonal.yt-spec-button-shape-next--mono.yt-spec-button-shape-next--size-m.yt-spec-button-shape-next--icon-leading.yt-spec-button-shape-next--segmented-start" ) . eq ( 0 ) . click ( )
$ ( ".yt-spec-button-shape-next.yt-spec-button-shape-next--filled.yt-spec-button-shape-next--mono.yt-spec-button-shape-next--size-m" ) . eq ( 0 ) . click ( )
2024-08-20 14:26:52 +08:00
}
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 ,
} ) ;
}
2024-08-19 18:02:42 +08:00
2024-08-19 17:05:34 +08:00
chrome . runtime . sendMessage (
{
ty : "get" ,
} ,
2024-08-19 18:02:42 +08:00
function ( obj ) {
2024-08-20 14:26:52 +08:00
let r = obj . name ;
let id = obj . id ;
console . log ( "传递过来的obj" + JSON . stringify ( obj ) ) ;
2024-08-19 17:05:34 +08:00
switch ( r ) {
case "naver" :
2024-08-20 14:26:52 +08:00
naver ( r , id ) ;
2024-08-19 17:05:34 +08:00
break ;
2024-08-20 14:26:52 +08:00
case "youtube" :
youtube ( r , id ) ;
2024-08-20 11:02:53 +08:00
break ;
2024-08-21 11:30:52 +08:00
case "youtube_shorts" :
youtube _shorts2 ( r , id ) ;
break ;
case "news_google" :
news _google ( r , id ) ;
break ;
2024-08-21 17:35:28 +08:00
case "play_google" :
play _google ( r , id ) ;
break ;
case "play_finance" :
play _finance ( r , id ) ;
break ;
case "mail" :
mail ( r , id ) ;
break ;
2024-08-22 14:06:42 +08:00
case "calendar" :
calendar ( r , id ) ;
break ;
2024-08-22 16:25:33 +08:00
case "shopping" :
shopping ( r , id ) ;
break ;
2024-08-26 14:34:55 +08:00
case "youtube" :
youtube ( r , id ) ;
break ;
2024-08-19 17:05:34 +08:00
default :
break ;
}
}
) ;
2024-08-20 10:05:28 +08:00
chrome . runtime . onMessage . addListener ( ( request , sender , sendResponse ) => {
2024-08-20 14:26:52 +08:00
console . log ( request ) ;
sendResponse ( "我收到了你的情书, popup~" ) ;
} ) ;