Compare commits

..

No commits in common. "3bec4bf2a5f66c94dddf246c71665aa4a13ae4c0" and "b74e21ed7b1ac51e25cf1252cd7d02cb9276ad4e" have entirely different histories.

3 changed files with 43 additions and 147 deletions

View File

@ -2,97 +2,41 @@
* @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 10:57:32 * @LastEditTime: 2024-08-19 17:53:29
* @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
*/ */
$(function () { $(function () {
// var id = 0, due = ['Dell', ' Lenovo ', "ASUS"], kme = 0 , name=""; // var id = 0, due = ['Dell', ' Lenovo ', "ASUS"], kme = 0 , name="";
var id = 0; var id = 0
var name = ""; var name = "";
setTimeout(function () { setTimeout(function () {
chrome.tabs.create( chrome.tabs.create(
{ {
url: "https://www.baidu.com/", url: "https://www.baidu.com/",
}, },
(e) => { (e) => {
name = "naver"; name = "naver";
id = e.id; id = e.id;
} }
); );
}, 2000); }, 2000);
function createTab(url, fname) {
return new Promise((resolve, reject) => { // 浏览器监听事件 每当有新页面生成就会执行
chrome.tabs.create( chrome.runtime.onMessage.addListener(function (
{ request,
url: url, sender,
}, sendResponse
(e) => { ) {
name = fname; // 判断是产生一个新页面是
id = e.id; if (request.ty == "get") {
if (chrome.runtime.lastError) { console.log(id)
reject(chrome.runtime.lastError); sendResponse({name,id});
} else {
resolve({ name: fname, id: e.id });
}
} }
); // if (request.ty == "remove") {
// sendResponse({name,id});
// }
return true;
}); });
}
// 浏览器监听事件 每当有新页面生成就会执行
chrome.runtime.onMessage.addListener(function (
request,
sender,
sendResponse
) {
// 判断是产生一个新页面是
if (request.ty == "get") {
sendResponse({ name, id });
}
if (request.ty == "remove") {
chrome.tabs.remove(request.id);
}
return true;
});
async function text() {
let a= await createTab('https://www.baidu.com/','baidu')
return a
}
async function text2() {
let a= await createTab('https://www.so.com/','360')
return a
}
//函数队列
let queue = [];
queue.push(text)
queue.push(text2)
//当前执行的队列索引
let closed_index=0;
function sendMsg(obj){
chrome.runtime.sendMessage(obj, res => {
// 答复
console.log('popup=>content')
console.log(res)
})
}
// 浏览器监听事件 关闭标签页时就会执行
chrome.tabs.onRemoved.addListener(async (windowId) => {
console.log("Closed window: " + windowId);
if(closed_index<queue.length){
let tmp=await queue[closed_index]()
// console.log(tmp)
sendMsg(tmp)
closed_index++
// sendResponse({ name, id });
}
});
chrome.tabs.onCreated.addListener(
(e)=>{console.log(e);}
)
}); });

View File

@ -20,83 +20,35 @@ function RandomIntscrollBy(y=0){
//naver使用函数 //naver使用函数
const naver = async (r, id) => { const naver = async (r, id) => {
// $("#kw").val("docker"); $("#kw").val("docker");
// await delay(1); await delay(1);
// $("#su").click(); $("#su").click();
// await delay(3);
// for (let index = 0; index < 4; index++) {
// RandomIntscrollBy()
// await delay(3);
// }
await delay(3); await delay(3);
send_close(id) for (let index = 0; index < 4; index++) {
RandomIntscrollBy()
await delay(3);
}
await delay(3);
}; };
//naver使用函数
const sll360 = async (r, id) => {
// $("#kw").val("docker");
// await delay(1);
// $("#su").click();
// await delay(3);
// for (let index = 0; index < 4; index++) {
// RandomIntscrollBy()
// await delay(3);
// }
console.log("??360")
await delay(3);
send_close(id)
};
const baidu = async (r, id) => { function send_close(){}
// $("#kw").val("docker");
// await delay(1);
// $("#su").click();
// await delay(3);
// for (let index = 0; index < 4; index++) {
// RandomIntscrollBy()
// await delay(3);
// }
console.log("??baidu")
await delay(30);
send_close(id)
};
function send_close(id){
chrome.runtime.sendMessage(
{
ty: "remove",
id:id
},)
}
chrome.runtime.sendMessage( chrome.runtime.sendMessage(
{ {
ty: "get", ty: "get",
}, },
function (obj) { function (obj) {
let r=obj.name let r=obj.name
let id=obj.id let id=obj.id
console.log("传递过来的obj"+obj)
switch (r) { switch (r) {
case "naver": case "naver":
naver(r, id); naver(r, id);
break; break;
case "360":
sll360(r, id);
break;
case "baidu":
baidu(r, id);
break;
default: default:
break; break;
} }
} }
); );
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
console.log(request)
sendResponse('我收到了你的情书popup~')
})

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.naver.com/*","https://www.baidu.com/*"
], ],
"js": [ "js": [
"lib/jquery-3.3.1.min.js", "lib/jquery-3.3.1.min.js",