Skip to content

Commit bd20012

Browse files
authored
Update 不学习何以强国.js
1 parent 640c6c5 commit bd20012

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

不学习何以强国.js

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// ==UserScript==
22
// @name 不学习何以强国-beta
33
// @namespace http://tampermonkey.net/
4-
// @version 20220121
4+
// @version 20220125
55
// @description 问题反馈位置: https://github.com/TechXueXi/techxuexi-js/issues 。读文章,看视频,做习题。
66
// @author techxuexi ,荷包蛋。
77
// @match https://www.xuexi.cn
@@ -71,6 +71,19 @@ var examPaperTotalPageCount = null;
7171
var examPaperReverse = false;
7272
//每周答题,专项答题 请求rate 限制 每 3000ms 一次
7373
const ratelimitms = 3000;
74+
75+
//默认情况下, chrome 只允许 window.close 关闭 window.open 打开的窗口,所以我们就要用window.open命令,在原地网页打开自身窗口再关上,就可以成功关闭了
76+
function closeWin() {
77+
try {
78+
window.opener = window;
79+
var win = window.open("","_self");
80+
win.close();
81+
top.close();
82+
} catch (e) {
83+
}
84+
85+
}
86+
7487
$(document).ready(function () {
7588
let url = window.location.href;
7689
if (url == "https://www.xuexi.cn" || url == "https://www.xuexi.cn/" || url == "https://www.xuexi.cn/index.html") {
@@ -205,7 +218,7 @@ async function reading(type) {
205218
GM_setValue('watchingUrl', null);
206219
}
207220
clearInterval(readingInterval);
208-
window.close();
221+
closeWin();
209222
}
210223
}, 1000);
211224
//关闭文章或视频页面
@@ -824,7 +837,7 @@ async function doingExam() {
824837
break;
825838
}
826839
}
827-
window.close();
840+
closeWin();
828841
}
829842
//获取关键字
830843
function getKey() {

0 commit comments

Comments
 (0)