Skip to content

Commit

Permalink
V1.3.0
Browse files Browse the repository at this point in the history
ManifestV2
优化内容
  • Loading branch information
Huozzzy committed Mar 9, 2022
1 parent fa8f687 commit 77263ac
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 118 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
25 changes: 3 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,11 @@
本插件基于原开源插件`学习小熊`的版本,针对新的文章视频阅读规则开发的二次版本。

## 更新说明
v1.2.3(2021-12-10):
v1.3.0(2022-03-09):

优化新版登陆页面二维码居中。
优化答题。
此版本为 Manifest V2 的最后一次更新,下一版本将迁移至 V3 版本插件。

v1.2.2(2021-11-25):

感谢@wangscsgit提供的优化答题思路,优先学习历史的答题,避免过期。

v1.2.1(2021-11-18):

登陆二维码自动居中。

v1.2.0(2021-11-13):

增加自动答题功能,每日最高45分(取决于有没有把 每周答题 和 专项答题 做完)。

本地频道功能经过尝试,暂无电脑浏览器实现的可能。

登陆二维码自动居中功能预计未来版本发布。


v1.1.1(2021-10-22):修复扫码登陆后,偶尔出现的“系统维护中”页面,导致学习卡住的问题。

v1.1.0(2021-10-20):更新积分查询接口,原接口字段被剔除。

## 致谢
此处感谢原作者:CN1984
Expand Down
35 changes: 2 additions & 33 deletions js/background.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
let scoreTabId = 0, runningTabId = 0, scoreWindowId = 0, runningWindowId = 0, channelUrls = {}, userId = 0,
usedUrls = {}, chooseLogin = 0, weeklyTitle = 0, paperTitle = 0;
let windowWidth = 360 + Math.floor(Math.random() * 120);
let windowHeight = 360 + Math.floor(Math.random() * 120);
let windowWidth = 350 ;
let windowHeight = 350 ;
let chromeVersion = (/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [0, 0])[1];
let firefoxVersion = (/Firefox\/([0-9]+)/.exec(navigator.userAgent) || [0, 0])[1];
let isMobile = !!(/Mobile/.exec(navigator.userAgent));
let urlMap = {
"index": "https://www.xuexi.cn",
// "points": "https://pc.xuexi.cn/points/my-points.html",
"points": "https://pc.xuexi.cn/points/login.html?ref=https%3A%2F%2Fpc.xuexi.cn%2Fpoints%2Fmy-points.html",
"scoreApi": "https://pc-proxy-api.xuexi.cn/api/score/days/listScoreProgress?sence=score&deviceType=2",
"channelApi": "https://www.xuexi.cn/lgdata/",
Expand Down Expand Up @@ -50,16 +49,6 @@ function getPointsData(callback) {
let res = JSON.parse(xhr.responseText);
if (res.hasOwnProperty("code") && parseInt(res.code) === 200) {
if (checkScoreAPI(res)) {
// let points = 0;
// let ruleList = [100, 200, 300, 400, 500, 600, 700];
// for (let key in res.data.taskProgress) {
// if (!res.data.taskProgress.hasOwnProperty(key)) {
// continue;
// }
// if (ruleList.indexOf(res.data.taskProgress[key].sort) !== -1) {
// points += res.data.taskProgress[key].currentScore;
// }
// }
if (!isMobile) {
chrome.browserAction.setBadgeText({ "text": res.data.totalScore.toString() });
}
Expand Down Expand Up @@ -91,21 +80,6 @@ function getPointsData(callback) {
function checkScoreAPI(res) {
if (res.hasOwnProperty("data")) {
if (res.data.hasOwnProperty("taskProgress")) {
// let pass = 0;
// let ruleList = [100, 200, 300, 400, 500, 600, 700];
// for (let key in res.data.taskProgress) {
// if (!res.data.taskProgress.hasOwnProperty(key)) {
// continue;
// }
// if (res.data.taskProgress[key].hasOwnProperty("sort") && res.data.taskProgress[key].hasOwnProperty("currentScore") && res.data.taskProgress[key].hasOwnProperty("dayMaxScore")) {
// if (ruleList.indexOf(res.data.taskProgress[key].sort) !== -1) {
// ++pass;
// }
// }
// }
// if (pass === 7) {
// return true;
// }
return true;
}
}
Expand Down Expand Up @@ -235,9 +209,6 @@ function autoEarnPoints(timeout) {
break;

}
// if (type) {
// break;
// }
}

if (type && !channelUrls.hasOwnProperty(type)) {
Expand Down Expand Up @@ -388,8 +359,6 @@ function closeWindow(windowId) {

//获取登录链接
function getLoginUrl() {
// let lang = chrome.i18n.getUILanguage() === "zh-CN" ? ".zh-CN" : "";
// return chrome.runtime.getURL("login" + lang + ".html");
return "https://pc.xuexi.cn/points/login.html?ref=https%3A%2F%2Fpc.xuexi.cn%2Fpoints%2Fmy-points.html";
}

Expand Down
6 changes: 0 additions & 6 deletions js/choose.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,4 @@ window.addEventListener("load", function () {
window.location.replace("https://pc.xuexi.cn/points/login.html?ref=https%3A%2F%2Fpc.xuexi.cn%2Fpoints%2Fmy-points.html");
});
});
// 关闭钉钉入口
// document.getElementById("dd").addEventListener("click", function () {
// chrome.runtime.sendMessage({"method": "chooseLogin"}, {}, function (response) {
// window.location.replace("https://login.dingtalk.com/login/index.htm?goto=https%3A%2F%2Foapi.dingtalk.com%2Fconnect%2Foauth2%2Fsns_authorize%3Fappid%3Ddingoankubyrfkttorhpou%26response_type%3Dcode%26scope%3Dsnsapi_login%26redirect_uri%3Dhttps%3A%2F%2Fpc-api.xuexi.cn%2Fopen%2Fapi%2Fsns%2Fcallback");
// });
// });
});
29 changes: 10 additions & 19 deletions js/exampaper.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,26 @@
// 专项答题
function goToLastPage() {
var item = document.getElementsByClassName("ant-pagination-item");
item[item.length - 1].click();
}
// goToLastPage();
setTimeout(goToLastPage,parseInt(2000));

function getNeedAnswer() {
var isPrePage = true;
// 逆序遍历
Array.from(document.querySelectorAll('.item .right > button')).reverse().forEach(function (e, b, c) {
if (isPrePage) {
var isNextPage = true;
document.querySelectorAll('.item .right > button').forEach(function (e, b, c) {
if (isNextPage) {
let i = e.innerText;
if (i != "" && (i == '开始答题' || i == '继续答题')) {
isPrePage = false;
isNextPage = false;
e.click();
return;
}
}
});

if (isPrePage) {
var li = document.getElementsByClassName("ant-pagination-prev")[0];
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-left').click();
document.querySelector('a.ant-pagination-item-link > i.anticon-right').click();
setTimeout(getNeedAnswer, parseInt(Math.random() * 1000));
} else {
chrome.runtime.sendMessage({"method": "paperTitle"});
chrome.runtime.sendMessage({ "method": "paperTitle" });
}
}
}

setTimeout(getNeedAnswer, parseInt(2000));

setTimeout(getNeedAnswer, parseInt(Math.random() * 1000));
29 changes: 10 additions & 19 deletions js/examweek.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,31 @@
// 每周答题
chrome.runtime.sendMessage({"method": "checkTab"}, {}, function (response) {
if (response && response.hasOwnProperty("runtime")) {
if (response.runtime) {
function goToLastPage() {
var item = document.getElementsByClassName("ant-pagination-item");
item[item.length - 1].click();
}
// goToLastPage();
setTimeout(goToLastPage,parseInt(2000));

function getNeedAnswer() {
var isPrePage = true;
// 逆序遍历
Array.from(document.querySelectorAll('.week > button')).reverse().forEach(function (e, b, c) {
if (isPrePage) {
var isNextPage = true;
document.querySelectorAll('.week > button').forEach(function (e, b, c) {
if (isNextPage) {
let i = e.innerText;
if (i != "" && i == '开始答题') {
isPrePage = false;
isNextPage = false;
e.click();
return;
}
}
});

if (isPrePage) {
var li = document.getElementsByClassName("ant-pagination-prev")[0];
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-left').click();
setTimeout(getNeedAnswer, parseInt(Math.random() * 1000));
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(2000));
setTimeout(getNeedAnswer, parseInt(Math.random() * 1000 ));
}
}
});
});
19 changes: 1 addition & 18 deletions js/login.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,10 @@
// var qrCode = document.querySelector('.ddloginbox');
// if (qrCode) {
// setTimeout(function () {
// qrCode.scrollIntoView({
// behavior: "smooth"
// });
// setTimeout(function () {
// window.scrollTo({
// left: (document.body.scrollWidth - document.documentElement.clientWidth) / 2,
// top: window.scrollY,
// behavior: 'smooth'
// });
// }, 1000 + Math.floor(Math.random() * 1000));
// }, 1000 + Math.floor(Math.random() * 1000))
// }

setTimeout(function () {
window.scrollTo({
left: (document.body.scrollWidth - document.documentElement.clientWidth) / 2,
top: 1350,
top: 1450,
behavior: 'smooth'
});
}, 10);

// chrome.runtime.sendMessage({"method": "checkLogin"});


2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "__MSG_extName__",
"version": "1.2.3",
"version": "1.3.0",
"default_locale": "zh_CN",
"description": "__MSG_extDescription__",
"icons": {
Expand Down

0 comments on commit 77263ac

Please sign in to comment.