-
Notifications
You must be signed in to change notification settings - Fork 0
/
sflepExamEnhance.user.js
164 lines (149 loc) · 4.65 KB
/
sflepExamEnhance.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// ==UserScript==
// @name 随行课堂 期末考试 增强
// @namespace http://tampermonkey.net/
// @version 0.2.1
// @description 在期末考试中提供增强
// @author MisakaCloud
// @match https://course.sflep.com/2019*
// @downloadURL https://github.com/gzzchh/userscripts/raw/master/sflepUnitTestEnhance.user.js
// @grant none
// ==/UserScript==
(function () {
"use strict";
// 解除听力次数限制
// 显示播放器 一些杂项
$("#divSound").removeAttr("style");
var _PlaySound = PlaySound;
window.PlaySound = function (src, id) {
// var count = $("#hdPlay_" + id).val();
var count = 999;
if (soundfile == "") {
soundfile = resPath + "ItemRes/sound/" + src;
createSoundPlayer();
} else {
soundfile = resPath + "ItemRes/sound/" + src;
jwplayer("soundplayer").load([{ file: soundfile }]);
}
jwplayer("soundplayer").onPlaylistComplete(function () {
jwplayer("soundplayer").load([{ file: "" }]);
});
jwplayer("soundplayer").onBufferFull(function () {
clearTimeout(bufferingTimer);
var sp = $("#btnPlay_" + id);
if (sp.length > 0) {
// var count = $("#hdPlay_" + id).val();
// if (count > 0) count--;
var count = 999;
if (count > 0)
//sp.val('播放(' + count + '次机会)');
sp.html(
'<span class=" fa fa-play-circle play_symble">' +
count +
"次播放机会</span>"
);
$("#hdPlay_" + id).val(count);
if (count == 0) {
//$('#btnPlay_' + id).attr("disabled", "disabled");
$("#btnPlay_" + id).attr("href", "javascript:void(0);");
}
// SaveCurrentPart(false, true); //异步保存,实时更新听力次数
}
sp.removeClass("loading");
});
$("#btnPlay_" + id).val("正在加载");
bufferingTimer = setTimeout("PlayerExpireCheck('" + id + "', 0)", 1000);
$("#btnPlay_" + id).addClass("loading");
jwplayer("soundplayer").play();
//offset()获取当前元素基于浏览的位置
var offsettop = $("#btnPlay_" + id).offset().top;
var offsetleft = $("#btnPlay_" + id).offset().left;
//position()获取当前元素基于父容器的位置
var positiontop = $("#btnPlay_" + id).position().top;
var positionleft = $("#btnPlay_" + id).position().left;
//设置panel的位置基于unamespan的坐标
$("#soundplayer").css({
position: "absolute",
top: offsettop - 20,
left: offsetleft + 150,
"z-index": 2,
});
// 切换成无视频显示,并且拉长
$("#soundplayer").css("width", "350px").css("height", "0px");
};
// 停止计时器
var _StartTimer = StartTimer;
window.StartTimer = function () {};
clearInterval(timer);
// 尝试显示进度条和控制
var cSP = createSoundPlayer;
window.createSoundPlayer = function () {
jwplayer("soundplayer").setup({
flashplayer: "script/jwplayer.flash.swf?c=" + Math.random(),
file: soundfile,
// height: 140,
// width: 140,
// skin: "six",
primary: "html5",
"controlbar.position": "bottom",
"controlbar.idlehide": "false",
controlbar: "bottom",
});
};
// 尝试提交时锁定已用时间
var SCP = SaveCurrentPart;
window.SaveCurrentPart = function (isTotalSubmit, isAsync) {
if (isAsync == undefined || isAsync == null) isAsync = false;
if (submited) return;
//整理答题情况
var answerXml = GenerateAnswerXML();
//总用时(=本次剩余时间-当前剩余时间+上次用时)
var useSeconds =
parseInt($("#ctl00_baseMaterContent_hdSeconds").val()) -
seconds +
parseInt($("#ctl00_baseMaterContent_hdSecondsUsed").val());
//ajax 保存part答题情况
$.ajax({
url: "SchoolTest.aspx",
data: {
action: "savePart",
answer: escape(answerXml),
partnum: curPartNum,
account: "4351182",
useSeconds: useSeconds,
sstid: sstid,
sheetid: 27904,
issubmit: isTotalSubmit,
nocache: Math.random(),
},
type: "POST",
async: isAsync,
success: function (ret) {
sstid = ret;
if (sstid == -100) alert("提交失败,测试次数已达到上限");
if (isTotalSubmit) {
submited = true;
Return("");
}
},
error: function (jqXHR, textStatus, errorThrown) {
if (textStatus == "timeout") {
//网络超时
alert("网络超时");
} else if (textStatus == "error" && jqXHR.readyState == 0) {
//网络断开
alert("网络断开,请重连网络后再继续考试!");
setTimeout(
"SaveCurrentPart(" + isTotalSubmit + "," + isAsync + ")",
1000
); //再次检测-提交
}
},
});
};
// 其他杂项
// 解除禁止选择禁止复制
document.oncontextmenu = true;
document.onselectstart = true;
// 不要翻译选项
$(".form-inline").find("option").addClass("notranslate");
})();