Greasy Fork is available in English.

zaixian100f.com_libjs

zaixian100f.com 在线100分 自动答题,12倍速播放视频, 因题库是加密原因,已对所加载过的题目进行了保存,已增加导出工具显示,待下次升级可自行导出。

Dette scriptet burde ikke installeres direkte. Det er et bibliotek for andre script å inkludere med det nye metadirektivet // @require https://update.greasyfork.org/scripts/511729/1460593/zaixian100fcom_libjs.js

  1. // ==UserScript==
  2. // @name zaixian100f.com_libjs
  3. // @namespace www.miw.cn
  4. // @description zaixian100f.com 在线100分 自动答题,12倍速播放视频, 因题库是加密原因,已对所加载过的题目进行了保存,已增加导出工具显示,待下次升级可自行导出。
  5. // @match *://*.zaixian100f.com/*
  6. // @grant GM.xmlHttpRequest
  7. // @grant GM.openInTab
  8. // @grant GM.listValues
  9. // @grant GM.notification
  10. // @grant GM.download
  11. // @connect *
  12. // @version 1.3.5
  13. // @author hello@miw.cn
  14. // @license MIT
  15. // ==/UserScript==
  16. const ans ={};
  17. let myquestions = new Set(JSON.parse(localStorage.getItem('myquestions') || '[]'));
  18. let mysaved=localStorage.getItem('mysaved') || '0';
  19. let need_face_num = 0;
  20. const _post = GM.xmlHttpRequest;
  21. console.log(myquestions);
  22.  
  23. const answer = (x,v)=>{
  24. const o=x.parentNode.nextElementSibling.querySelectorAll(`[value=${v}]`);
  25. if(o.length) {
  26. o[0].click();
  27. }
  28. }
  29.  
  30. const doit=()=>{
  31. document.querySelectorAll('[id^=questions_]').forEach(x=>{
  32. const id = x.id.substr(10);
  33. const an = ans[id];
  34. if(an){
  35. if(an!='true' && an!='false'){
  36. for(let v of an.split('')){
  37. answer(x,v);
  38. }
  39. } else {
  40. answer(x,an);
  41. }
  42.  
  43. }
  44. });
  45. };
  46.  
  47. const _cat = (url,data,fn,method="post")=>{
  48. _post({
  49. method: method,
  50. url: url,
  51. data: JSON.stringify(data),
  52. headers: { "Content-Type": "application/json;charset=utf-8" },
  53. onload: function(r) {
  54. fn & fn(r);
  55. }
  56. });
  57. }
  58.  
  59. function post(url,data,fn,method='POST'){
  60.  
  61. let b = {}
  62. if(method==='POST'){
  63. b = {"body": JSON.stringify(data)}
  64. }
  65. fetch(url, {
  66. "headers": {
  67. "content-type": "application/json;charset=utf-8",
  68. },
  69. ...b,
  70. "method": method,
  71. mode:'cors',
  72. }).then(res=>res.json()).then(json=>{
  73. console.log(json);
  74. if(fn) fn();
  75. });
  76. }
  77. window.post = post;
  78. const getVideoParam=()=>{
  79. const video = document.querySelector('video#vjs_video_3_html5_api');
  80. if(video){
  81. const params = location.href.split('?')[1].split('&');
  82. const t = Math.floor(video.duration);
  83. const r = ("00" + (t % 60)).slice(-2);
  84. const m = Math.floor(t / 60) +':'+r;
  85. const p = {"now_minute":m,"need_face_num":need_face_num,"vide_ratio":"0.01"};
  86. for(let s of params){
  87. let a=s.replace('Id','_id').split('=');
  88. p[a[0]]=a[1];
  89. }
  90. console.log('课程参数:',p);
  91. return p;
  92. } else {
  93. return null;
  94. }
  95.  
  96. }
  97. const videoFinal=()=>{
  98. const p = getVideoParam();
  99. post("https://www.zaixian100f.com/api/course/addStudyTime",p,()=>{
  100. setTimeout(()=>{
  101. document.querySelector('.to-course').click();
  102. },2000);
  103. });
  104. }
  105.  
  106.  
  107. const addFunc=(c,n,fn)=>{
  108. const p=document.querySelector(`${c}`);
  109.  
  110. if(!!p){
  111. const have = p.querySelectorAll('.__doit');
  112. if(have.length==0){
  113. const btn = document.createElement("button");
  114. btn.textContent = n;
  115. btn.classList.add('__doit');
  116. btn.addEventListener('click', function() {
  117. fn && fn();
  118. });
  119. p.appendChild(btn);
  120. }
  121.  
  122. }
  123.  
  124. }
  125.  
  126. const addFuncs=()=>{
  127. addFunc('.lesson—left h1','12倍速',()=>{
  128. const video = document.querySelector('video#vjs_video_3_html5_api');
  129. if(video){
  130. video.addEventListener('ended',(e)=>{
  131. //console.log(e);
  132. videoFinal();
  133. });
  134. video.playbackRate=12;
  135. }
  136.  
  137. });
  138. addFunc('.test-paper h4','自动答题',()=>{
  139. doit();
  140. });
  141. }
  142. const refresh_names=()=>{
  143. const _names = new Set(JSON.parse(localStorage.getItem('saved') || '[]'));
  144. console.log(_names)
  145. _names.forEach(i=>{
  146. const _list = new Set(JSON.parse(localStorage.getItem('saved-'+i) || '[]'));
  147. const element = document.querySelector(`[data-vname="${i}"]`);
  148. element && element.parentNode.removeChild(element);
  149. const _d = `<div data-vname="${i}">${i} : ${_list.size} <button class="_down" style="padding:0px;margin-left:5px;line-height:1;border:none;" data-name="${i}">⬇️</button></div>`;
  150. const div = document.createElement("div");
  151. div.innerHTML=_d;
  152. document.getElementsByClassName('__mytool')[0].appendChild(div);
  153. });
  154. }
  155. const save_result=(res)=>{
  156. if(res.list){
  157. for(let i in res.list){
  158. const _list = new Set(JSON.parse(localStorage.getItem('saved-'+i) || '[]'));
  159. res.list[i].forEach(x=>{_list.add(x);});
  160. localStorage.setItem('saved-'+i,JSON.stringify(Array.from(_list)));
  161. const _names = new Set(JSON.parse(localStorage.getItem('saved') || '[]'));
  162. _names.add(i);
  163. localStorage.setItem('saved',JSON.stringify(Array.from(_names)));
  164. }
  165. }
  166. refresh_names();
  167. }
  168. const root_url = 'https://cat.miw.cn';
  169. const save_url = root_url+'/cat/zx100';
  170. const down_url = root_url+'/cat/zx100/down';
  171.  
  172. const showTip=(msg)=>{
  173. var obj = {
  174. title:"提示框", //标题 可选 也是默认值
  175. infoTips:msg, //提示消息 可选 也是默认值
  176. duration:1800, //消失时间 可选 也是默认值
  177. width:320, //宽度 可选 也是默认值
  178. height:50, //高度 可选 也是默认值
  179. };
  180. showTips(obj);
  181. }
  182. const __doExport=(name)=>{
  183. //这里开始导出
  184. const _list = new Set(JSON.parse(localStorage.getItem('saved-'+name) || '[]'));
  185.  
  186. if(_list.size==0){
  187. showTip("未能成功保存题目,请先浏览全部题目再来导出.");
  188. } else {
  189. //console.log(_list.size);
  190. _cat(down_url,{ids:Array.from(_list),paperName:name},(v)=>{
  191. v & console.log(v.responseText);
  192. if(v.responseText!='Invalid CORS request'){
  193. //GM.openInTab(root_url+'/cat/zx100/down/'+v.responseText)
  194. GM.download({
  195. url: root_url+'/cat/zx100/down/'+v.responseText,
  196. name: name+".html", //不填则自动获取文件名
  197. saveAs: true,
  198. });
  199. } else {
  200. showTip("无权操作");
  201. }
  202. });
  203. }
  204. }
  205.  
  206. const show_tool=()=>{
  207. const elements = document.getElementsByTagName('*');
  208. let zIndex=0;
  209. for(e of elements){
  210. let s=window.getComputedStyle(e);
  211. if(s.zIndex && s.zIndex!='auto') {
  212. try{
  213. let t = parseInt(s.zIndex);
  214. zIndex = t>zIndex?t:zIndex;
  215. }catch(e){}
  216. }
  217. }
  218. var body = document.body;
  219. var __mytool = document.createElement("div");
  220. __mytool.innerHTML = `浏览:<span class="myquestions">${myquestions.size}</span><br>保存:`;
  221. __mytool.classList.add('__mytool');
  222.  
  223. __mytool.style.cssText = `position:fixed;left:20px;top:150px;bord-radius:10px; z-index:${zIndex+1};font-size:9pt;padding:5px; max-width:180px;height:auto;background-color: rgba(109, 174, 243,0.6);color:yellow;box-shadow:3px 3px 3px #ffffffbf;`;
  224. body.parentNode.insertBefore(__mytool, body);
  225.  
  226. var container = document.getElementsByClassName('__mytool')[0];
  227.  
  228. // 绑定事件处理器到容器,用于未来子元素的点击事件
  229. container.addEventListener('click', function(event) {
  230. // 检查事件是否来自特定的子元素或符合特定条件的其他元素
  231. if (event.target && event.target.matches('._down')) {
  232. const _name = event.target.getAttribute('data-name');
  233. //console.log('子元素被点击了!'+_name);
  234. __doExport(_name);
  235. }
  236. });
  237.  
  238. }
  239.  
  240. function showTips(objInfo){
  241. var mTitle = objInfo && objInfo.title || "提示框";
  242. var w = objInfo && objInfo.width || 180;
  243.  
  244. var h = objInfo && objInfo.height || 100;
  245. var duration = objInfo && objInfo.duration || 800;
  246.  
  247. var infoTips = objInfo && objInfo.infoTips || "hi";
  248.  
  249. var alert = document.createElement("div");
  250. alert.style.cssText = `position:absolute;left:50%;top:50%;z-index:99999;transform: translate(-50%,-50%);color:white;font-size:12px;border-radius:10px;box-shadow:inset 0px 0px 3px #fff;background-color: rgba(0,0,0,0.5);overflow:hidden;`;
  251. alert.style.width = w+"px";
  252. alert.style.minHeight = h+"px";
  253.  
  254. var title = document.createElement("p");
  255. title.innerHTML = mTitle+":";
  256. title.style.cssText = `margin:10px 0 10px 10px;`;
  257.  
  258. var con = document.createElement("p");
  259. con.style.cssText = `display:flex;justify-content:center;align-items:center;padding:0px 10px 0px;margin-bottom:10px;font-size:14px;word-break:break-all;`;
  260. con.innerHTML = infoTips;
  261.  
  262. alert.appendChild(title);
  263. alert.appendChild(con);
  264. document.body.appendChild(alert);
  265. setTimeout(function(){
  266. document.body.removeChild(alert);
  267. },duration);
  268. }
  269.  
  270. function __init() {
  271. var ___open = window.XMLHttpRequest.prototype.open;
  272. window.XMLHttpRequest.prototype.open = async function (method, url, async) {
  273. const res = await ___open.apply(this, arguments);
  274. addFuncs();
  275. return res;
  276. };
  277.  
  278. const nativeSend = XMLHttpRequest.prototype.send;
  279. XMLHttpRequest.prototype.send = function(body) {
  280. const nativeOnReadyStateChange = this.onreadystatechange;
  281. this.onreadystatechange = async function() {
  282.  
  283. if (this.readyState === 4) {
  284. if(this.responseURL.endsWith('/api/course/faceNumber')){
  285. need_face_num = JSON.parse(this.responseText).data.count;
  286. //console.log(need_face_num);
  287. }
  288. if(this.responseType !='arraybuffer'){
  289. try{
  290. //console.log(this);
  291. //console.log(await GM.listValues());
  292. const responseText=this.responseText;
  293. const res = JSON.parse(responseText);
  294. const list = res.data.testpaper_item || res.data.content || res.data.items || res.data.item;
  295. const title=res.data.testpaper_name || res.data.title;
  296. if(list && list.length){
  297. list.map(x=>{
  298. const an = JSON.parse(x.answer).answer;
  299. ans[x.id] = typeof an ==='string' ? an : an.join('');
  300. x['user_answer'] = an;
  301. myquestions.add(x.id);
  302. });
  303. }
  304. if(myquestions.size>0){localStorage.setItem('myquestions',JSON.stringify(Array.from(myquestions)));}
  305. console.log('我的题目数量:',myquestions.size);
  306. if(save_url!=this.responseURL && list ){
  307. _cat(save_url,{url:this.responseURL,list:list, title: title},(v)=>{
  308. //v & console.log(v.responseText);
  309. if(v.responseText=='Invalid CORS request'){
  310. _cat(save_url,{url:this.responseURL,list:list, title: title},(v)=>{
  311. //v & console.log(v.responseText);
  312. if(v.responseText=='Invalid CORS request'){
  313. console.log('重试失败');
  314. } else {
  315. //GM.openInTab("https://www.miw.cn/",{active:false});
  316. save_result(JSON.parse(v.responseText));
  317. }
  318. });
  319. } else {
  320. //GM.openInTab("https://www.miw.cn/",{active:false});
  321. save_result(JSON.parse(v.responseText));
  322. }
  323. });
  324. }
  325.  
  326. }catch(e){
  327. console.log('解析出错,说明不是需要的数据');
  328. }
  329. }
  330. }
  331.  
  332. if (nativeOnReadyStateChange) {
  333. nativeOnReadyStateChange.apply(this, arguments);
  334. }
  335. };
  336. nativeSend.apply(this, arguments);
  337. };
  338.  
  339. }