第一次提交

This commit is contained in:
lingling 2024-08-19 09:59:57 +08:00
commit a054956bba
9 changed files with 4767 additions and 0 deletions

250
css/popup.css Normal file
View File

@ -0,0 +1,250 @@
.srui_button{
background: #409EFF;
color: #fff;
border-radius: 2px;
padding: 8px 12px;
margin-right: 5px;
border: none;
cursor: pointer;
font-size: 16px;
}
.srui_button_sec{
background:#ddd;
color:#000;
}
.srui_button:hover{
background:#333 !important;
color:#fff !important;
}
.srui_textarea{
padding:5px;
height:50px;
width:300px;
border:1px solid #ddd;
margin-bottom:5px;
border-radius: 3px;
}
.srui_textarea_lg{
width:400px;
height:120px;
}
.srui_input{
padding:8px 5px;
width:200px;
border:1px solid #ddd;
margin:5px 0;
border-radius: 3px;
display: inline-block;
}
.srui_input_sm{
width:120px;
}
.srui_input_lg{
width:400px;
}
.srui_select{
padding:5px;
border:1px solid #ddd;
margin:5px 0;
}
.srui_title{
display: inline-block;
width:70px;
}
.srui_tishi{
font-size:12px;
color:#666;
margin:3px 0;
}
.srui_right{
float: right;
}
/* 边框 */
.srui_border{
border: 1px solid #ddd;
}
.srui_border_rds{
border-radius: 4px;
}
/* 文字颜色 */
.srui_color_black{
color: #222222
}
.srui_color_white{
color: #ffffff
}
/* 背景色 element-ui */
.srui_bg_blue{
background-color: #409EFF;
}
.srui_bg_green{
background-color: #67C23A;
}
.srui_bg_orange{
background-color: #E6A23C;
}
.srui_bg_yellow{
background-color: rgb(236, 213, 1);
}
.srui_bg_pink{
background-color: #F56C6C;
}
.srui_bg_red{
background-color: rgb(207, 7, 7);
}
.srui_bg_brown{
background-color: rgb(148, 87, 7);
}
.srui_bg_gray{
background-color: #909399;
}
.srui_bg_black{
background-color: #303133;
}
.srui_bg_white{
background-color: #ffffff;
}
/* 弹出窗口 */
#srui_tmbg{
width:100%;
height:100%;
background:#000;
opacity:0.4;
position:fixed;
top:0;
left:0;
display:none;
}
#srui_tips_box{
position:fixed;
max-width: 80%;
max-height: 70%;
word-break:break-all;
top: -40%;
left: 50%;
-ms-transform: translate(-40%, -50%);
-webkit-transform: translate(-40%, -50%);
transform: translate(-40%, -50%);
padding:20px 40px;
font-size:16px;
z-index:9999999999;
border-radius:5px;
font-family:Microsoft Yahei,arial;
}
#srui_tips_box .srui_ft{
margin-top: 10px;
display: flex;
justify-content: flex-end;
text-align: right
}
/*开关*/
.srui_switch_btn{
width:36px !important;
height:20px;
position:relative;
display:inline-block;
cursor:pointer;
}
.srui_switch_btn i{
position:absolute;
/* width:22px;
height:22px; */
width:16px;
height:16px;
background:#fff;
border-radius:50%;
display:inline-block;
/* -moz-box-shadow:-1px 2px 5px #333333;
-webkit-box-shadow:-1px 2px 5px #333333;
box-shadow:-1px 2px 5px #333333; */
top: 1px;
}
.srui_switch_btn[data-on="off"] i{
/* left:0; */
left: 2px;
}
.srui_switch_btn[data-on="on"] i{
/* right:0; */
right:2px;
}
.srui_switch_btn em{
display:inline-block;
width:36px;
height:18px;
background:#ccc;
border-radius:10px;
/* margin-top:3px; */
display:inline-block;
}
.srui_switch_btn[data-on="on"] em{
background:#3089dc
}
#popupname{
width:200px;
overflow:hidden
}
#popupname img{
float:left;
margin-right:5px;
}
#popupname span{
height:26px;
line-height:20px;
display:inline-block;
}
#content{
min-width: 220px;
padding: 10px;
font-size: 13px;
}
.head{
border-bottom: 1px solid #ddd;
padding-bottom: 10px;
margin-bottom: 10px;
}
.head .title{
font-size: 16px;
font-weight: bold
}
.logout{
float: right;
text-decoration: none;
color: #333;
display: none;
}
.logout:hover{
color: rgb(211, 3, 3);
}
h2{ color: #FF9800;
font-size: 22px; margin-bottom: 5px;}

BIN
icon64.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

4
js/background.js Normal file
View File

@ -0,0 +1,4 @@
setTimeout(function(){
chrome.tabs.create({ url: "popup.html" }, function () {
})
},3500);

57
js/popup.js Normal file
View File

@ -0,0 +1,57 @@
$(function () {
// var id = 0, due = ['Dell', ' Lenovo ', "ASUS"], kme = 0 , name="";
var name="";
chrome.tabs.create({ url: "https://www.youtube.com/" }, e => {
name="youtube";
})
// 延时器作用 过一点时间执行一次
// setTimeout(function () {
// chrome.tabs.create({ url: "https://www.google.com/" }, e => {
// kme = 1;
// id = e.id;
// });
// setTimeout(function () {
// chrome.tabs.create({ url: "https://www.google.com/" }, e => {
// kme = 2;
// id = e.id;
// });
// setTimeout(function () {
// chrome.tabs.create({ url: "https://mail.google.com/" }, e => {
// id = e.id;
// });
// }, 20000);
// }, 20000);
// }, 20000);
// 定时1分30秒后 执行新建页面打开油管
setTimeout(function () {
chrome.tabs.create({ url: "https://www.youtube.com/shorts/" }, e => {
name="youtube/shorts";
});
}, 2000);
// 浏览器监听事件 每当有新页面生成就会执行
chrome.runtime.onMessage.addListener(
function (request, sender, sendResponse) {
// 判断是产生一个新页面是
if (request.ty == 'get') {
// if (sender.tab.id == id) {
// sendResponse(due[kme]);
// }
// else {
// sendResponse(name);
// }
sendResponse(name);
}
return true;
}
);
})
//*[@id="like-button"]/yt-button-shape/label/button/yt-touch-feedback-shape/div/div[2]

234
lib/content.js Normal file
View File

@ -0,0 +1,234 @@
chrome.runtime.sendMessage({
ty: 'get'
}, function (r) {
if (r) {
// 判断当前网站是否带有/search?q= 当搜索框搜索完后会执行这部分代码
if (location.href.indexOf('/search?q=') != -1) {
// 传递两个参数 按规定随机生成一个数字
function rd(n, m) {
var c = m - n + 1;
return Math.floor(Math.random() * c + n);
};
setTimeout(function () {
// 屏幕向下滚动 569px
scrollBy(0, 569);
setTimeout(function () {
scrollBy(0, 369);
setTimeout(function () {
// 随机点击一个链接
$('a h3').eq(rd(0, $('a h3').length - 1))[0].click();
}, 1000);
}, 1000);
}, 700);
// alert("执行了content.js文件 第一个 if里 条件是 location.href.indexOf('/search?q=') != -1")
}
// 进入邮箱页面 点击邮箱里内容链接
else if (location.href.startsWith('https://mail.google.com/')) {
if (location.href.startsWith('https://mail.google.com/mail/u/')) {
var mkeww = 0, mue = setInterval(function () {
if ($('[role="grid"] tbody>tr').length) {
clearInterval(mue);
setTimeout(function () {
$('[role="grid"] tbody>tr').eq(0)[0].click();
}, 1900);
} else {
mkeww++;
if (mkeww > 106) {
clearInterval(mue);
}
}
}, 500);
// alert("执行了content.js文件 第一个 if里 条件是 location.href.startsWith('https://mail.google.com/mail/u/')");
}
// alert("执行了content.js文件 第一个 if里 条件是 location.href.startsWith('https://mail.google.com/')");
}
// 进入用户界面 点击应用列表图标(不知道有啥用处)
else if (location.href.startsWith('https://accounts.google.com/ServiceLogin')) {
var 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)
alert("执行了content.js文件 第一个 if里 条件是 location.href.startsWith('https://accounts.google.com/ServiceLogin')");
}
// 看长视频
else if (r == "youtube") {
// 点击长视频观看
setTimeout(function () {
wb = Math.round(Math.random() * $('div #contents ytd-rich-grid-row img').length);
if ($('div #contents ytd-rich-grid-row img').eq(wb).is('.yt-core-image--fill-parent-height'))
$('div #contents ytd-rich-grid-row img').eq(wb).click();
else
$('div #contents ytd-rich-grid-row img').eq(wb + 1).click();
}, 10000);
sum = 1;
// 循环播放 2分钟执行一次 执行5次后关闭
var dingshiqi = setInterval(function () {
if (sum == 5) {
clearInterval(dingshiqi);
// 关闭当前窗口的所有标签
const currentTab = window.location.href;
chrome.tabs.query({ currentWindow: true }, tabs => {
tabs.forEach(tab => {
if (tab.url !== currentTab) {
chrome.tabs.remove(tab.id);
}
});
});
}
setTimeout(function () {
//点击订阅 如果已经订阅过了就不用点
if ($('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();
}, 5000);
$('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();
sum += 1;
}, 240000);
// 1200000=20分钟
// 240000=4分钟
}
// 看短视频
else if (r == "youtube/shorts") {
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 {
setTimeout(function () {
var playButton = document.getElementsByClassName('ytp-large-play-button ytp-button')[0];
playButton.click();
console.log('点击了播放!');
}, 5000)
}
// 执行
var dingshiqi_duanshipin = setInterval(() => {
run(randomTime = list[i])
}, list[i] + 2000);
// 定义一个执行函数
function run(randomTime) {
// 执行randTime次后停止
console.log('总计:', randTime, '次,当前第:', i + 1, '次,观看时长:', randomTime / 1000, 's');
if (i == randTime) {
console.log('已经执行', randTime, '次,关闭当前标签页!')
clearInterval(dingshiqi_duanshipin);
window.close();
}
// 点赞
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
setTimeout(function () {
// 下一集
$('div #navigation-button-down button').click();
console.log('点击了下一个视频')
}, randomTime);
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('点击了播放!');
}
});
}
else {
function getertText_click(aa, Text) {//输入后再点击
aa.dispatchEvent(new Event('click', { bubbles: true }));
aa.dispatchEvent(new Event('focus', { bubbles: true }));
const set = Object.getOwnPropertyDescriptor(aa.__proto__, 'value').set
set.call(aa, Text);
aa.dispatchEvent(new Event('input', { bubbles: true }))
aa.dispatchEvent(new Event('focus', { bubbles: true }))
aa.dispatchEvent(new Event('change', { bubbles: true }))
aa.dispatchEvent(new Event('blur', { bubbles: true }))
}
var mue = setInterval(function () {
if ($('[name="q"]').length) {
clearInterval(mue);
setTimeout(function () {
getertText_click($('[name="q"]')[0], r);
mue = setInterval(function () {
if ($('[name="btnK"]').length) {
clearInterval(mue);
$('[name="btnK"]').eq(0)[0].click();
}
}, 1000);
}, 2000);
}
}, 500);
}
// alert("执行了content.js文件 第一个 if");
}
// alert("执行了content.js文件");
});

4178
lib/jquery-3.3.1.min.js vendored Normal file

File diff suppressed because it is too large Load Diff

27
manifest.json Normal file
View File

@ -0,0 +1,27 @@
{
"name": "谷歌自动搜索邮箱自动点击",
"description": "谷歌自动搜索邮箱自动点击",
"version": "1.0.0",
"manifest_version": 2,
"permissions": ["tabs","*://*/*","background"],
"icons": {
"19": "icon64.png",
"48": "icon64.png",
"128": "icon64.png"
},
"background": {
"scripts": ["js/background.js"]
},
"content_scripts": [
{
"matches": [
"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*"
],
"js": [
"lib/jquery-3.3.1.min.js",
"lib/content.js"
],
"run_at": "document_end"
}
]
}

17
popup.html Normal file
View File

@ -0,0 +1,17 @@
<!doctype html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>这是一个测试</title>
<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="js/popup.js"></script>
</head>
<body>
<div style="width: 520px;height: 470px;text-align: center;margin: auto;">
<h2 style="color: #2159f3;">测试是否成功打开</h2>
</div>
</body>
</html>

0
介绍文档.txt Normal file
View File