Merge branch 'devStrategy'
This commit is contained in:
commit
85da919bfe
62
js/popup.js
62
js/popup.js
|
@ -38,6 +38,7 @@ $(function () {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
function shuffleArray(array) {
|
function shuffleArray(array) {
|
||||||
for (let i = array.length - 1; i > 0; i--) {
|
for (let i = array.length - 1; i > 0; i--) {
|
||||||
const j = Math.floor(Math.random() * (i + 1));
|
const j = Math.floor(Math.random() * (i + 1));
|
||||||
|
@ -45,7 +46,6 @@ $(function () {
|
||||||
}
|
}
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// 浏览器监听事件 每当有新页面生成就会执行
|
// 浏览器监听事件 每当有新页面生成就会执行
|
||||||
chrome.runtime.onMessage.addListener(function (
|
chrome.runtime.onMessage.addListener(function (
|
||||||
request,
|
request,
|
||||||
|
@ -57,60 +57,24 @@ $(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 youtube_shorts() {
|
|
||||||
let a = await createTab(
|
|
||||||
"https://www.youtube.com/shorts/",
|
|
||||||
"youtube_shorts"
|
|
||||||
);
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
async function news_google() {
|
|
||||||
let a = await createTab("https://news.google.com/", "news_google");
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
async function play_google() {
|
|
||||||
let a = await createTab("https://play.google.com/", "play_google");
|
|
||||||
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() {
|
|
||||||
let a = await createTab("https://shopping.google.com/", "shopping");
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
async function youtube() {
|
|
||||||
let a = await createTab("https://www.youtube.com/", "youtube");
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
//函数队列
|
|
||||||
let queue = [];
|
|
||||||
// queue.push(play_finance);//好像js注入不进去
|
|
||||||
queue.push(shopping);
|
|
||||||
queue.push(calendar);
|
|
||||||
queue.push(mail);
|
|
||||||
// queue.push(youtube);
|
|
||||||
queue.push(play_google);
|
|
||||||
queue.push(youtube_shorts);
|
|
||||||
queue.push(news_google);
|
|
||||||
//乱序执行 此处有问题
|
//乱序执行 此处有问题
|
||||||
// queue=shuffleArray(queue)
|
// queue=shuffleArray(queue)
|
||||||
//当前执行的队列索引
|
//当前执行的队列索引
|
||||||
|
//函数队列
|
||||||
|
let queue = [
|
||||||
|
{ 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://www.google.com/finance/", tip: "play_finance" },
|
||||||
|
];
|
||||||
let closed_index = 0;
|
let closed_index = 0;
|
||||||
|
|
||||||
function sendMsg(obj) {
|
function sendMsg(obj) {
|
||||||
|
@ -125,7 +89,9 @@ $(function () {
|
||||||
chrome.tabs.onRemoved.addListener(async (windowId) => {
|
chrome.tabs.onRemoved.addListener(async (windowId) => {
|
||||||
console.log("Closed window: " + windowId);
|
console.log("Closed window: " + windowId);
|
||||||
if (closed_index < queue.length) {
|
if (closed_index < queue.length) {
|
||||||
let tmp = await queue[closed_index]();
|
let url = queue[closed_index].url;
|
||||||
|
let tip = queue[closed_index].tip;
|
||||||
|
let tmp = await createTab(url, tip);
|
||||||
// console.log(tmp)
|
// console.log(tmp)
|
||||||
sendMsg(tmp);
|
sendMsg(tmp);
|
||||||
closed_index++;
|
closed_index++;
|
||||||
|
|
|
@ -305,11 +305,21 @@ async function youtube_shorts2(r, id) {
|
||||||
async function youtube(r, id) {
|
async function youtube(r, id) {
|
||||||
// 点击长视频观看
|
// 点击长视频观看
|
||||||
await delay(5);
|
await delay(5);
|
||||||
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")
|
let vido_array = $(
|
||||||
vido_array[getRandomInt(0,vido_array.length-1)].click()
|
".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"
|
||||||
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()
|
vido_array[getRandomInt(0, vido_array.length - 1)].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()
|
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
function ServiceLogin(r, id) {
|
function ServiceLogin(r, id) {
|
||||||
|
@ -345,39 +355,26 @@ chrome.runtime.sendMessage(
|
||||||
let r = obj.name;
|
let r = obj.name;
|
||||||
let id = obj.id;
|
let id = obj.id;
|
||||||
console.log("传递过来的obj" + JSON.stringify(obj));
|
console.log("传递过来的obj" + JSON.stringify(obj));
|
||||||
switch (r) {
|
let functoons = [
|
||||||
case "naver":
|
{ name: "naver", funct: naver },
|
||||||
naver(r, id);
|
{ name: "youtube", funct: youtube },
|
||||||
break;
|
{ name: "youtube_shorts", funct: youtube_shorts2 },
|
||||||
case "youtube":
|
{ name: "news_google", funct: news_google },
|
||||||
youtube(r, id);
|
{ name: "play_google", funct: play_google },
|
||||||
break;
|
{ name: "play_finance", funct: play_finance },
|
||||||
case "youtube_shorts":
|
{ name: "mail", funct: mail },
|
||||||
youtube_shorts2(r, id);
|
{ name: "calendar", funct: calendar },
|
||||||
break;
|
{ name: "shopping", funct: shopping },
|
||||||
case "news_google":
|
];
|
||||||
news_google(r, id);
|
let is_Match = false;
|
||||||
break;
|
for (let index = 0; index < functoons.length; index++) {
|
||||||
case "play_google":
|
// const element = functoons[index];
|
||||||
play_google(r, id);
|
let name = functoons[index].name;
|
||||||
break;
|
let funct = functoons[index].funct;
|
||||||
case "play_finance":
|
if (r == name) {
|
||||||
play_finance(r, id);
|
is_Match = true;
|
||||||
break;
|
funct(r, id);
|
||||||
case "mail":
|
}
|
||||||
mail(r, id);
|
|
||||||
break;
|
|
||||||
case "calendar":
|
|
||||||
calendar(r, id);
|
|
||||||
break;
|
|
||||||
case "shopping":
|
|
||||||
shopping(r, id);
|
|
||||||
break;
|
|
||||||
case "youtube":
|
|
||||||
youtube(r, id);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue