From 172e74e907eef65a7e715bffc5232683e390d846 Mon Sep 17 00:00:00 2001
From: Huozy <42334632+Huozzzy@users.noreply.github.com>
Date: Sun, 24 Apr 2022 10:03:32 +0800
Subject: [PATCH] =?UTF-8?q?V1.3.1=20=E4=BC=98=E5=8C=96=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 13 +-
js/background.js | 146 ++++++++++----------
js/exampaper.js | 52 ++++---
js/exampractice.js | 330 ++++++++++++++++++++++++---------------------
js/examweek.js | 41 +++---
manifest.json | 2 +-
6 files changed, 305 insertions(+), 279 deletions(-)
diff --git a/README.md b/README.md
index f71688f..cc0e36a 100644
--- a/README.md
+++ b/README.md
@@ -2,18 +2,9 @@
本插件基于原开源插件`学习小熊`的版本,针对新的文章视频阅读规则开发的二次版本。
## 更新说明
-v1.3.0(2022-03-09):
-
- 优化答题。
- 此版本为 Manifest V2 的最后一次更新,下一版本将迁移至 V3 版本插件。
-
-
-## 致谢
-此处感谢原作者:CN1984
-原作者版本链接在此:[学习小熊](https://github.com/CN1984/LearningThePooh)
-由于原作最后更新时间为2019年,且我提交的PR一直没有合并,本人大胆推测原作者已停止更新,故开发现版本。
-若有侵权,请原作者及时联系我,我将立即停止此项目。
+v1.3.1(2022-04-24):
+ 优化部分逻辑。
## 下载
* [最新发布](https://github.com/Huozzzy/Learning-Learner/releases/download/release/Learning-Learner.crx)
diff --git a/js/background.js b/js/background.js
index d882689..f0f5535 100755
--- a/js/background.js
+++ b/js/background.js
@@ -49,9 +49,9 @@ function getPointsData(callback) {
let res = JSON.parse(xhr.responseText);
if (res.hasOwnProperty("code") && parseInt(res.code) === 200) {
if (checkScoreAPI(res)) {
- if (!isMobile) {
+ // if (!isMobile) {
chrome.browserAction.setBadgeText({ "text": res.data.totalScore.toString() });
- }
+ // }
if (typeof callback === "function") {
callback(res.data);
}
@@ -91,7 +91,7 @@ function getChannelData(type, callback) {
shuffle(channel[type]);
channelArr = channel[type][0].split('|');
- if (!isMobile) {
+ // if (!isMobile) {
chrome.windows.get(runningWindowId, { "populate": true }, function (window) {
if (typeof window !== "undefined") {
chrome.tabs.sendMessage(window.tabs[window.tabs.length - 1].id, {
@@ -100,12 +100,12 @@ function getChannelData(type, callback) {
});
}
});
- } else {
- chrome.tabs.sendMessage(runningTabId, {
- "method": "redirect",
- "data": channelArr[1]
- });
- }
+ // } else {
+ // chrome.tabs.sendMessage(runningTabId, {
+ // "method": "redirect",
+ // "data": channelArr[1]
+ // });
+ // }
setTimeout(function () {
let xhr = new XMLHttpRequest();
@@ -242,7 +242,7 @@ function autoEarnPoints(timeout) {
}
- if (!isMobile) {
+ // if (!isMobile) {
if (url && scoreTabId && runningWindowId) {
chrome.windows.get(runningWindowId, { "populate": true }, function (window) {
if (typeof window !== "undefined") {
@@ -256,18 +256,18 @@ function autoEarnPoints(timeout) {
} else {
closeWindow();
}
- } else {
- if (url && scoreTabId && runningTabId) {
- chrome.tabs.sendMessage(runningTabId, {
- "method": "redirect",
- "data": url
- });
- autoEarnPoints(newTime);
- } else {
- chrome.tabs.remove(runningTabId);
- chrome.tabs.remove(scoreTabId);
- }
- }
+ // } else {
+ // if (url && scoreTabId && runningTabId) {
+ // chrome.tabs.sendMessage(runningTabId, {
+ // "method": "redirect",
+ // "data": url
+ // });
+ // autoEarnPoints(newTime);
+ // } else {
+ // chrome.tabs.remove(runningTabId);
+ // chrome.tabs.remove(scoreTabId);
+ // }
+ // }
});
}, timeout);
}
@@ -299,7 +299,7 @@ function shuffle(array) {
//通知
function notice(title, message = "") {
- if (!isMobile) {
+ // if (!isMobile) {
chrome.notifications.create({
"type": "basic",
"iconUrl": "img/Pikachu-128.png",
@@ -310,9 +310,9 @@ function notice(title, message = "") {
chrome.notifications.clear(notificationId);
}, 5000);
});
- } else {
- alert(title + (message ? "\n" + message : ""));
- }
+ // } else {
+ // alert(title + (message ? "\n" + message : ""));
+ // }
}
//创建窗口
@@ -367,7 +367,7 @@ chrome.browserAction.onClicked.addListener(function (tab) {
if (chromeVersion < 45 && firefoxVersion < (isMobile ? 55 : 48)) {
notice(chrome.i18n.getMessage("extVersion"));
} else {
- if (!isMobile) {
+ // if (!isMobile) {
if (scoreTabId) {
if (runningWindowId) {
chrome.windows.update(runningWindowId, { "focused": true, "state": "normal" });
@@ -384,21 +384,21 @@ chrome.browserAction.onClicked.addListener(function (tab) {
scoreTabId = window.tabs[window.tabs.length - 1].id;
});
}
- } else {
- if (scoreTabId) {
- if (runningTabId) {
- chrome.tabs.update(runningTabId, { "active": true });
- } else {
- chrome.tabs.update(scoreTabId, { "active": true });
- }
- } else {
- channelUrls = {};
- chooseLogin = 0;
- chrome.tabs.create({ "url": urlMap.points }, function (tab) {
- scoreTabId = tab.id;
- });
- }
- }
+ // } else {
+ // if (scoreTabId) {
+ // if (runningTabId) {
+ // chrome.tabs.update(runningTabId, { "active": true });
+ // } else {
+ // chrome.tabs.update(scoreTabId, { "active": true });
+ // }
+ // } else {
+ // channelUrls = {};
+ // chooseLogin = 0;
+ // chrome.tabs.create({ "url": urlMap.points }, function (tab) {
+ // scoreTabId = tab.id;
+ // });
+ // }
+ // }
}
});
@@ -412,7 +412,7 @@ chrome.tabs.onRemoved.addListener(function (tabId, removeInfo) {
});
//窗口移除事件
-if (!isMobile) {
+// if (!isMobile) {
chrome.windows.onRemoved.addListener(function (windowId) {
if (windowId === runningWindowId) {
runningWindowId = 0;
@@ -421,7 +421,7 @@ if (!isMobile) {
chrome.browserAction.setBadgeText({ "text": "" });
}
});
-}
+// }
//通信事件
chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
@@ -435,7 +435,7 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
break;
case "startRun":
if (!Object.keys(channelUrls).length) {
- if (!isMobile) {
+ // if (!isMobile) {
if (!runningWindowId) {
getPointsData(function (data) {
if (userId !== data.userId) {
@@ -463,34 +463,34 @@ chrome.runtime.onMessage.addListener(function (request, sender, sendResponse) {
});
});
}
- } else {
- if (!runningTabId) {
- getPointsData(function (data) {
- if (userId !== data.userId) {
- usedUrls = {
- "article": [],
- "video": []
- }
- }
- userId = data.userId;
- chrome.tabs.create({ "url": urlMap.index }, function (tab) {
- runningTabId = tab.id;
- setTimeout(function () {
- channelUrls["exam-practice"] = urlMap.dailyAsk;
- channelUrls["exam-weekly"] = urlMap.weeklyAsk;
- channelUrls["exam-paper"] = urlMap.paperAsk;
- getChannelData("article", function (list) {
- channelUrls["article"] = list;
- getChannelData("video", function (list) {
- channelUrls["video"] = list;
- autoEarnPoints(1000 + Math.floor(Math.random() * 1000));
- });
- });
- }, 1000 + Math.floor(Math.random() * 3000));
- });
- });
- }
- }
+ // } else {
+ // if (!runningTabId) {
+ // getPointsData(function (data) {
+ // if (userId !== data.userId) {
+ // usedUrls = {
+ // "article": [],
+ // "video": []
+ // }
+ // }
+ // userId = data.userId;
+ // chrome.tabs.create({ "url": urlMap.index }, function (tab) {
+ // runningTabId = tab.id;
+ // setTimeout(function () {
+ // channelUrls["exam-practice"] = urlMap.dailyAsk;
+ // channelUrls["exam-weekly"] = urlMap.weeklyAsk;
+ // channelUrls["exam-paper"] = urlMap.paperAsk;
+ // getChannelData("article", function (list) {
+ // channelUrls["article"] = list;
+ // getChannelData("video", function (list) {
+ // channelUrls["video"] = list;
+ // autoEarnPoints(1000 + Math.floor(Math.random() * 1000));
+ // });
+ // });
+ // }, 1000 + Math.floor(Math.random() * 3000));
+ // });
+ // });
+ // }
+ // }
}
break;
case "useUrl":
diff --git a/js/exampaper.js b/js/exampaper.js
index 816a56a..c536231 100644
--- a/js/exampaper.js
+++ b/js/exampaper.js
@@ -1,26 +1,34 @@
-function getNeedAnswer() {
- var isNextPage = true;
- document.querySelectorAll('.item .right > button').forEach(function (e, b, c) {
- if (isNextPage) {
- let i = e.innerText;
- if (i != "" && (i == '开始答题' || i == '继续答题')) {
- isNextPage = false;
- e.click();
- return;
- }
- }
- });
+chrome.runtime.sendMessage({"method": "checkTab"}, {}, function (response) {
+ if (response && response.hasOwnProperty("runtime")) {
+ if (response.runtime) {
+ window.onload = function (){
+ function getNeedAnswer() {
+ var isNextPage = true;
+ document.querySelectorAll('.item .right > button').forEach(function (e, b, c) {
+ if (isNextPage) {
+ let i = e.innerText;
+ if (i != "" && (i == '开始答题' || i == '继续答题')) {
+ isNextPage = false;
+ e.click();
+ return;
+ }
+ }
+ });
+
+ if (isNextPage) {
- if (isNextPage) {
+ var li = document.getElementsByClassName("ant-pagination-next")[0];
+ if (li.getAttribute("aria-disabled") == "false") {
+ document.querySelector('a.ant-pagination-item-link > i.anticon-right').click();
+ setTimeout(getNeedAnswer, parseInt(1000));
+ } else {
+ chrome.runtime.sendMessage({"method": "paperTitle"});
+ }
+ }
+ }
- var li = document.getElementsByClassName("ant-pagination-next")[0];
- if (li.getAttribute("aria-disabled") == "false") {
- document.querySelector('a.ant-pagination-item-link > i.anticon-right').click();
- setTimeout(getNeedAnswer, parseInt(Math.random() * 1000));
- } else {
- chrome.runtime.sendMessage({ "method": "paperTitle" });
+ setTimeout(getNeedAnswer, parseInt(1000));
+ }
}
}
-}
-
-setTimeout(getNeedAnswer, parseInt(Math.random() * 1000));
+});
diff --git a/js/exampractice.js b/js/exampractice.js
index 63aad00..1f8d38b 100755
--- a/js/exampractice.js
+++ b/js/exampractice.js
@@ -1,178 +1,202 @@
chrome.runtime.sendMessage({"method": "checkTab"}, {}, function (response) {
if (response && response.hasOwnProperty("runtime")) {
if (response.runtime) {
-
- var WaitingTime = 10, setTimeoutFunc = null, ManageType = 'auto', isManual = false;
-
- function getAnswers() {
- var nmlsuo = 0, answerArray = [], match_w = {}, max = 0, yc_t = 0;
- isManual = false;
- if (document.querySelector(".q-header") == null) {
- if (document.querySelector(".ant-btn.action.ant-btn-primary") != null){
- chrome.runtime.sendMessage({"method": "askComplete"});
+ window.onload = function () {
+ var waitTiming = 10, setTimeoutFunc = null, ManageType = 'auto', isManual = false;
+ function getAnswers() {
+ var options = 0, optionsArray = [], match_num = {}, max = 0, delay = 0;
+ isManual = false;
+ if (document.querySelector(".q-header") == null) {
+ if (document.querySelector(".ant-btn.action.ant-btn-primary") != null) {
+ chrome.runtime.sendMessage({"method": "askComplete"});
+ return;
+ } else {
+ setTimeoutFunc = setTimeout(getAnswers, parseInt(Math.random() * 1000));
+ return;
+ }
+ }
+ var questionTitle = document.querySelector(".q-header");
+ if (questionTitle == null) {
return;
+ }
+ var questionType = questionTitle.innerText.substr(0, 3);
+ if (document.querySelector(".q-footer .tips") != null) {
+ document.querySelector(".q-footer .tips").click();
} else {
- setTimeoutFunc = setTimeout(getAnswers, 1000);
+ answerSubmit(1);
return;
}
- }
- var questionTitle = document.querySelector(".q-header");
- if (questionTitle == null) {
- return;
- }
- var questionTtype = questionTitle.innerText.substr(0, 3);
- if (document.querySelector(".q-footer .tips") != null) {
- document.querySelector(".q-footer .tips").click();
- } else {
- answerSubmit(1);
- return;
- }
- document.querySelectorAll('.line-feed [color=red]').forEach(function (a, b, c) {
- let i = a.innerText;
- if (i != "") answerArray.push(i);
- });
- switch (questionTtype) {
- case "单选题":
- yc_t = 1;
- case "多选题":
- nmlsuo = document.querySelectorAll('.q-answers .chosen').length;
- if (nmlsuo <= 0) {
- document.querySelectorAll('.q-answer').forEach(function (a, b, c) {
- var yttyutut = a.innerHTML.split('. ').slice(-1)[0];
- var poyuyui = false;
- var dz_c = 0;
- var ootrddfg = false;
- var qazswr = answerArray.join('');
- ootrddfg = Boolean(a.className.indexOf("chosen") != -1);
- poyuyui = (yttyutut.indexOf(qazswr) != -1 || qazswr.indexOf(yttyutut) != -1) && qazswr != "";
- if (poyuyui && !ootrddfg) {
- a.click();
- nmlsuo++;
- }
- if (!poyuyui) {
- dz_c += qweqeqd(qazswr, a.innerHTML);
- match_w[dz_c] = a
- }
- })
- if (nmlsuo == 0) {
- for (let i in match_w) {
- max = Number(max) >= Number(i) ? Number(max) : Number(i);
+ document.querySelectorAll('.line-feed [color=red]').forEach(function (a, b, c) {
+ let i = a.innerText;
+ if (i != "") optionsArray.push(i);
+ });
+
+ if (optionsArray.length == 0) {
+ document.querySelectorAll('.line-feed > font').forEach(function (a, b, c) {
+ let i = a.innerText;
+ if (i != "") optionsArray.push(i);
+ });
+
+ if (optionsArray.length == 0) {
+ document.querySelectorAll('.line-feed').forEach(function (a, b, c) {
+ let i = a.innerText;
+ if (i != "" && i != "请观看视频") {
+ optionsArray.push(i);
}
- match_w[max].click();
- nmlsuo++;
- isManual = true;
- }
- manualManage();
- yc_t = yc_t == 0 ? 2500 : 1500;
+ });
}
- break;
- case "填空题":
- var inpus = document.querySelectorAll('.q-body input');
- var inputs_e = document.querySelectorAll('.q-body input[value=""]');
- nmlsuo = inpus.length - inputs_e.length;
- if (inputs_e.length > 0) {
- var ev = new Event('input', {bubbles: true});
- inpus.forEach(function (a, b, c) {
- if (answerArray[0] == undefined) {
+ }
+ switch (questionType) {
+ case "单选题":
+ delay = 1;
+ case "多选题":
+ options = document.querySelectorAll('.q-answers .chosen').length;
+ if (options <= 0) {
+ document.querySelectorAll('.q-answer').forEach(function (a, b, c) {
+ var optionChoose = a.innerHTML.split('. ').slice(-1)[0];
+ var optionIsRight = false;
+ var optionMatches = 0;
+ var isChosen = false;
+ var optionString = optionsArray.join('');
+ optionChoose = optionChoose.replace(/\(/g, "(").replace(/\)/g, ")");
+ optionString = optionString.replace(/\(/g, "(").replace(/\)/g, ")");
+
+ isChosen = Boolean(a.className.indexOf("chosen") != -1);
+ optionIsRight = (optionChoose.indexOf(optionString) != -1 || optionString.indexOf(optionChoose) != -1) && optionString != "";
+ if (optionIsRight && questionType == '单选题') {
+ optionIsRight = (optionString.length == optionChoose.length ? true : false);
+ }
+ if (optionIsRight && !isChosen) {
+ a.click();
+ options++;
+ }
+ if (!optionIsRight) {
+ optionMatches += getoptionMatches(optionString, a.innerHTML);
+ match_num[optionMatches] = a
+ }
+ })
+ if (options == 0) {
+ for (let i in match_num) {
+ max = Number(max) >= Number(i) ? Number(max) : Number(i);
+ }
+ match_num[max].click();
+ options++;
isManual = true;
- let a = document.querySelector(".q-body").innerText;
- let n = parseInt(Math.random() * 2 + 2);
- let i = parseInt(Math.random() * (a.length - n - 1));
- answerArray[0] = a.substr(i, n);
}
- var value = "";
- if (c.length == 1)
- value = answerArray.join('');
- else
- value = b < answerArray.length ? answerArray[b] : answerArray[0];
- if (a.value == "") {
- a.setAttribute("value", value);
- a.dispatchEvent(ev);
- nmlsuo++;
- }
- })
- manualManage();
- yc_t = 3500;
- }
- break;
+ manualManage();
+ delay = delay == 0 ? 2500 : 1500;
+ }
+ break;
+ case "填空题":
+ var inpus = document.querySelectorAll('.q-body input');
+ var inputs_e = document.querySelectorAll('.q-body input[value=""]');
+ options = inpus.length - inputs_e.length;
+ if (inputs_e.length > 0) {
+ var ev = new Event('input', {bubbles: true});
+ inpus.forEach(function (a, b, c) {
+ if (optionsArray[0] == undefined) {
+ isManual = true;
+ let a = document.querySelector(".q-body").innerText;
+ let n = parseInt(Math.random() * 2 + 2);
+ let i = parseInt(Math.random() * (a.length - n - 1));
+ optionsArray[0] = a.substr(i, n);
+ }
+ var value = "";
+ if (c.length == 1)
+ value = optionsArray.join('');
+ else
+ value = b < optionsArray.length ? optionsArray[b] : optionsArray[0];
+ if (a.value == "") {
+ a.setAttribute("value", value);
+ a.dispatchEvent(ev);
+ options++;
+ }
+ })
+ manualManage();
+ delay = 3500;
+ }
+ break;
+ }
+ setTimeoutFunc = setTimeout(function () {
+ answerSubmit(options)
+ }, parseInt(Math.random() * 1000 + delay));
}
- setTimeoutFunc = setTimeout(function () {
- answerSubmit(nmlsuo)
- }, parseInt(Math.random() * 1500 + yc_t));
- }
- function answerSubmit(nmlsuo = 0) {
- if (nmlsuo > 0 && ManageType == 'auto') {
- !document.querySelector(".next-btn").disabled ? document.querySelector(".next-btn").click() : document.querySelector(".submit-btn").click();
- setTimeoutFunc = setTimeout(getAnswers, parseInt(Math.random() * 1000));
+ function answerSubmit(options = 0) {
+ if (options > 0 && ManageType == 'auto') {
+ setTimeout(function (){
+ !document.querySelector(".next-btn").disabled ? document.querySelector(".next-btn").click() : document.querySelector(".submit-btn").click();
+ },1000);
+ setTimeoutFunc = setTimeout(getAnswers, parseInt(Math.random() * 1000));
+ }
}
- }
- function qweqeqd(a = '', b = '') {
- let c = 0;
- for (let i = 0; i < b.length; i++) {
- if (a.indexOf(b.substr(i, 1)) != -1) {
- c++;
+ function getoptionMatches(a = '', b = '') {
+ let c = 0;
+ for (let i = 0; i < b.length; i++) {
+ if (a.indexOf(b.substr(i, 1)) != -1) {
+ c++;
+ }
}
+ return c;
}
- return c;
- }
- function manualManage() {
- if (document.querySelector("#my_ms") != null || !isManual) return;
- let ds_c = 0;
- let ds_t = null;
- ManageType = "wait";
- let e = document.createElement("div");
- e.id = "my_ms";
- e.innerHTML = "此题无完全匹配答案,已填写(选择)一个相对最匹配的答案(可能是错误的)。你可以点击下面按钮切换到手动做题并修正答案后再次点击按钮切换到自动做题。
若 " + WaitingTime + " 秒无操作则继续自动做题
";
- e.style.color = 'red';
- e.style.fontSize = '20px';
- e.style.textAlign = 'center';
- document.querySelector(".header-row").appendChild(e);
- let b = document.createElement("button");
- b.style.color = 'green';
- b.style.fontSize = '24px';
- b.style.textAlign = 'center';
- b.style.marginTop = '10px';
- b.value = 'auto';
- b.innerText = '切换到手动做题';
- b.onclick = function () {
- document.querySelector("#my_ds").innerHTML = '';
- if (ds_t != null) {
- clearInterval(ds_t);
- ds_t = null;
- }
- if (this.value == 'auto') {
- this.value = 'manual';
- ManageType = "manual";
- b.innerText = '切换到自动做题';
- this.style.color = 'red';
- } else {
- this.value = 'auto';
- ManageType = 'auto';
- b.innerText = '切换到手动做题';
- this.style.color = 'green';
- document.querySelector("#my_ms").remove();
- getAnswers();
+ function manualManage() {
+ if (document.querySelector("#my_ms") != null || !isManual) return;
+ let ds_c = 0;
+ let ds_t = null;
+ ManageType = "wait";
+ let e = document.createElement("div");
+ e.id = "my_ms";
+ e.innerHTML = "此题无完全匹配答案,已填写(选择)一个相对最匹配的答案(可能是错误的)。你可以点击下面按钮切换到手动做题并修正答案后再次点击按钮切换到自动做题。
若 " + waitTiming + " 秒无操作则继续自动做题
";
+ e.style.color = 'red';
+ e.style.fontSize = '20px';
+ e.style.textAlign = 'center';
+ document.querySelector(".header-row").appendChild(e);
+ let b = document.createElement("button");
+ b.style.color = 'green';
+ b.style.fontSize = '24px';
+ b.style.textAlign = 'center';
+ b.style.marginTop = '10px';
+ b.value = 'auto';
+ b.innerText = '切换到手动做题';
+ b.onclick = function () {
+ document.querySelector("#my_ds").innerHTML = '';
+ if (ds_t != null) {
+ clearInterval(ds_t);
+ ds_t = null;
+ }
+ if (this.value == 'auto') {
+ this.value = 'manual';
+ ManageType = "manual";
+ b.innerText = '切换到自动做题';
+ this.style.color = 'red';
+ } else {
+ this.value = 'auto';
+ ManageType = 'auto';
+ b.innerText = '切换到手动做题';
+ this.style.color = 'green';
+ document.querySelector("#my_ms").remove();
+ getAnswers();
+ }
}
+ e.appendChild(b);
+ ds_t = setInterval(function () {
+ ds_c++;
+ document.querySelector("#my_ds_c").innerText = waitTiming - ds_c;
+ if (ds_c >= waitTiming) {
+ document.querySelector("#my_ms").remove();
+ clearInterval(ds_t);
+ ds_t = null;
+ ManageType = 'auto';
+ answerSubmit(1);
+ }
+ }, 1000);
+
}
- e.appendChild(b);
- ds_t = setInterval(function () {
- ds_c++;
- document.querySelector("#my_ds_c").innerText = WaitingTime - ds_c;
- if (ds_c >= WaitingTime) {
- document.querySelector("#my_ms").remove();
- clearInterval(ds_t);
- ds_t = null;
- ManageType = 'auto';
- answerSubmit(1);
- }
- }, 1000);
+ setTimeoutFunc = setTimeout(getAnswers, parseInt(Math.random() * 1000));
}
-
- setTimeoutFunc = setTimeout(getAnswers, parseInt(Math.random() * 1000 ));
}
}
});
diff --git a/js/examweek.js b/js/examweek.js
index 7e2993a..8fb7843 100644
--- a/js/examweek.js
+++ b/js/examweek.js
@@ -1,31 +1,34 @@
chrome.runtime.sendMessage({"method": "checkTab"}, {}, function (response) {
if (response && response.hasOwnProperty("runtime")) {
if (response.runtime) {
- function getNeedAnswer() {
- var isNextPage = true;
- document.querySelectorAll('.week > button').forEach(function (e, b, c) {
- if (isNextPage) {
- let i = e.innerText;
- if (i != "" && i == '开始答题') {
- isNextPage = false;
- e.click();
- return;
+ window.onload = function (){
+ function getNeedAnswer() {
+ var isNextPage = true;
+ document.querySelectorAll('.week > button').forEach(function (e, b, c) {
+ if (isNextPage) {
+ let i = e.innerText;
+ if (i != "" && i == '开始答题') {
+ isNextPage = false;
+ e.click();
+ return;
+ }
}
- }
- });
+ });
- if (isNextPage) {
- var li = document.getElementsByClassName("ant-pagination-next")[0];
- if (li.getAttribute("aria-disabled") == "false") {
- document.querySelector('a.ant-pagination-item-link > i.anticon-right').click();
- setTimeout(getNeedAnswer, parseInt(Math.random() * 1000 ));
- } else {
- chrome.runtime.sendMessage({"method": "weeklyTitle"});
+ if (isNextPage) {
+ var li = document.getElementsByClassName("ant-pagination-next")[0];
+ if (li.getAttribute("aria-disabled") == "false") {
+ document.querySelector('a.ant-pagination-item-link > i.anticon-right').click();
+ setTimeout(getNeedAnswer, parseInt(Math.random() * 1000 ));
+ } else {
+ chrome.runtime.sendMessage({"method": "weeklyTitle"});
+ }
}
}
+
+ setTimeout(getNeedAnswer, parseInt(Math.random() * 1000 ));
}
- setTimeout(getNeedAnswer, parseInt(Math.random() * 1000 ));
}
}
});
\ No newline at end of file
diff --git a/manifest.json b/manifest.json
index fb05a87..f5367be 100755
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "__MSG_extName__",
- "version": "1.3.0",
+ "version": "1.3.1",
"default_locale": "zh_CN",
"description": "__MSG_extDescription__",
"icons": {