云上全平台🦄️支持自动答题|题库搜|刷资源|刷视频|视频加速|快速背题|AI搜题|AI问答|

【🐯全网免费仅做一款脚本🐯】、【🚀已完美兼容、智慧树、中国大学mooc、慕课、雨课堂、新国开、超星、学习通、知到、国家开放大学、蓝墨云、职教云、智慧职教、云班课精品课、山东专技、西财在线剩余网站仅支持部分功能🚀】【半兼容、绎通云、U校园、学堂在线】、【😎完美应付测试,全自动答题,一键完成所有资源学习(视频挨个刷时长不存在滴)、视频倍速😎】、【💪新增AI搜题、AI问答,定制化服务💪】、【💙破除网站不可复制文字💙】、【🐮基于生成式AI(ChatGPT)的答案生成🐮】、【🧡新增背题模式(遮挡答案,更好的进行考试复习)🧡】、【云上官方站:https://metost.com】【特别感谢MeTo题库免费提供题目搜索功能】【💚作者在此保证,脚本无任何诸如(手机号,学校信息,等隐私信息)收集💚】

  1. // ==UserScript==
  2. // @name 云上全平台🦄️支持自动答题|题库搜|刷资源|刷视频|视频加速|快速背题|AI搜题|AI问答|
  3. // @version 5.3.14
  4. // @description 【🐯全网免费仅做一款脚本🐯】、【🚀已完美兼容、智慧树、中国大学mooc、慕课、雨课堂、新国开、超星、学习通、知到、国家开放大学、蓝墨云、职教云、智慧职教、云班课精品课、山东专技、西财在线剩余网站仅支持部分功能🚀】【半兼容、绎通云、U校园、学堂在线】、【😎完美应付测试,全自动答题,一键完成所有资源学习(视频挨个刷时长不存在滴)、视频倍速😎】、【💪新增AI搜题、AI问答,定制化服务💪】、【💙破除网站不可复制文字💙】、【🐮基于生成式AI(ChatGPT)的答案生成🐮】、【🧡新增背题模式(遮挡答案,更好的进行考试复习)🧡】、【云上官方站:https://metost.com】【特别感谢MeTo题库免费提供题目搜索功能】【💚作者在此保证,脚本无任何诸如(手机号,学校信息,等隐私信息)收集💚】
  5. // @author 阿绿
  6. // @match *://*.chaoxing.com/*
  7. // @match *://*.treewises.com/*
  8. // @match *://*.swufe-online.com/*
  9. // @match *://*.xuetangx.com/*
  10. // @match *://*.ytccr.com/*
  11. // @match *://*.xueyinonline.com/*
  12. // @match *://*.unipus.cn/*
  13. // @match *://*.icourse163.org/*
  14. // @match *://*.yuketang.cn/*
  15. // @match *://*.ouchn.cn/*
  16. // @match *://*.metost.com/*
  17. // @match *://*.icve.com.cn/*
  18. // @match *://*.zhihuishu.com/*
  19. // @match *://*.mosoteach.cn/*
  20. // @supportURL https://github.com/alv002/meto/
  21. // @icon https://bkimg.cdn.bcebos.com/pic/4ec2d5628535e5dde7114110e88eb0efce1b9c16c4e1
  22. // @require https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/3.6.0/jquery.min.js
  23. // @require https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/crypto-js/4.1.1/crypto-js.min.js
  24. // @require https://lib.baomitu.com/jquery/3.6.0/jquery.min.js
  25. // @require https://lib.baomitu.com/crypto-js/4.1.1/crypto-js.min.js
  26. // @require https://lib.baomitu.com/html2canvas/1.4.1/html2canvas.min.js
  27. // @require https://lib.baomitu.com/tesseract.js/5.1.1/tesseract.min.js
  28. // @require https://gf.qytechs.cn/scripts/445293/code/TyprMd5.js
  29. // @resource Table https://www.forestpolice.org/ttf/2.0/table.json
  30. // @grant GM_setValue
  31. // @grant GM_getValue
  32. // @grant GM_addStyle
  33. // @grant GM_getResourceText
  34. // @grant unsafeWindow
  35. // @grant GM_info
  36. // @grant GM_xmlhttpRequest
  37. // @grant GM_registerMenuCommand
  38. // @connect metost.com
  39. // @connect chaoxing.com
  40. // @connect unipus.cn
  41. // @connect *
  42. // @license AGPL-3.0-or-later
  43. // @namespace https://gitee.com/xiaolv12/yunbanke
  44. // ==/UserScript==
  45.  
  46.  
  47. ;(function(_this) {
  48. let $ = document.getElementById("yl_8") && document.getElementById("yl_8").onclick ||jQuery; // 此处为避免原生网页没有jquery
  49. _this.y$ = $
  50. _this.GM_setValue = GM_setValue
  51. function MyPage(menu){
  52. this.MainIP = "http://m.metost.com"
  53. this.SpareIP ="http://m.metost.com"
  54. this.ChatIP = "https://v.metost.com"
  55. this.ShopIP ="https://d.metost.com"
  56. this.version="5.3.14";
  57. this.$ = $;
  58. this.menu = menu;
  59. this.shadowContent = '';
  60. this.config = this.urlToObject(window.location.href);
  61. this.config.tk_uid =null;
  62. this.api = this.getAPI(this.config.hostname);
  63. if(!this.api){ //是否隐藏ui
  64. console.log("并未匹配到页面")
  65. this.initMenu("none");
  66. // return
  67. }else{
  68. this.initMenu("block");
  69. this.prival_global();//全局定时器
  70. }
  71. this.initData();
  72. // this.initVue();
  73. return this;
  74. }
  75. MyPage.prototype.urlToObject = function(url){
  76. let obj = {};
  77. let arr1 = url.split("?");
  78. obj["front_url"] = arr1[0].split("/");
  79. let domain = obj["front_url"][2]
  80. if(domain.includes('mooc.mosoteach.cn')){
  81. obj.hostname = "mooc.mosoteach";
  82. }else if(domain.includes('mosoteach.cn')){
  83. obj.hostname = "mosoteach";
  84. }else if(domain.includes("zhihuishu.com")){
  85. obj.hostname = "zhihuishu";
  86. }else if(domain.includes("icve.com.cn")){
  87. obj.hostname = "icve";
  88. }else if(domain.includes("metost.com")){
  89. obj.hostname = "meto";
  90. }else if(domain.includes("ouchn.cn")){
  91. obj.hostname = "ouchn";
  92. }else if(domain.includes("chaoxing.com")){
  93. obj.hostname = "chaoxing";
  94. }else if(domain.includes("yuketang.cn")){
  95. obj.hostname = "yuketang";
  96. }else if(domain.includes("icourse163")){
  97. obj.hostname = "mooc";
  98. }else if(domain.includes("unipus.cn")){
  99. obj.hostname = "uschool";
  100. }else if(domain.includes("xuetangx.com")){
  101. obj.hostname = "xuetangx";
  102. }else if(domain.includes("ytccr.com")){
  103. obj.hostname = "ytccr";
  104. }else if(domain.includes("treewises.com")){
  105. obj.hostname = "sdzj"; //山东专技
  106. }else if(domain.includes("swufe-online.com")){
  107. obj.hostname = "xczx"; //西财在线
  108. }
  109. if(arr1[1]){
  110. let arr2 = arr1[1].split("&");
  111. for(let i=0;i<arr2.length;i++){
  112. let res = arr2[i].split("=");
  113. obj[res[0]]=res[1];
  114. }
  115. }
  116. if(arr1[2]){
  117. let arr2 = arr1[2].split("&");
  118. for(let i=0;i<arr2.length;i++){
  119. let res = arr2[i].split("=");
  120. obj[res[0]]=res[1];
  121. }
  122. }
  123. return obj;
  124. }
  125. MyPage.prototype.getAPI = function(hostname) {
  126. switch (hostname) {
  127. case "mooc.mosoteach":
  128. console.log("精品云班课脚本准备中");
  129. return new jpyunbanke_api(this.config);
  130. case "mosoteach":
  131. console.log("云班课脚本准备中");
  132. return new yunbanke_api(this.config);
  133. case "zhihuishu":
  134. console.log("智慧树脚本准备中");
  135. return new zhihuishu_api(this.config);
  136. case "icve":
  137. console.log("智慧职教脚本准备中");
  138. return new icve_api(this.config);
  139. case "meto":
  140. console.log("meto脚本准备中");
  141. return new meto_api(this.config);
  142. case "ouchn":
  143. console.log("国开脚本准备中");
  144. return new ouchn_api(this.config);
  145. case "chaoxing":
  146. console.log("超星脚本准备中");
  147. return new chaoxin_api(this.config);
  148. case "yuketang":
  149. console.log("雨课堂脚本准备中");
  150. return new yuketang_api(this.config);
  151. case "mooc":
  152. console.log("慕课脚本准备中");
  153. return new mooc_api(this.config);
  154. case "uschool":
  155. console.log("U校园脚本准备中");
  156. return new uschool_api(this.config);
  157. case "xuetangx":
  158. console.log("学堂在线脚本准备中");
  159. return new xuetangx_api(this.config);
  160. case "ytccr":
  161. console.log("绎通云脚本准备中");
  162. return new ytccr_api(this.config);
  163. case "sdzj":
  164. console.log("山东专技脚本准备中");
  165. return new sdzj_api(this.config);
  166. case "xczx":
  167. console.log("西财在线脚本准备中");
  168. return new xczx_api(this.config);
  169. default:
  170. return null;
  171. }
  172. };
  173.  
  174. MyPage.prototype.getCookie = function(objName) { //获取指定名称的cookie的值
  175. var arrStr = document.cookie.split("; ");
  176. for (var i = 0; i < arrStr.length; i++) {
  177. var temp = arrStr[i].split("=");
  178. if (temp[0] == objName) return temp[1]; //解码
  179. }
  180. return "";
  181. }
  182. MyPage.prototype.generateHexString=function (length) {
  183. var hexString = '';
  184. var hexChars = '0123456789abcdef';
  185. for (var i = 0; i < length; i++) {
  186. hexString += hexChars.charAt(Math.floor(Math.random() * hexChars.length));
  187. }
  188. return hexString;
  189. }
  190. MyPage.prototype.video_spend=function () {
  191. if(window.my.config.hostname=="zhihuishu"){
  192. GM_setValue("video_spend",1)
  193. return
  194. }else{
  195. div_zhu.append("<button id='x_spend' ><span>视频速率</span></button>");
  196. }
  197. setInterval(()=> {
  198. $("video").each((index,item)=>{
  199. item.playbackRate = GM_getValue("video_spend")||1;
  200. })
  201. }, 2000)
  202. $(shadowContent.querySelector("#x_spend")).click(()=>{
  203. var userInput = window.prompt("请注意有些平台有速率检测,如被检测请保持默认\n部分平台发现观看速度过快会打回\n请输入您需要修改的速率(一般平台可支持:0-16倍速率,1为正常速率)", GM_getValue("video_spend")||1)||1;
  204. GM_setValue("video_spend",userInput)
  205. $("video").each((index,item)=>{
  206. item.playbackRate = userInput;
  207. })
  208. })
  209. }
  210. // MyPage.prototype.guid= function(data){
  211. // return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  212. // var r =Math.random() * 16 | 0,
  213. // v = c == 'x' ? r : (r & 0x3 | 0x8);
  214. // console.log(v);
  215. // return v.toString(16);
  216. // });
  217. // }
  218. MyPage.prototype.upladApi = function(url,data){
  219. let domain = this.MainIP;
  220. if(GM_getValue("choice_server")){//切换服务器
  221. domain = this.SpareIP;
  222. }
  223. url = domain+url;
  224. if(!GM_getValue("time_error_rate")){
  225. GM_setValue("time_error_rate",0)
  226. }
  227. var obj={};
  228. obj.poolId = this.config.poolId;
  229. obj.token = this.config.poolId;
  230. for(var key in data){
  231. obj[key] = data[key];
  232. }
  233. return new Promise(function(resolve, reject){
  234. GM_xmlhttpRequest({
  235. timeout: 15000,
  236. method: "post",
  237. "url": url,
  238. headers:{
  239. "Content-Type":'application/json',
  240. accept: "application/json",
  241. },
  242. data: JSON.stringify(obj),
  243. onload: function(response) {
  244. var status = response.status;
  245. var playurl = "";
  246. // console.log(response.responseText)
  247. try{
  248. var responseText = JSON.parse(response.responseText);
  249. }catch{
  250. GM_setValue("choice_server",!GM_getValue("choice_server"));
  251. aner.text("服务器数据获取失败,请尝试切换网络");
  252. // aner.append("<br>ti_uid="+GM_getValue("ti_uid") +"<br>pp="+GM_getValue("pp") +"<br>poolId="+GM_getValue("poolId"));
  253. aner.css("display","block");
  254. return
  255. }
  256. if(status==200||status=='200'||status==501||status=='501'){
  257. resolve({"result":"success", "json":responseText});
  258. }else if(status==400||status=='400'||status==401||status=='401'){
  259. if ("data" in responseText){
  260. if (responseText.data.message){ //基本上是adduid的返回值
  261. resolve({"result":"success", "json":responseText});
  262. }else{
  263. if(responseText.data != "重复试卷"){
  264. aner.css("display","block");
  265. if(responseText.data[0]=="人"){
  266. var time_error_rate = Date.now() - responseText.data.substr(6)
  267. GM_setValue("time_error_rate",time_error_rate);
  268. // console.log(time_error_rate)
  269. }
  270. GM_setValue("overdue",1)
  271. aner.text(responseText.data);
  272. }else{
  273. resolve({"result":"success", "json":responseText});
  274. }
  275. }
  276. }else{
  277. aner.text("基础配置文件似乎出错了,请刷新后重试");
  278. // aner.append("<br>ti_uid="+GM_getValue("ti_uid") +"<br>pp="+GM_getValue("pp") +"<br>poolId="+GM_getValue("poolId"));
  279. aner.css("display","block");
  280. }
  281. }else if(status==500||status=='500'){
  282. aner.css("display","block")
  283. if("message" in responseText){
  284. aner.text(responseText.message);
  285. }else{
  286. aner.text("导入错误,请联系管理员");
  287. }
  288. reject({"result":"error", "json":responseText});
  289. }else{
  290. aner.css("display","block")
  291. aner.text(responseText.message);
  292. reject({"result":"error", "json":responseText});
  293. GM_setValue("overdue",1)
  294. }
  295. },
  296. onerror : function(err){
  297. if(url != domain+"/tiku/api/v1/problems"){
  298. console.log('error')
  299. console.log(err)
  300. GM_setValue("choice_server",!GM_getValue("choice_server"));
  301. aner.css("display","block")
  302. aner.text("无法连接到服务器,请尝试更换网络,需要可以访问http://d.metost.com");
  303. }
  304. },
  305. ontimeout : function(inf){
  306. if(url != domain+"/tiku/api/v1/problems"){
  307. GM_setValue("choice_server",!GM_getValue("choice_server"));
  308. console.log('请求超时')
  309. console.log(inf)
  310. aner.css("display","block")
  311. aner.text("服务器响应超时,请稍后重试,直接加群,来催更,或者来给项目充个电,发动钞能力,助力作者更早更换服务器。");
  312. }
  313. }
  314. });
  315. });
  316. }
  317. MyPage.prototype.HtmlUtil = {
  318. /*1.用浏览器内部转换器实现html转码*/
  319. htmlEncode:function (html){
  320. //1.首先动态创建一个容器标签元素,如DIV
  321. var temp = document.createElement ("div");
  322. //2.然后将要转换的字符串设置为这个元素的innerText(ie支持)或者textContent(火狐,google支持)
  323. (temp.textContent != undefined ) ? (temp.textContent = html) : (temp.innerText = html);
  324. //3.最后返回这个元素的innerHTML,即得到经过HTML编码转换的字符串了
  325. var output = temp.innerHTML;
  326. temp = null;
  327. return output;
  328. },
  329. /*2.用浏览器内部转换器实现html解码*/
  330. htmlDecode:function (text){
  331. //1.首先动态创建一个容器标签元素,如DIV
  332. var temp = document.createElement("div");
  333. //2.然后将要转换的字符串设置为这个元素的innerHTML(ie,火狐,google都支持)
  334. temp.innerHTML = text;
  335. //3.最后返回这个元素的innerText(ie支持)或者textContent(火狐,google支持),即得到经过HTML解码的字符串了。
  336. var output = temp.innerText || temp.textContent;
  337. temp = null;
  338. return output;
  339. }
  340. };
  341.  
  342. MyPage.prototype.resoluAnswers=function(data){
  343. let newData = {};
  344. if(data ==null){
  345. return console.log("并未获取到题库数据");
  346. }
  347. if("paperId" in data){
  348. console.log("MeTo题库重组中");
  349. newData.id = data.title;
  350. newData.rows = [];
  351. data.problems.forEach(row=>{
  352. let _data ={};
  353. _data.problemId = row.problemId;
  354. _data.subject = row.text;
  355. _data.answers = JSON.parse(row.answer);
  356. newData.rows.push(_data);
  357. });
  358. }else if("rule" in data){
  359. console.log("助手题库重组中");
  360. newData.rows = [];
  361. if("get_answer" in data){ //修改未测试
  362. data.get_answer.forEach(row=>{
  363. let _data ={};
  364. _data.answers = [];
  365. let br = new RegExp("-and-","g");
  366. row.t = row.t.replace(br,"&");
  367. row.t=this.HtmlUtil.htmlDecode(row.t);
  368. _data.subject = row.t;
  369. row.a.forEach(an=>{
  370. _data.answers.push(this.HtmlUtil.htmlDecode(an.replace(br,"&")))
  371. })
  372. _data.type =row.y;
  373. _data.options = row.s;
  374. newData.rows.push(_data);
  375. });
  376. }
  377. }else if("flag" in data){
  378. if (data.flag == "metoproblems"){
  379. console.log("meto1题组重组中");
  380. newData.id = data.title;
  381. newData.rows = [];
  382. try{
  383. data.problems.forEach(row=>{
  384. let _data ={};
  385. _data.problemId = row.problemId;
  386. _data.subject = row.text;
  387. _data.answers = JSON.parse(row.answer);
  388. newData.rows.push(_data);
  389. });
  390. }catch (e){
  391. // alert("服务器连接失败,请联系作者。")
  392. console.log("发生异常:" + e);
  393. }
  394. }
  395. }else{
  396. console.log(data);
  397. }
  398. return newData;
  399. }
  400. /*
  401. * 西财在线请求
  402. */
  403. class xczx_api{
  404. constructor(config) {
  405. this.config = config;
  406. }
  407. async get_user_obj(){
  408. let name = _this._USERNAME_
  409. let id = _this._LOGINID_
  410. this.config.user_id = "xczx_"+id
  411. this.config.full_name = name;
  412. let obj={
  413. "unionid": this.config.user_id,
  414. "username": this.config.full_name,
  415. "poolId":"ec942b0b-38c6-3256-b0e1-2a33428d4bbc",
  416. "grade": "西财在线",
  417. };
  418. return obj
  419. }
  420. async init_button(){
  421. if(this.config.front_url[4] =="learn"){
  422. this.choice_function()
  423. if(GM_getValue("resource_farming_state")){
  424. div_zhu.append("<button id='x_xxx' ><span>正在刷资源,请稍后</span></button>");
  425. aner.show("hide")
  426. aner.text("如需暂停请刷新上一级页面")
  427. }else{
  428. if(GM_getValue("resource_farming_main_state")){
  429. div_zhu.append("<button onclick='GM_setValue(\"resource_farming_main_state\",false);location.reload()'><span>停止翻页</span></button>");
  430. }else{
  431. div_zhu.append("<button onclick='GM_setValue(\"resource_farming_main_state\",true);location.reload()'><span>自动翻页</span></button>");
  432. }
  433. }
  434. }
  435. else{
  436. div_zhu.append("<button onclick='window.open(\"https://d.metost.com\");'><span>MeTo题库</span></button>");
  437. }
  438. }
  439. sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
  440. async choice_function(){
  441. if(!GM_getValue("resource_farming_state")&&!GM_getValue("resource_farming_main_state")){
  442. return
  443. }
  444. var divIframe
  445. for(let i=20;i;i--){
  446. console.log("检测视频loading")
  447. await this.sleep(1000)
  448. divIframe = $("iframe").contents()
  449. let videoIframe = $("iframe").contents().find("iframe").contents()
  450. if(videoIframe.find("video").length&&videoIframe.find("video")[0].duration){
  451. console.log("视频加载")
  452. let video = videoIframe.find("video")[0]
  453. // $(".xt_video_player_common_icon").click()
  454. while(1){
  455. video = videoIframe.find("video")[0]
  456. if(!video){
  457. location.reload()
  458. }
  459. if(video.ended){
  460. console.log("video finsh")
  461. let flag = false;
  462. divIframe.find(".s_point").each((index,div)=>{
  463. if($(div).find(".item_done_icon.item_done_pos").attr("class") != 'item_done_icon item_done_pos done_icon_show' && $(div).find(".s_learn_video").length&&!flag){
  464. div.click()
  465. flag = true
  466. this.choice_function();
  467. }
  468. })
  469. break;
  470. }
  471. video.muted = true;
  472. videoIframe.find(".screen-player-btn-icon.icon-play-sp-fill").click()
  473. await this.sleep(4000)
  474. }
  475. break;
  476. }
  477. }
  478. await this.sleep(1000)
  479. GM_setValue("resource_farming_state",false)
  480. if(GM_getValue("resource_farming_main_state")){
  481. let flag = false;
  482. divIframe.find(".s_point").each((index,div)=>{
  483. if($(div).find(".item_done_icon.item_done_pos").attr("class") != 'item_done_icon item_done_pos done_icon_show' && $(div).find(".s_learn_video").length&&!flag){
  484. div.click()
  485. flag = true
  486. this.choice_function();
  487. }
  488. })
  489. }else{
  490. window.close();
  491. }
  492. }
  493. }
  494.  
  495. /*
  496. * 山东专技请求
  497. */
  498. class sdzj_api{
  499. constructor(config) {
  500. this.config = config;
  501. }
  502. get_user_inf(){
  503. return new Promise((resolve,rejcet)=>{
  504. $.ajax({
  505. type: 'get',
  506. xhrFields: {
  507. withCredentials: true //允许跨域发送cookies
  508. },
  509. url: "https://sdzz-train.treewises.com/api/login/get-account-info.gson",
  510. success: function(res) {
  511. resolve(res.attribute.cmsAccountInfo);
  512. }
  513. });
  514. })
  515. }
  516. async get_user_obj(){
  517. let user_inf = await this.get_user_inf()
  518. console.log(user_inf)
  519. let name = user_inf.realName
  520. let id = user_inf.accountId
  521. this.config.user_id = id
  522. this.config.full_name = name;
  523. let obj={
  524. "unionid": this.config.user_id,
  525. "username": this.config.full_name,
  526. "poolId":"ec942b0b-38c6-3256-b0e1-2a33428d4bbc",
  527. "grade": "山东专技",
  528. };
  529. return obj
  530. }
  531. async init_button(){
  532. if(this.config.front_url[3] =="learning"){
  533. this.choice_function()
  534. if(GM_getValue("resource_farming_state")){
  535. div_zhu.append("<button id='x_xxx' ><span>正在刷资源,请稍后</span></button>");
  536. aner.show("hide")
  537. aner.text("如需暂停请刷新上一级页面")
  538. }else{
  539. if(GM_getValue("resource_farming_main_state")){
  540. div_zhu.append("<button onclick='GM_setValue(\"resource_farming_main_state\",false);location.reload()'><span>停止翻页</span></button>");
  541. }else{
  542. div_zhu.append("<button onclick='GM_setValue(\"resource_farming_main_state\",true);location.reload()'><span>自动翻页</span></button>");
  543. }
  544. }
  545. }
  546. else{
  547. div_zhu.append("<button onclick='window.open(\"https://d.metost.com\");'><span>MeTo题库</span></button>");
  548. }
  549. }
  550. sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
  551. async choice_function(){
  552. if(!GM_getValue("resource_farming_state")&&!GM_getValue("resource_farming_main_state")){
  553. return
  554. }
  555. for(let i=10;i;i--){
  556. console.log("检测视频loading")
  557. await this.sleep(1000)
  558. if($("video").length&&$("video")[0].duration){
  559. console.log("视频加载")
  560. let video = $("video")[0]
  561. document.hasFocus = ()=> {
  562. return true
  563. }
  564. await this.sleep(2000)
  565. // $(".xt_video_player_common_icon").click()
  566. while(1){
  567. if(video.ended){
  568. $(".course-spend").each((index,div)=>{
  569. if(div.innerHTML!='100.0%'){
  570. div.click()
  571. this.choice_function()
  572. }
  573. })
  574. break;
  575. }
  576. await this.sleep(1000)
  577. video.muted = true;
  578. $("#replaybtn").click()//播放按钮1
  579. $(".bplayer-play-btn").click() //播放按钮2
  580. let div = $(".ccQuestion").find("li"); //第一个答题验证
  581. while(div.length){
  582. var randElement = div[Math.floor(Math.random() * div.length)];
  583. randElement.click()
  584. $("#ccQuestionSubmit").click()
  585. if($("#rightBtn").length){
  586. $("#rightBtn").click()
  587. break;
  588. }
  589. await this.sleep(100)
  590. }
  591. div = $(".bplayer-question-content").find(".option-item"); //第二个答题验证
  592. while(div.length && div.attr("style") != 'display: none;'){
  593. var randElement = div[Math.floor(Math.random() * div.length)];
  594. randElement.click()
  595. $(".commit.bplayer-btn").click()
  596. $(".complete.bplayer-btn").click()
  597. $(".commit.bplayer-btn").click()
  598. // if($("#rightBtn").length){
  599. // $("#rightBtn").click()
  600. // break;
  601. // }
  602. await this.sleep(100)
  603. }
  604. }
  605. break;
  606. }
  607. }
  608. await this.sleep(1000)
  609. GM_setValue("resource_farming_state",false)
  610. if(GM_getValue("resource_farming_main_state")){
  611. $(".btn-next").click()
  612. }else{
  613. window.close();
  614. }
  615. }
  616. }
  617.  
  618. /*
  619. * 绎通云请求
  620. */
  621. class ytccr_api{
  622. constructor(config) {
  623. this.config = config;
  624. }
  625. getCookie(objName) { //获取指定名称的cookie的值
  626. var arrStr = document.cookie.split("; ");
  627. for (var i = 0; i < arrStr.length; i++) {
  628. var temp = arrStr[i].split("=");
  629. if (temp[0] == objName) return temp[1]; //解码
  630. }
  631. return "";
  632. }
  633. get_user_inf(){
  634. return new Promise((resolve,rejcet)=>{
  635. $.ajax({
  636. type: 'get',
  637. xhrFields: {
  638. withCredentials: true //允许跨域发送cookies
  639. },
  640. headers: {
  641. "Authorization":"Bearer "+this.getCookie("token"),
  642. },
  643. url: "https://dadexs.ytccr.com/org_student_api/yt/student/myStudentInfo/getInfo",
  644. success: function(res) {
  645. resolve(res);
  646. }
  647. });
  648. })
  649. }
  650. async get_user_obj(){
  651. // var regex = /window.webUser([\s\S]*?)};/gi;
  652. let user_inf = await this.get_user_inf()
  653. // var matches = doc.match(regex);
  654. // GM_setValue("userimg",window.webUser.largeFaceUrl||"");
  655. // let img_table = $(shadowContent.querySelector("#x_set"))
  656. // img_table.css("background","url(" + window.webUser.largeFaceUrl||"" + ")")
  657. let name = user_inf.data.realName
  658. let id = user_inf.data.idCardNo
  659. this.config.user_id = "yty_"+id
  660. this.config.full_name = name;
  661. let obj={
  662. "unionid": this.config.user_id,
  663. "username": this.config.full_name,
  664. "poolId":"ec942b0b-38c6-3256-b0e1-2a33428d4bbc",
  665. "grade": "绎通云",
  666. };
  667. return obj
  668. }
  669. }
  670. /*
  671. * u校园请求
  672. */
  673. class uschool_api{
  674. constructor(config) {
  675. this.config = config;
  676. }
  677. getCookie(objName) { //获取指定名称的cookie的值
  678. var arrStr = document.cookie.split("; ");
  679. for (var i = 0; i < arrStr.length; i++) {
  680. var temp = arrStr[i].split("=");
  681. if (temp[0] == objName) return temp[1]; //解码
  682. }
  683. return "";
  684. }
  685. get_user_inf(){
  686. return new Promise((resolve,rejcet)=>{
  687. GM_xmlhttpRequest({
  688. method: "GET",
  689. url: "https://ucamapi.unipus.cn/rpc/api/user-info/brief?source=0&callback=window.user_inf=&openId="+this.getCookie("ucamUserId"),
  690. onload: res=> {
  691. resolve(res.response);
  692. },
  693. onerror:err=>{
  694. console.log("加载失败")
  695. }
  696. })
  697. })
  698. }
  699. // get_user_inf(){
  700. // alert("即将发送一个请求信息,点击仅获取一次即可\n此请求信息是为了获取用户ID,否则进行手动登录(不可用)也可");
  701. // return new Promise((resolve,rejcet)=>{
  702. // GM_xmlhttpRequest({
  703. // method: "GET",
  704. // url: "https://ucontent.unipus.cn/auth/api/user",
  705. // onload: res=> {
  706. // resolve(res.response);
  707. // },
  708. // onerror:err=>{
  709. // console.log("加载失败")
  710. // }
  711. // })
  712. // })
  713. // }
  714. async get_user_obj(){
  715. // var regex = /window.webUser([\s\S]*?)};/gi;
  716. let script = await this.get_user_inf()
  717. // var matches = doc.match(regex);
  718. eval(script)
  719. // GM_setValue("userimg",window.webUser.largeFaceUrl||"");
  720. // let img_table = $(shadowContent.querySelector("#x_set"))
  721. // img_table.css("background","url(" + window.webUser.largeFaceUrl||"" + ")")
  722. let name = window.user_inf.result.name
  723. let id = window.user_inf.result.id
  724. this.config.user_id = "uschool_"+id
  725. this.config.full_name = name;
  726. let obj={
  727. "unionid": this.config.user_id,
  728. "username": this.config.full_name,
  729. "poolId":"ec942b0b-38c6-3256-b0e1-2a33428d4bbc",
  730. "grade": "uschool",
  731. };
  732. return obj
  733. }
  734. }
  735. /*
  736. * 学堂在线请求
  737. */
  738. class xuetangx_api{
  739. constructor(config) {
  740. this.config = config;
  741. }
  742. get_user_inf(){
  743. return new Promise((resolve,rejcet)=>{
  744. $.ajax({
  745. type: 'get',
  746. xhrFields: {
  747. withCredentials: true //允许跨域发送cookies
  748. },
  749. url: "https://www.xuetangx.com/api/v1/u/user/basic_profile/",
  750. success: function(res) {
  751. resolve(res.data);
  752. }
  753. });
  754. });
  755. }
  756. async get_user_obj(){
  757. let user_inf = await this.get_user_inf()
  758. console.log(user_inf)
  759. GM_setValue("userimg",user_inf.avatar||"");
  760. let img_table = $(shadowContent.querySelector("#x_set"))
  761. img_table.css("background","url(" + user_inf.avatar||"" + ")")
  762.  
  763. let name = user_inf.nickname
  764. let id = user_inf.user_id
  765. this.config.user_id = "xtzx_"+id
  766. this.config.full_name = name;
  767. let obj={
  768. "unionid": this.config.user_id,
  769. "username": this.config.full_name,
  770. "poolId":"ec942b0b-38c6-3256-b0e1-2a33428d4bbc",
  771. "grade": "学堂在线",
  772. };
  773. return obj
  774. }
  775. }
  776. /*
  777. * mooc请求
  778. */
  779. class mooc_api{
  780. constructor(config) {
  781. this.config = config;
  782. }
  783. async init_button(){
  784. if(this.config.front_url[this.config.front_url.length-1] =="studycontent"||this.config.front_url[this.config.front_url.length-2]=="studentLog"){
  785. GM_setValue("resource_farming_state",false) // 跨域访问,清空默认状态
  786. div_zhu.append("<button id='x_res' ><span>一键完成资源</span></button>");
  787. }else{
  788. // let a = await this.get_ansers()
  789. // console.log(a)
  790. div_zhu.append("<button onclick='window.open(\"https://d.metost.com\");'><span>MeTo题库</span></button>");
  791. }
  792. }
  793. getCookie(objName) { //获取指定名称的cookie的值
  794. var arrStr = document.cookie.split("; ");
  795. for (var i = 0; i < arrStr.length; i++) {
  796. var temp = arrStr[i].split("=");
  797. if (temp[0] == objName) return temp[1]; //解码
  798. }
  799. return "";
  800. }
  801. get_ansers(){
  802. return new Promise((resolve,rejcet)=>{
  803. $.ajax({
  804. type: 'post',
  805. xhrFields: {
  806. withCredentials: true //允许跨域发送cookies
  807. },
  808. data:{
  809. aid: 2698276550,
  810. tid: "1241795540",
  811. withStdAnswerAndAnalyse: true
  812. },
  813. url: "https://www.icourse163.org/web/j/mocQuizRpcBean.getOpenQuizPaperDto.rpc?csrfKey="+this.getCookie("NTESSTUDYSI"),
  814. success: function(res) {
  815. resolve(res);
  816. }
  817. });
  818. });
  819. }
  820.  
  821. get_user_inf(){
  822. return new Promise((resolve,rejcet)=>{
  823. $.ajax({
  824. type: 'get',
  825. xhrFields: {
  826. withCredentials: true //允许跨域发送cookies
  827. },
  828. url: "https://www.icourse163.org/home.htm",
  829. success: function(res) {
  830. resolve(res);
  831. }
  832. });
  833. });
  834. }
  835. async get_user_obj(){
  836. // var regex = /window.webUser([\s\S]*?)};/gi;
  837. // let doc = await this.get_user_inf()
  838. // var matches = doc.match(regex);
  839. // console.log(_this.webUser)
  840. // eval(matches[0])
  841. GM_setValue("userimg",_this.webUser.largeFaceUrl||"");
  842. let img_table = $(shadowContent.querySelector("#x_set"))
  843. img_table.css("background","url(" + _this.webUser.largeFaceUrl||"" + ")")
  844. let name = _this.webUser.nickName
  845. let id = _this.webUser.id
  846. this.config.user_id = "mooc_"+id
  847. this.config.full_name = name;
  848. let obj={
  849. "unionid": this.config.user_id,
  850. "username": this.config.full_name,
  851. "poolId":"ec942b0b-38c6-3256-b0e1-2a33428d4bbc",
  852. "grade": "mooc",
  853. };
  854. return obj
  855. }
  856. }
  857. /*
  858. * 雨课堂请求
  859. */
  860. class yuketang_api{
  861. constructor(config) {
  862. this.config = config;
  863. }
  864. async init_button(){
  865. if(this.config.front_url[this.config.front_url.length-1] =="studycontent"||this.config.front_url[this.config.front_url.length-2] =="studentLog"){
  866. GM_setValue("resource_farming_state",false) // 跨域访问,清空默认状态
  867. div_zhu.append("<button id='x_res' ><span>一键完成资源</span></button>");
  868. div_zhu.append("<button id='x_forum' ><span>讨论表</span></button>");
  869. } else if (this.config.front_url[this.config.front_url.length - 2] == "video" || this.config.front_url[this.config.front_url.length - 3] == "video-student" || this.config.front_url[this.config.front_url.length - 2] == "forum"){
  870. this.choice_function()
  871. if(GM_getValue("resource_farming_state")){
  872. div_zhu.append("<button id='x_xxx' ><span>正在刷资源,请稍后</span></button>");
  873. aner.show("hide")
  874. aner.text("如需暂停请刷新上一级页面")
  875. }else{
  876. if(GM_getValue("resource_farming_main_state")){
  877. div_zhu.append("<button onclick='GM_setValue(\"resource_farming_main_state\",false);location.reload()'><span>停止翻页</span></button>");
  878. }else{
  879. div_zhu.append("<button onclick='GM_setValue(\"resource_farming_main_state\",true);location.reload()'><span>自动翻页</span></button>");
  880. }
  881. div_zhu.append("<button id='x_forum' ><span>讨论表</span></button>");
  882. }
  883. }else if(this.config.front_url[7] == "exercise"){ //暂时屏蔽上传
  884. // aner.css("display","block")
  885. // aner.text("正在导入题库中");
  886. // if(!GM_getValue(this.config.id)){
  887. // let flag = await(this.get_quiz_result(this.config.front_url[8],this.config.front_url[9]));
  888. // if(flag == "success"){
  889. // aner.text("题库导入成功");
  890. // }else{
  891. // // aner.text("题库导入失败");
  892. // }
  893. // }else{
  894. // aner.text("题库已存在");
  895. // }
  896. }else{
  897. div_zhu.append("<button onclick='window.open(\"https://d.metost.com\");'><span>MeTo题库</span></button>");
  898. }
  899. }
  900. get_exercise_list(classId,paperId){
  901. return new Promise((resolve,rejcet)=>{
  902. $.ajax({
  903. type: 'GET',
  904. xhrFields: {
  905. withCredentials: true //允许跨域发送cookies
  906. },
  907. headers:{
  908. "Classroom-Id":classId,//this.config.front_url[8],
  909. "Xtbz":"ykt",
  910. },
  911. url: "https://"+this.config.front_url[2]+"/mooc-api/v1/lms/exercise/get_exercise_list/"+paperId+"/",
  912. success: function(res) {
  913. resolve(res.data);
  914. }
  915. });
  916. });
  917. }
  918. get_leaf_info(classId,id){
  919. return new Promise((resolve,rejcet)=>{
  920. $.ajax({
  921. type: 'GET',
  922. xhrFields: {
  923. withCredentials: true //允许跨域发送cookies
  924. },
  925. headers:{
  926. "Classroom-Id":classId,
  927. "Xtbz":"ykt",
  928. },
  929. url: "https://"+this.config.front_url[2]+"/mooc-api/v1/lms/learn/leaf_info/"+classId+"/"+id+"/",
  930. success: function(res) {
  931. resolve(res);
  932. }
  933. });
  934. });
  935. }
  936. async get_quiz_result(classId,id){
  937. var status = "error";
  938. let leaf_info = await this.get_leaf_info(classId,id);
  939. let paper = await this.get_exercise_list(classId,leaf_info.data.content_info.leaf_type_id)
  940. let classname = paper.problems[0].content.LibraryName
  941. var answers = this.reset_answer(paper);
  942. if(answers == null || JSON.stringify(answers) == '{}' ||GM_getValue(answers.id)){
  943. console.log("题库导入存在,或异常")
  944. return status;
  945. }
  946. let obj={
  947. "poolId": this.config.poolId,
  948. "userId": this.config.tk_uid,
  949. "tags":[classname,answers.title,"雨课堂"],
  950. "title": "ykt_"+ answers.id,
  951. "problems":[],
  952. };
  953. let data={};
  954. answers.rows.forEach(row=>{
  955. if(row.subject.length < 4 || row.answers == ""){
  956. console.log("题目录入有误");
  957. return; //跳出循环
  958. }
  959. data={
  960. "tags": ["雨课堂"],
  961. "text": row.subject,
  962. "answer": JSON.stringify(row.answers),
  963. };
  964. data.tags.push(row.type);
  965. let l = ["choice_A","choice_B","choice_C","choice_D","choice_E","choice_F","choice_G","choice_H","choice_I","choice_J","choice_K","choice_L","choice_M","choice_N","choice_O","choice_P","choice_Q","choice_R","choice_S","choice_T","choice_U","choice_V","choice_W","choice_X","choice_Y","choice_Z"];
  966. let i=0;
  967. row.options.forEach(option =>{
  968. data[l[i]]=option;
  969. i=i+1;
  970. })
  971. obj.problems.push(data);
  972. });
  973. if(obj.problems.length == 0){
  974. return;
  975. }
  976. aner.css("display","block")
  977. aner.text("因api被攻击暂不支持导入题库");
  978. aner.append(`</br>如需请更新完整版</a>进行更多体验`)
  979. return status;
  980. }
  981. reset_answer(data){
  982. let newData = {};
  983. if(data ==null){
  984. return console.log("并未获取到题库数据");
  985. }
  986. if("problems" in data){
  987. console.log("雨课堂题库重组中");
  988. newData.id = data.exercise_id;
  989. newData.title = data.name;
  990. newData.rows = [];
  991. data.problems.forEach(row=>{
  992. let _data = {};
  993. _data.id = row.content.ProblemID;
  994. let imgs =null;
  995. try{
  996. imgs = $.parseHTML(row.content.Body); // 去除特殊字符报错
  997. }catch (e){
  998. console.log(e);
  999. }
  1000. row.title=window.my.HtmlUtil.htmlDecode(row.content.Body);
  1001. if(imgs){
  1002. imgs.forEach(async function(img,index){
  1003. if(img.localName == "img"){
  1004. row.title += img.outerHTML;
  1005. }
  1006. })
  1007. }
  1008. // row.subject = row.subject.substr(0,500) //截断前500个字符
  1009. _data.subject = row.title;
  1010. _data.options = [];
  1011. _data.answers = [];
  1012. _data.type = row.content.TypeText;
  1013. let tmp_option = row.content.Options
  1014. if(row.user.is_show_answer){
  1015. tmp_option.forEach(option=>{
  1016. _data.options.push(window.my.HtmlUtil.htmlDecode(option.value));
  1017. if(typeof(row.user.answer) == 'string'){
  1018. if(option.key ==row.user.answer){
  1019. _data.answers.push(window.my.HtmlUtil.htmlDecode(option.value));
  1020. }
  1021. }else{
  1022. row.user.answer.forEach(value=>{
  1023. if(option.key == value){
  1024. _data.answers.push(window.my.HtmlUtil.htmlDecode(option.value));
  1025. }
  1026. })
  1027. }
  1028. });
  1029. }
  1030. // }else{
  1031. // if(row.isRight == true){
  1032. // tmp_option.forEach(option=>{
  1033. // _data.options.push(window.my.HtmlUtil.htmlDecode(option.Content));
  1034. // row.recordAnswer.split(",").forEach(index=>{
  1035. // if(option.SortOrder == index){
  1036. // _data.answers.push(window.my.HtmlUtil.htmlDecode(option.Content));
  1037. // }
  1038. // })
  1039. // });
  1040. // }else{
  1041. // _data=null;
  1042. // }
  1043. // }
  1044. // }
  1045. if(_data != null){
  1046. newData.rows.push(_data);
  1047. }
  1048. });
  1049. }else{
  1050. console.log(data);
  1051. }
  1052. console.log(newData)
  1053. return newData;
  1054. }
  1055. get_courses(){
  1056. return new Promise((resolve,rejcet)=>{
  1057. $.ajax({
  1058. type: 'GET',
  1059. xhrFields: {
  1060. withCredentials: true //允许跨域发送cookies
  1061. },
  1062. // headers:{
  1063. // "Classroom-Id":classId,
  1064. // "Xtbz":"ykt",
  1065. // },
  1066. url: "https://"+this.config.front_url[2]+"/v2/api/web/courses/list?identity=2",
  1067. success: function(res) {
  1068. resolve(res.data.list);
  1069. }
  1070. });
  1071. });
  1072. }
  1073. get_online_courseware(classId,free_sku_id){
  1074. return new Promise((resolve,rejcet)=>{
  1075. $.ajax({
  1076. type: 'GET',
  1077. xhrFields: {
  1078. withCredentials: true //允许跨域发送cookies
  1079. },
  1080. headers:{
  1081. "Classroom-Id":classId,
  1082. "Xtbz":"ykt",
  1083. },
  1084. url: "https://"+this.config.front_url[2]+"/c27/online_courseware/schedule/score_detail/single/"+free_sku_id+"/0/",
  1085. success: function(res) {
  1086. resolve(res.data);
  1087. }
  1088. });
  1089. });
  1090. }
  1091. get_classrooms(classId){
  1092. return new Promise((resolve,rejcet)=>{
  1093. $.ajax({
  1094. type: 'GET',
  1095. xhrFields: {
  1096. withCredentials: true //允许跨域发送cookies
  1097. },
  1098. headers:{
  1099. "Classroom-Id":classId,
  1100. "Xtbz":"ykt",
  1101. },
  1102. url: "https://"+this.config.front_url[2]+"/v2/api/web/classrooms/"+classId+"?role=5",
  1103. success: function(res) {
  1104. resolve(res.data);
  1105. }
  1106. });
  1107. });
  1108. }
  1109. // async upload_all_problem(show_aner){ //暂时不收集
  1110. // let classListData = await (this.get_courses());
  1111. // let class_length = 0
  1112. // if(show_aner){
  1113. // aner.text("欢迎您的第一次使用,正在为您聚合数据中,请稍后。。。。");
  1114. // aner.css("display","block")
  1115. // }
  1116. // for(let i=0;i<classListData.length;i++){
  1117. // let cl = classListData[i];
  1118. // let classrooms = await this.get_classrooms(cl.classroom_id)
  1119. // let coursewares = await this.get_online_courseware(cl.classroom_id,classrooms.free_sku_id)
  1120. // if(!coursewares.leaf_level_infos){
  1121. // continue;
  1122. // }else{
  1123. // coursewares = coursewares.leaf_level_infos
  1124. // }
  1125. // for(let j=0;j<coursewares.length;j++){
  1126. // let courseware = coursewares[j];
  1127. // console.log(courseware.leaf_type, courseware.schedule, !GM_getValue(courseware.id))
  1128. // if(courseware.leaf_type==6 && courseware.schedule && !GM_getValue(courseware.id)){
  1129. // class_length++;
  1130. // try{
  1131. // await(this.get_quiz_result(cl.classroom_id,courseware.id));
  1132. // console.log(courseware.id+"upload成功")
  1133. // }catch{
  1134. // console.log(courseware.id+"upload失败")
  1135. // }
  1136. // if(show_aner){
  1137. // aner.text("百分比长时间未动请刷新页面\n已加载:"+class_length+"%");
  1138. // }
  1139. // }
  1140. // }
  1141. // // console.log(result)
  1142. // // .then((result) =>{
  1143. // // $(result).find(".interaction-row").each(async (index,div)=>{
  1144. // // let id = $(div).attr('data-id');
  1145. // // let type = $(div).attr('data-type');
  1146. // // let status = $(div).attr('data-row-status');
  1147. // // if(type=="QUIZ"){
  1148. // //
  1149. // // }
  1150. // // })
  1151.  
  1152. // // });
  1153. // }
  1154. // }
  1155. get_user_inf(){
  1156. return new Promise((resolve,rejcet)=>{
  1157. $.ajax({
  1158. type: 'get',
  1159. xhrFields: {
  1160. withCredentials: true //允许跨域发送cookies
  1161. },
  1162. url: "https://"+this.config.front_url[2]+"/edu_admin/get_user_basic_info",
  1163. success: function(res) {
  1164. resolve(res.data.user_info);
  1165. }
  1166. });
  1167. });
  1168. }
  1169. get_user_inf1(){
  1170. return new Promise((resolve,rejcet)=>{
  1171. $.ajax({
  1172. type: 'get',
  1173. xhrFields: {
  1174. withCredentials: true //允许跨域发送cookies
  1175. },
  1176. url: "https://"+this.config.front_url[2]+"/v2/api/web/userinfo",
  1177. success: function(res) {
  1178. resolve(res.data[0]);
  1179. }
  1180. });
  1181. });
  1182. }
  1183. async get_user_obj(){
  1184. let user_inf = await this.get_user_inf() || await this.get_user_inf1()
  1185. GM_setValue("userimg",user_inf.avatar||"");
  1186. $(shadowContent.querySelector("#x_set"))
  1187. let img_table = $(shadowContent.querySelector("#x_set"))
  1188. img_table.css("background","url(" + user_inf.avatar||"" + ")")
  1189.  
  1190. let name = user_inf.name
  1191. let id = user_inf.user_id
  1192. this.config.user_id = "ykt_"+id
  1193. this.config.full_name = name;
  1194. let obj={
  1195. "unionid": this.config.user_id,
  1196. "username": this.config.full_name,
  1197. "poolId":"ec942b0b-38c6-3256-b0e1-2a33428d4bbc",
  1198. "grade": "雨课堂",
  1199. };
  1200. return obj
  1201. }
  1202. sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
  1203. // 创建一个 PointerEvent 对象
  1204. pointerEvent = new PointerEvent("pointerdown", {
  1205. bubbles: true,
  1206. cancelable: true,
  1207. pointerId: 1, // 指针 ID
  1208. pointerType: "mouse", // 指针类型
  1209. clientX: 100, // 指针在视口中的 X 坐标
  1210. clientY: 100, // 指针在视口中的 Y 坐标
  1211. });
  1212. async choice_function(){
  1213. if(!GM_getValue("resource_farming_state")&&!GM_getValue("resource_farming_main_state")){
  1214. return
  1215. }
  1216. let forum_flag = false;
  1217. for(let i=10;i;i--){
  1218. console.log($(".activity-content").text().length)
  1219. await this.sleep(1000)
  1220. if ($("video").length && $("video")[0].duration) {
  1221. console.log("视频加载")
  1222. let video = $("video")[0]
  1223.  
  1224. document.hasFocus = () => {
  1225. return true
  1226. }
  1227. await this.sleep(2000)
  1228. $(".xt_video_player_common_icon").click()
  1229.  
  1230.  
  1231. while (1) {
  1232. if (video.ended || $(".text").text().substr(-4, 4) == "100%" || $(".finish").length) {
  1233. break;
  1234. }
  1235. await this.sleep(1000)
  1236. video.muted = true;
  1237. $(".xt_video_bit_play_btn").click()
  1238. $(".xt_video_bit_play_btn")[0].dispatchEvent(this.pointerEvent);
  1239.  
  1240. }
  1241. break;
  1242. } else if ($(".publish_discuss_unit_container").length && !forum_flag) {
  1243. console.log("检测到未讨论")
  1244. if (GM_getValue("forum_texts")) {
  1245. var forum_texts = GM_getValue("forum_texts").split(",")
  1246. var forum_text = forum_texts[Math.floor(Math.random() * forum_texts.length)]
  1247. } else {
  1248. console.log("暂未设置讨论词")
  1249. continue;
  1250. }
  1251. $(".publish_discuss_unit_container").find("textarea").val(forum_text)
  1252. let ev = document.createEvent("HTMLEvents");
  1253. ev.initEvent("input", true, true);
  1254. $(".publish_discuss_unit_container").find("textarea")[0].dispatchEvent(ev);
  1255. await this.sleep(2000)
  1256. $(".submitComment").click()
  1257. forum_flag = true;
  1258. continue;
  1259. }
  1260. }
  1261. await this.sleep(1000)
  1262. if (GM_getValue("resource_farming_state")) {
  1263. GM_setValue("resource_farming_state", false)
  1264. window.close();
  1265. } else {
  1266. $(".btn-next").click()
  1267. }
  1268. }
  1269. async resource_farming(){
  1270. let activity_list=[]
  1271. let divs = $(".leaf-detail")
  1272. divs.each((index,div)=>{
  1273. if($(div).find(".icon--shipin").length && $(div).find(".el-tooltip").text()!="已完成" ){
  1274. activity_list.push(div)
  1275. }
  1276. })
  1277. divs = $(".right-content")[0] ||[]//雨课堂main site 视频
  1278. $(divs).find(".study-unit").each((index,div)=>{
  1279. if($(div).find("span")[1].innerHTML.trim() !="已完成"){
  1280. activity_list.push($(div).find(".name-text"))
  1281. }
  1282. })
  1283. activity_list.pop()
  1284. divs = $(".right-content")[1] || []//雨课堂main site 讨论
  1285. $(divs).find(".study-unit").each((index, div) => {
  1286. if ($(div).find("span")[1].innerHTML.trim() != "已发言") {
  1287. activity_list.push($(div).find(".name-text"))
  1288. }
  1289. })
  1290.  
  1291.  
  1292. if(activity_list.length){
  1293. console.log(activity_list.length)
  1294. }else{
  1295. aner.show("slow")
  1296. aner.text("未检测到页面资源,请等待页面加载完毕。 ")
  1297. aner.append("</br>若未展开资源,请点击全部展开。")
  1298. aner.append("</br>或者进入成绩单页面,再次点击。")
  1299. $(shadowContent.querySelector("#x_res")).attr("disabled", false)
  1300. $("#tab-student_school_report").click()
  1301. return
  1302. }
  1303. aner.show("slow")
  1304. aner.text("部分浏览器默认关闭弹出窗口,请在右上角开启")
  1305. // return
  1306. for(let i =0;i<activity_list.length;i++){
  1307. GM_setValue("resource_farming_state",true)
  1308. activity_list[i].click()
  1309. while(1){
  1310. if(GM_getValue("resource_farming_state")){
  1311. $(shadowContent.querySelector("#x_res")).text("剩余"+(activity_list.length - i)+"资源")
  1312. await this.sleep(1000)
  1313. }else{
  1314. break
  1315. }
  1316. }
  1317. }
  1318. $(shadowContent.querySelector("#x_res")).text("全部完成")
  1319. }
  1320. }
  1321. /*
  1322. * 超星请求
  1323. */
  1324. class chaoxin_api{
  1325. constructor(config) {
  1326. this.config = config;
  1327. // setInterval(()=> {
  1328. try{
  1329. iframe.onload = ()=>{
  1330. try {this.encode_font();} catch (e) {console.log(e)}
  1331. }
  1332. }catch{}
  1333. // }, 2000)
  1334. }
  1335. /**
  1336. * 原作者 wyn665817@163.com
  1337. * 链接 https://scriptcat.org/script-show-page/432/code
  1338. */
  1339. encode_font(){
  1340. console.log("解密字体")
  1341. // 判断是否存在加密字体
  1342. var $tip = $('iframe').contents().find("iframe").contents().find("iframe").contents().find('style:contains(font-cxsecret)')
  1343. if (!$tip.length) return;
  1344.  
  1345. // 解析font-cxsecret字体
  1346. var font = $tip.text().match(/base64,([\w\W]+?)'/)[1];
  1347. font = Typr.parse(base64ToUint8Array(font))[0];
  1348.  
  1349. // 匹配解密字体
  1350. var table = JSON.parse(GM_getResourceText('Table'));
  1351. var match = {};
  1352. for (var i = 19968; i < 40870; i++) { // 中文[19968, 40869]
  1353. $tip = Typr.U.codeToGlyph(font, i);
  1354. if (!$tip) continue;
  1355. $tip = Typr.U.glyphToPath(font, $tip);
  1356. $tip = CryptoJS.MD5(JSON.stringify($tip)).toString().slice(24); // 8位即可区分
  1357. match[i] = table[$tip];
  1358. }
  1359. // 替换加密字体
  1360. $('iframe').contents().find("iframe").contents().find("iframe").contents().find('.font-cxsecret').html(function(index, html) {
  1361. $.each(match, function(key, value) {
  1362. key = String.fromCharCode(key);
  1363. key = new RegExp(key, 'g');
  1364. value = String.fromCharCode(value);
  1365. html = html.replace(key, value);
  1366. });
  1367. return html;
  1368. }).removeClass('font-cxsecret'); // 移除字体加密
  1369.  
  1370. function base64ToUint8Array(base64) {
  1371. var data = window.atob(base64);
  1372. var buffer = new Uint8Array(data.length);
  1373. for (var i = 0; i < data.length; ++i) {
  1374. buffer[i] = data.charCodeAt(i);
  1375. }
  1376. return buffer;
  1377. }
  1378. }
  1379. async init_button(){
  1380. if(this.config.c === "res"||this.config.front_url[this.config.front_url.length-1] === "course-learning"){
  1381. div_zhu.append("<button id='x_res' ><span>一键完成资源</span></button>");
  1382. }else if(this.config.front_url[4] =="studentstudy"||this.config.front_url[5] =="studentstudy"){
  1383. this.choice_function()
  1384. if(GM_getValue("resource_farming_state")){
  1385. div_zhu.append("<button id='x_xxx' ><span>正在刷资源,请稍后</span></button>");
  1386. aner.show("hide")
  1387. aner.text("如需暂停请刷新上一级页面")
  1388. }else{
  1389. if(GM_getValue("resource_farming_main_state")){
  1390. div_zhu.append("<button onclick='GM_setValue(\"resource_farming_main_state\",false);location.reload()'><span>停止翻页</span></button>");
  1391. aner.show("hide")
  1392. aner.text("手动切换课程后请刷新页面")
  1393. }else{
  1394. div_zhu.append("<button onclick='GM_setValue(\"resource_farming_main_state\",true);location.reload()'><span>自动翻页</span></button>");
  1395. }
  1396. }
  1397. }else if(this.config.front_url[5] =="cards"){
  1398. console.log("获取答案")
  1399. if(!GM_getValue(this.config.knowledgeid)){
  1400. await this.get_quiz_result(this.config.clazzid,this.config.courseid,this.config.knowledgeid,this.config.num);
  1401. }else{
  1402. aner.show("hide")
  1403. aner.text("题库已存在");
  1404. }
  1405.  
  1406. }else{
  1407. div_zhu.append("<button onclick='window.open(\"https://d.metost.com\");'><span>MeTo题库</span></button>");
  1408. }
  1409. }
  1410.  
  1411.  
  1412. get_cards(clazzid,courseid,knowledgeid,num){
  1413. return new Promise((resolve,rejcet)=>{
  1414. GM_xmlhttpRequest({
  1415. method: "GET",
  1416. url: "https://mooc1-2.chaoxing.com/mooc-ans/knowledge/cards?clazzid="+clazzid+"&courseid="+courseid+"&knowledgeid="+knowledgeid+"&num="+num,
  1417. onload: res=> {
  1418. resolve(res.response);
  1419. },
  1420. onerror:err=>{
  1421. console.log("加载失败")
  1422. }
  1423. })
  1424. })
  1425. }
  1426. get_work(data){
  1427. let mArg = JSON.parse(data)
  1428. return new Promise((resolve,rejcet)=>{
  1429. GM_xmlhttpRequest({
  1430. method: "GET",
  1431. url: "https://mooc1-2.chaoxing.com/mooc-ans/api/work?api=1&workId="+mArg.attachments[0].property.workid+"&jobid="+mArg.attachments[0].property._jobid+"&needRedirect=true&skipHeader=true&knowledgeid="+mArg.defaults.knowledgeid+"&ktoken="+mArg.defaults.ktoken+"&cpi="+mArg.defaults.cpi+"&ut=s&clazzId="+mArg.defaults.clazzId+"&type=&enc="+mArg.attachments[0].enc+"&utenc=undefined&courseid="+mArg.defaults.courseid,
  1432. onload: res=> {
  1433. resolve(res);
  1434. },
  1435. onerror:err=>{
  1436. console.log("加载失败")
  1437. }
  1438. })
  1439. })
  1440. }
  1441. get_WorkQuestionYiPiYue(url){
  1442. url = url.replace("api=1", "api=0");
  1443. return new Promise((resolve,rejcet)=>{
  1444. GM_xmlhttpRequest({
  1445. method: "GET",
  1446. url: url,
  1447. onload: res=> {
  1448. resolve(res.response);
  1449. },
  1450. onerror:err=>{
  1451. console.log("加载失败")
  1452. }
  1453. })
  1454. })
  1455. }
  1456. async get_quiz_result(clazzid,courseid,knowledgeid,num){
  1457. var status = "error";
  1458. let card = await this.get_cards(clazzid,courseid,knowledgeid,num)
  1459. let pattern = /mArg = (\{.*\})/;
  1460. let match = card.match(pattern);
  1461. let work = await this.get_work(match[1])
  1462. let WorkQuestion = await this.get_WorkQuestionYiPiYue(work.finalUrl)
  1463. var answers = this.reset_answer(WorkQuestion);
  1464. if(answers == null || JSON.stringify(answers) == '{}'){
  1465. console.log("题库导入存在,或异常")
  1466. return status;
  1467. }
  1468. let obj={
  1469. "poolId": this.config.poolId,
  1470. "userId": this.config.tk_uid,
  1471. "tags":[$(WorkQuestion).find("h1").find("span")[0].innerText.trim(),answers.title,"超星"],
  1472. "title": "cx_"+ answers.id,
  1473. "problems":[],
  1474. };
  1475. let data={};
  1476. answers.rows.forEach(row=>{
  1477. if(row.subject.length < 4 || row.answers == ""){
  1478. console.log("题目录入有误");
  1479. return; //跳出循环
  1480. }
  1481. data={
  1482. "tags": ["超星"],
  1483. "text": row.subject,
  1484. "answer": JSON.stringify(row.answers),
  1485. };
  1486. data.tags.push(row.type);
  1487. let l = ["choice_A","choice_B","choice_C","choice_D","choice_E","choice_F","choice_G","choice_H","choice_I","choice_J","choice_K","choice_L","choice_M","choice_N","choice_O","choice_P","choice_Q","choice_R","choice_S","choice_T","choice_U","choice_V","choice_W","choice_X","choice_Y","choice_Z"];
  1488. let i=0;
  1489. row.options.forEach(option =>{
  1490. data[l[i]]=option;
  1491. i=i+1;
  1492. })
  1493. obj.problems.push(data);
  1494. });
  1495. if(obj.problems.length == 0){
  1496. return;
  1497. }
  1498. aner.css("display","block")
  1499. aner.text("因api被攻击暂不支持导入题库");
  1500. aner.append(`</br>如需请更新完整版</a>进行更多体验`)
  1501. return status;
  1502. }
  1503. HtmlUtil = { //此处由于window.my还没有加载完毕,所以提前拉进来
  1504. /*1.用浏览器内部转换器实现html转码*/
  1505. htmlEncode:function (html){
  1506. //1.首先动态创建一个容器标签元素,如DIV
  1507. var temp = document.createElement ("div");
  1508. //2.然后将要转换的字符串设置为这个元素的innerText(ie支持)或者textContent(火狐,google支持)
  1509. (temp.textContent != undefined ) ? (temp.textContent = html) : (temp.innerText = html);
  1510. //3.最后返回这个元素的innerHTML,即得到经过HTML编码转换的字符串了
  1511. var output = temp.innerHTML;
  1512. temp = null;
  1513. return output;
  1514. },
  1515. /*2.用浏览器内部转换器实现html解码*/
  1516. htmlDecode:function (text){
  1517. //1.首先动态创建一个容器标签元素,如DIV
  1518. var temp = document.createElement("div");
  1519. //2.然后将要转换的字符串设置为这个元素的innerHTML(ie,火狐,google都支持)
  1520. temp.innerHTML = text;
  1521. //3.最后返回这个元素的innerText(ie支持)或者textContent(火狐,google支持),即得到经过HTML解码的字符串了。
  1522. var output = temp.innerText || temp.textContent;
  1523. temp = null;
  1524. return output;
  1525. }
  1526. };
  1527. reset_answer(body){
  1528. let newData = {};
  1529. if(!$(body).find(".Py_answer").text().includes("正确答案")){
  1530. return console.log("并未获取到题库数据");
  1531. }
  1532. console.log("超星题库重组中");
  1533. newData.id = $(body).find("#knowledgeId")[0].value;
  1534. newData.title = $(body).find("#_title")[0].value;
  1535. newData.rows = [];
  1536. $(body).find(".imgReview").each((_,row)=>{
  1537. let _data = {};
  1538. _data.id = $(row).find("#moreScore").attr("data");
  1539. row.title=this.HtmlUtil.htmlDecode($(row).find("#questionStem_"+_data.id).text().trim());
  1540. row.title = row.title.substr(0,500) //截断前500个字符
  1541. _data.subject = row.title;
  1542. _data.options = [];
  1543. _data.answers = [];
  1544. _data.type = $(row).find("#typeName_"+_data.id)[0].value;
  1545.  
  1546. let tmp_option = $(row).find("li.clearfix")
  1547. if(tmp_option.length){//多单选择
  1548. tmp_option.each((_,option)=>{
  1549. _data.options.push(this.HtmlUtil.htmlDecode($(option).find("a").text().trim()));
  1550. let answers = $(row).find(".Py_answer").find("span")[0].innerText.substr(6).split("")
  1551. answers.forEach(answer =>{
  1552. if($(option).find("i").text()[0] == answer){
  1553. _data.answers.push(this.HtmlUtil.htmlDecode($(option).find("a").text().trim()));
  1554. }
  1555. })
  1556. });
  1557. }else{ //判断
  1558. if($(row).find(".Py_answer.Py_tk.clearfix").length){
  1559. _data.answers.push(this.HtmlUtil.htmlDecode($(row).find(".Py_answer.Py_tk.clearfix")[0].innerText.replace(/[\n\t ]/g, "").substr(5).trim()));
  1560. }else{
  1561. _data.answers.push(this.HtmlUtil.htmlDecode($(row).find(".Py_answer").find("span")[0].innerText.trim().substr(6).trim()));
  1562. }
  1563. }
  1564. if(_data != null){
  1565. newData.rows.push(_data);
  1566. }
  1567. });
  1568.  
  1569. console.log(newData)
  1570. return newData;
  1571. }
  1572. get_courses(){
  1573. return new Promise((resolve,rejcet)=>{
  1574. GM_xmlhttpRequest({
  1575. method: "GET",
  1576. url: "https://mooc1-2.chaoxing.com/visit/courses",
  1577. onload: res=> {
  1578. resolve(res.response);
  1579. },
  1580. onerror:err=>{
  1581. console.log("加载失败")
  1582. }
  1583. })
  1584. })
  1585. }
  1586. get_studentcourse(url){
  1587. return new Promise((resolve,rejcet)=>{
  1588. GM_xmlhttpRequest({
  1589. method: "GET",
  1590. url: url.replace("i.mooc","mooc1-2"),
  1591. onload: res=> {
  1592. resolve(res.response);
  1593. },
  1594. onerror:err=>{
  1595. console.log("加载失败")
  1596. }
  1597. })
  1598. })
  1599. }
  1600. get_student_specific(url){
  1601. return new Promise((resolve,rejcet)=>{
  1602. GM_xmlhttpRequest({
  1603. method: "GET",
  1604. url: "https://mooc1-2.chaoxing.com/mooc-ans/mycourse/studentstudyAjax?"+url,
  1605. onload: res=> {
  1606. resolve(res.response);
  1607. },
  1608. onerror:err=>{
  1609. console.log("加载失败")
  1610. }
  1611. })
  1612. })
  1613. }
  1614. async upload_all_problem(show_aner){
  1615. this.config.class_size = 0
  1616. this.config.class_length = 0
  1617. if(show_aner){
  1618. aner.text("欢迎您的第一次使用,正在为您聚合数据中,请稍后。。。。");
  1619. aner.css("display","block")
  1620. }
  1621. let courses = await (this.get_courses());
  1622. if(!courses){
  1623. return;
  1624. }
  1625. $(courses).find(".courseName").each(async (index,div)=>{
  1626. let studentcourse = await this.get_studentcourse(div.href)
  1627. if($(studentcourse).find(".clearfix").find(".openlock").length){
  1628. $(studentcourse).find(".clearfix").find("a").each(async (index,div)=>{
  1629. let arr1 = $(div)[0].href.split("?")
  1630. let specific = await this.get_student_specific(arr1[1])
  1631. let arr2 = arr1[1].split("&");
  1632. let obj = {};
  1633. for(let i=0;i<arr2.length;i++){
  1634. let res = arr2[i].split("=");
  1635. obj[res[0]]=res[1];
  1636. }
  1637. $(specific).find("span").each(async (index,div)=>{
  1638. let pattern = /测验|试题|检测|考试|测试|考查|考察|考验|考题|评估|检查|检验/;
  1639. if(pattern.test(div.innerText)){//如果包含以上内容
  1640. this.config.class_length++;
  1641. this.config.class_size++;
  1642. try{
  1643. await this.get_quiz_result(obj.clazzid,obj.courseId,obj.chapterId,div.attributes.class.value[1] -1)
  1644. console.log(obj.chapterId+"upload成功")
  1645. }catch(e){
  1646. console.log(e)
  1647. console.log(obj.chapterId+"upload失败")
  1648. }
  1649. this.config.class_size--;
  1650. if(show_aner){
  1651. aner.text("百分比长时间未动请刷新页面\n已加载:"+Math.trunc((1-(this.config.class_size/this.config.class_length))*100)+"%");
  1652. }
  1653. }
  1654. })
  1655. })
  1656. }
  1657. })
  1658.  
  1659. return
  1660. }
  1661.  
  1662. get_userid(){
  1663. return new Promise((resolve,rejcet)=>{
  1664. $.ajax({
  1665. type: 'post',
  1666. // xhrFields: {
  1667. // withCredentials: true //允许跨域发送cookies
  1668. // },
  1669. url:"http://i.chaoxing.com/base",
  1670. success: function(res) {
  1671. resolve(res);
  1672. }
  1673. });
  1674. });
  1675. }
  1676. sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
  1677. async get_user_obj(){
  1678. // let a = await this.get_userid()
  1679. let name = null
  1680. let id = null
  1681. if($("body").find(".user").find("img")[0]){
  1682. GM_setValue("userimg",$("body").find(".user").find("img")[0].attributes.src.value||"");
  1683. let img_table = $(shadowContent.querySelector("#x_set"))
  1684. img_table.css("background","url(" + $("body").find(".user").find("img")[0].attributes.src.value||"" + ")")
  1685. name = $("body").find(".user").find("h3")[0].innerText
  1686. id = $("body").find(".user").find("img")[0].attributes.src.value.substr(28,9)
  1687. }else if($("body").find(".zt_u_b").find("img")[0]){
  1688. GM_setValue("userimg",$("body").find(".zt_u_b").find("img")[0].attributes.src.value||"");
  1689. let img_table = $(shadowContent.querySelector("#x_set"))
  1690. img_table.css("background","url(" + GM_getValue("userimg")||"" + ")")
  1691. name = $("body").find(".zt_u_b").find(".zt_u_name")[0].innerText
  1692. id = $("body").find(".zt_u_b").find("img")[0].attributes.src.value.substr(34,9)
  1693. }else{
  1694. GM_setValue("userimg",$("body").find(".headPic").find("img")[0].attributes.src.value||"");
  1695. let img_table = $(shadowContent.querySelector("#x_set"))
  1696. img_table.css("background","url(" + $("body").find(".headPic").find("img")[0].attributes.src.value||"" + ")")
  1697. name = $("body").find(".name")[0].outerText
  1698. id = $("body").find(".headPic").find("img")[0].attributes.src.value.substr(35,9)
  1699. }
  1700. if(!id){
  1701. return
  1702. }
  1703. this.config.user_id = "cx_"+id;
  1704. this.config.full_name = name;
  1705. let obj={
  1706. "unionid": this.config.user_id,
  1707. "username": this.config.full_name,
  1708. "poolId":"ec942b0b-38c6-3256-b0e1-2a33428d4bbc",
  1709. "grade": "超星",
  1710. };
  1711. return obj
  1712. }
  1713. async choice_function(){
  1714. if(!GM_getValue("resource_farming_main_state")){
  1715. return
  1716. }
  1717. for(let i=10;i;i--){
  1718. await this.sleep(1000)
  1719. console.log("开始检测页面内容"+i)
  1720. let video
  1721. if($('iframe').length){
  1722. video = $('iframe').contents().find("iframe").contents().find("video")[0]
  1723. }
  1724. if(video){
  1725. console.log("视频加载")
  1726. video.muted = true;
  1727. while(1){
  1728. if(video.ended||$('iframe').contents().find(".ans-job-icon").attr("aria-label") == '任务点已完成'){
  1729. console.log("播放结束")
  1730. break;
  1731. }
  1732. // $(".playButton").click()
  1733. video.play()
  1734. // let mi = video.duration - video.currentTime
  1735. // console.log(mi)
  1736. await this.sleep(1000)
  1737. }
  1738. break;
  1739. }
  1740. }
  1741. try{
  1742. $(".orientationright")[0].click()
  1743. }catch{
  1744. $(".jb_btn.nextChapter").click()
  1745. //$("#prevNextFocusNext").click()
  1746. }
  1747. try{
  1748. $(".nextChapter.prebutton").click()
  1749. }catch{
  1750. }
  1751. // GM_setValue("resource_farming_state",false)
  1752. this.choice_function() //再次循环
  1753. }
  1754.  
  1755. }
  1756. /*
  1757. * 国开请求
  1758. */
  1759. class ouchn_api{
  1760. constructor(config) {
  1761. this.config = config;
  1762. }
  1763. async init_button(){
  1764. if(this.config.front_url[5] =="ng#" ||this.config.front_url[5] =="ng" ){
  1765. GM_setValue("resource_farming_state",false) // 跨域访问,清空默认状态
  1766. div_zhu.append("<button id='x_res' ><span>一键完成资源</span></button>");
  1767. }else if(this.config.front_url[5] =="learning-activity"){
  1768. this.choice_function()
  1769. if(GM_getValue("resource_farming_state")){
  1770. div_zhu.append("<button id='x_xxx' ><span>正在刷资源,请稍后</span></button>");
  1771. aner.show("hide")
  1772. aner.text("如需暂停请刷新上一级页面")
  1773. }else{
  1774. if(GM_getValue("resource_farming_main_state")){
  1775. div_zhu.append("<button onclick='GM_setValue(\"resource_farming_main_state\",false);location.reload()'><span>停止翻页</span></button>");
  1776. }else{
  1777. div_zhu.append("<button onclick='GM_setValue(\"resource_farming_main_state\",true);location.reload()'><span>自动翻页</span></button>");
  1778. }
  1779. }
  1780. }else if(this.config.front_url[6]=="submission"){
  1781. // div_zhu.append("<button id='x_start' ><span>开始搜题</span></button>");
  1782. aner.css("display","block")
  1783. aner.text("正在导入题库中");
  1784. if(!GM_getValue(this.config.front_url[7])){
  1785. let flag = await(this.get_quiz_result(this.config.front_url[4],this.config.front_url[7]));
  1786. }else{
  1787. aner.text("题库已存在");
  1788. }
  1789. }else{
  1790. div_zhu.append("<button onclick='window.open(\"https://d.metost.com\");'><span>MeTo题库</span></button>");
  1791. }
  1792. }
  1793.  
  1794. get_submission(exam,submission){
  1795. return new Promise((resolve,rejcet)=>{
  1796. $.ajax({
  1797. type: 'GET',
  1798. xhrFields: {
  1799. withCredentials: true //允许跨域发送cookies
  1800. },
  1801. url:"https://lms.ouchn.cn/api/exams/"+exam+"/submissions/"+submission,
  1802. success: function(res) {
  1803. resolve(res);
  1804. }
  1805. });
  1806. });
  1807. }
  1808.  
  1809. async get_quiz_result(exams,submissions){
  1810. let res = await (this.get_submission(exams,submissions));
  1811. var status = "error";
  1812. let answers = this.reset_answer(res);
  1813. answers.title = GM_getValue(examId)||"未命名试卷"
  1814. if(answers == null || JSON.stringify(answers) == '{}' ){
  1815. return status;
  1816. }
  1817. let obj={
  1818. "poolId": this.config.poolId,
  1819. "userId": this.config.tk_uid,
  1820. "tags":[answers.title,"国开"],
  1821. "title":"gk_"+submissions,
  1822. "problems":[],
  1823. };
  1824. let data={};
  1825. answers.rows.forEach(row=>{
  1826. if(row.subject.length < 4 || row.answers == ""){
  1827. console.log("题目录入有误:");
  1828. console.log(row);
  1829. return; //跳出循环
  1830. }
  1831. data={
  1832. "tags": ["国开"],
  1833. "text": row.subject,
  1834. "answer": JSON.stringify(row.answers),
  1835. };
  1836. data.tags.push(row.type);
  1837. let l = ["choice_A","choice_B","choice_C","choice_D","choice_E","choice_F","choice_G","choice_H","choice_I","choice_J","choice_K","choice_L","choice_M","choice_N","choice_O","choice_P","choice_Q","choice_R","choice_S","choice_T","choice_U","choice_V","choice_W","choice_X","choice_Y","choice_Z"];
  1838. let i=0;
  1839. row.options.forEach(option =>{
  1840. data[l[i]]=option;
  1841. i=i+1;
  1842. })
  1843. obj.problems.push(data);
  1844. });
  1845. if(obj.problems.length == 0){
  1846. return;
  1847. }
  1848. aner.css("display","block")
  1849. aner.text("因api被攻击暂不支持导入题库");
  1850. aner.append(`</br>如需请更新完整版</a>进行更多体验`)
  1851. return status;
  1852. }
  1853.  
  1854. reset_answer(data){
  1855. let newData = {};
  1856. if(data ==null){
  1857. return console.log("并未获取到题库数据");
  1858. }
  1859. if("subjects_data" in data){
  1860. console.log("国开题库重组中");
  1861. console.log(data)
  1862. let subjects = data.subjects_data.subjects;
  1863. let submission_score_data = data.submission_score_data;
  1864. let submission_data = data.submission_data;
  1865. newData.title = "暂无";
  1866. newData.rows = [];
  1867. subjects.forEach(row=>{
  1868. let _data = {};
  1869. _data.id = row.id;
  1870. let imgs =null;
  1871. try{
  1872. imgs = $.parseHTML(row.description); // 去除特殊字符报错
  1873. }catch (e){
  1874. console.log(e);
  1875. }
  1876. row.description=window.my.HtmlUtil.htmlDecode(row.description);
  1877. if(imgs){
  1878. imgs.forEach(async function(img,index){
  1879. if(img.localName == "img"){
  1880. row.description += img.outerHTML;
  1881. }
  1882. })
  1883. }
  1884. // row.subject = row.subject.substr(0,500) //截断前500个字符
  1885. _data.subject = row.description;
  1886. _data.options = [];
  1887. _data.answers = [];
  1888. _data.type = row.type;
  1889. let tmp_option =null;
  1890. // if(row.options.length){
  1891. // tmp_option = JSON.parse(row.options)
  1892. // }
  1893. // if(tmp_option){
  1894. row.options.forEach(option=>{
  1895. _data.options.push(window.my.HtmlUtil.htmlDecode(option.content).trim());
  1896. if(option.is_answer){
  1897. _data.answers.push(window.my.HtmlUtil.htmlDecode(option.content).trim());
  1898. }else if(!("is_answer" in option)){ //如果不包含这个值 则判断用户选择
  1899. if(!submission_score_data){
  1900. return;
  1901. }
  1902. if(submission_score_data[_data.id] == row.point){//如果用户答案正确
  1903. submission_data.subjects.forEach(element => {
  1904. if(element.answers){ //填空题
  1905. element.answers.forEach(answer =>{
  1906. _data.answers.push(window.my.HtmlUtil.htmlDecode(answer.content).trim());
  1907. })
  1908. }else{ //选择题
  1909. element.answer_option_ids.forEach(answer_id =>{
  1910. if(option.id == answer_id){
  1911. _data.answers.push(window.my.HtmlUtil.htmlDecode(option.content).trim());
  1912. }
  1913. })
  1914. }
  1915. });
  1916. }
  1917. }
  1918. });
  1919. if(_data != null){
  1920. newData.rows.push(_data);
  1921. }
  1922. });
  1923. }else{
  1924. console.log(data);
  1925. }
  1926. console.log(newData)
  1927. return newData;
  1928. }
  1929.  
  1930. get_userid(){
  1931. return new Promise((resolve,rejcet)=>{
  1932. $.ajax({
  1933. type: 'GET',
  1934. xhrFields: {
  1935. withCredentials: true //允许跨域发送cookies
  1936. },
  1937. url:"https://lms.ouchn.cn/user/settings",
  1938. success: function(res) {
  1939. resolve(res);
  1940. }
  1941. });
  1942. });
  1943. }
  1944. // get_user_inf(){
  1945. // return new Promise((resolve,rejcet)=>{
  1946. // $.ajax({
  1947. // type: 'GET',
  1948. // xhrFields: {
  1949. // withCredentials: true //允许跨域发送cookies
  1950. // },
  1951. // url:"https://lms.ouchn.cn/api/user/20000797261/accounts",
  1952. // success: function(res) {
  1953. // resolve(res[0]);
  1954. // }
  1955. // });
  1956. // });
  1957. // }
  1958. async get_user_obj(){
  1959. // let a = await this.get_userid()
  1960. // a = $(a)
  1961. // eval(a.find("script")[0])
  1962. // console.log(globalData)
  1963. // let user_inf = await(this.get_user_inf());
  1964. // if(!user_inf){
  1965. // return;
  1966. // }
  1967. // console.log(user_inf)
  1968. let user_inf = _this.globalData.user
  1969. // GM_setValue("userimg",user_inf.avatarUrl||"");
  1970. // let img_table = $(shadowContent.querySelector("#x_set"))
  1971. // img_table.css("background","url(" + user_inf.avatarUrl||"" + ")")
  1972. this.config.user_id = "gk_"+user_inf.id
  1973. this.config.full_name = user_inf.name;
  1974. let obj={
  1975. "unionid": this.config.user_id,
  1976. "username": this.config.full_name,
  1977. "poolId":"ec942b0b-38c6-3256-b0e1-2a33428d4bbc",
  1978. "grade": "国开",
  1979. };
  1980. return obj
  1981. }
  1982.  
  1983. get_activity_reads(course){
  1984. return new Promise((resolve,rejcet)=>{
  1985. $.ajax({
  1986. type: 'GET',
  1987. xhrFields: {
  1988. withCredentials: true //允许跨域发送cookies
  1989. },
  1990. url:"https://lms.ouchn.cn/api/course/"+course+"/activity-reads-for-user",
  1991. success: function(res) {
  1992. resolve(res);
  1993. }
  1994. });
  1995. });
  1996. }
  1997. get_completeness(course){
  1998. return new Promise((resolve,rejcet)=>{
  1999. $.ajax({
  2000. type: 'GET',
  2001. xhrFields: {
  2002. withCredentials: true //允许跨域发送cookies
  2003. },
  2004. url:"https://lms.ouchn.cn/api/course/"+course+"/my-completeness",
  2005. success: function(res) {
  2006. resolve(res);
  2007. }
  2008. });
  2009. });
  2010. }
  2011. get_models(course){
  2012. return new Promise((resolve,rejcet)=>{
  2013. $.ajax({
  2014. type: 'GET',
  2015. xhrFields: {
  2016. withCredentials: true //允许跨域发送cookies
  2017. },
  2018. url:"https://lms.ouchn.cn/api/courses/"+course+"/modules",
  2019. success: function(res) {
  2020. resolve(res);
  2021. }
  2022. });
  2023. });
  2024. }
  2025. get_all_activities(course,str){
  2026. return new Promise((resolve,rejcet)=>{
  2027. $.ajax({
  2028. type: 'GET',
  2029. xhrFields: {
  2030. withCredentials: true //允许跨域发送cookies
  2031. },
  2032. url:"https://lms.ouchn.cn/api/course/"+course+"/all-activities?module_ids="+str,
  2033. success: function(res) {
  2034. resolve(res);
  2035. }
  2036. });
  2037. });
  2038. }
  2039. async choice_function(){
  2040. if(!GM_getValue("resource_farming_state")&&!GM_getValue("resource_farming_main_state")){
  2041. return
  2042. }
  2043. for(let i=10;i;i--){
  2044. console.log($(".activity-content").text().length)
  2045. await this.sleep(1000)
  2046. if($(".activity-content").find(".text-too-long").length){
  2047. console.log("检测到ppt按钮")
  2048. $(".activity-content").find(".text-too-long").click()
  2049. break;
  2050. }else if($(".join-button").length){
  2051. console.log("课堂直播")
  2052. break;
  2053. }else if($("video").length&&$("video")[0].duration){
  2054. console.log("视频加载")
  2055. let video = $("video")[0]
  2056. video.muted = true;
  2057. while(1){
  2058. if(video.ended){
  2059. break;
  2060. }
  2061. $(".mvp-fonts-play").click()
  2062. // let mi = video.duration - video.currentTime
  2063. // console.log(mi)
  2064. await this.sleep(1000)
  2065. }
  2066. break;
  2067. }else if($(".activity-content").find(".page-box").length){
  2068. console.log("文章加载")
  2069. break;
  2070. }else if($(".exam-activity-box").length){
  2071. console.log("测试题加载")
  2072. await this.sleep(1000)//测试题box加载过快,可能导致没有下一个
  2073. break;
  2074. }
  2075. }
  2076. await this.sleep(3000)
  2077. GM_setValue("resource_farming_state",false)
  2078. $(".next-btn").click()
  2079. }
  2080. sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
  2081. async resource_farming(){
  2082. let course = this.config.front_url[4]
  2083. let url = "https://lms.ouchn.cn/course/"+course+"/learning-activity/full-screen#/"
  2084. let activity_list=[]
  2085. let divs = $(".learning-activity")
  2086. divs.each((index,div)=>{
  2087. let type = $(div).find(".activity-summary").attr("ng-switch-when")
  2088. if($(div).find(".completeness").attr("class") != "completeness full" && type != "exam"&& type != "forum" &&type != "homework"){
  2089. try{
  2090. var id = $(div).attr("id").substr(18)
  2091. }catch{
  2092. return
  2093. }
  2094. activity_list.push(id)
  2095. }
  2096. })
  2097. if(activity_list.length){
  2098. console.log(activity_list)
  2099. }else{
  2100. aner.show("slow")
  2101. aner.text("未检测到页面资源,请等待页面加载完毕。 ")
  2102. aner.append("</br>若未展开资源,请点击全部展开。")
  2103. $(shadowContent.querySelector("#x_res")).attr("disabled", false)
  2104. return
  2105. }
  2106. aner.show("slow")
  2107. aner.text("部分浏览器默认关闭弹出窗口,请在右上角开启")
  2108. // return
  2109. for(let i =0;i<activity_list.length;i++){
  2110. GM_setValue("resource_farming_state",true)
  2111. let childwindow = window.open(url+activity_list[i], "_blank")
  2112. while(1){
  2113. if(GM_getValue("resource_farming_state")){
  2114. $(shadowContent.querySelector("#x_res")).text("剩余"+(activity_list.length - i)+"资源")
  2115. await this.sleep(1000)
  2116. }else{
  2117. childwindow.close()
  2118. break
  2119. }
  2120. }
  2121. }
  2122. $(shadowContent.querySelector("#x_res")).text("全部完成")
  2123. }
  2124. }
  2125. /*
  2126. * meto请求
  2127. */
  2128. class meto_api{
  2129. constructor(config) {
  2130. this.config = config;
  2131. }
  2132. get_user_inf(){
  2133. return new Promise((resolve,rejcet)=>{
  2134. $.ajax({
  2135. type: 'GET',
  2136. xhrFields: {
  2137. withCredentials: true //允许跨域发送cookies
  2138. },
  2139. url:"https://v.metost.com/api/user",
  2140. success: function(res) {
  2141. resolve(res);
  2142. }
  2143. });
  2144. });
  2145. }
  2146. async get_user_obj(){
  2147. let user_inf = await(this.get_user_inf());
  2148. if(!user_inf){
  2149. return;
  2150. }
  2151. this.config.tk_uid = user_inf.id;
  2152. this.config.pp = user_inf.sal;
  2153. this.config.user_id = user_inf.user.email
  2154. this.config.poolId = CryptoJS.MD5(CryptoJS.MD5(this.config.user_id).toString() + this.config.pp).toString();
  2155. this.config.poolId = this.config.poolId.slice(0,8)+"-"+this.config.poolId.slice(8,12)+"-"+this.config.poolId.slice(12,16)+"-"+this.config.poolId.slice(16,20)+"-"+this.config.poolId.slice(20,32)
  2156. GM_setValue("poolId",this.config.poolId);
  2157. GM_setValue("ti_uid",this.config.tk_uid);
  2158. // GM_setValue("userimg",user_inf.avatarUrl||"");
  2159. // let img_table = $(shadowContent.querySelector("#x_set"))
  2160. // img_table.css("background","url(" + user_inf.avatarUrl||"" + ")")
  2161. this.config.full_name = user_inf.name;
  2162. let obj={
  2163. "unionid": this.config.user_id,
  2164. "username": "",
  2165. "poolId":"ec942b0b-38c6-3256-b0e1-2a33428d4bbc",
  2166. "grade": "meto",
  2167. };
  2168. return obj
  2169. }
  2170. }
  2171. /*
  2172. * 智慧职教请求
  2173. */
  2174. class icve_api{
  2175. constructor(config) {
  2176. this.config = config;
  2177. }
  2178. async init_button(){
  2179. if(this.config.front_url[this.config.front_url.length-1] == "keepTest"||this.config.front_url[this.config.front_url.length-1] =="jobTest"){ //
  2180. // this.Listener();
  2181. div_zhu.append("<button id='x_start' ><span>开始搜题</span></button>");
  2182. }else if(this.config.front_url[this.config.front_url.length-1] =="course-learning"){ //暂未实现 留置
  2183. div_zhu.append("<button id='x_res' ><span>一键完成资源</span></button>");
  2184. }else if(this.config.front_url[this.config.front_url.length-1] == "viewJob1"){ //旧版,似乎还有在用。
  2185. aner.css("display","block")
  2186. aner.text("正在导入题库中");
  2187. let examId = this.config.examId||this.config.id;
  2188. let taskId = this.config.recordId||this.config.taskId;
  2189. if(!GM_getValue(examId+taskId)){
  2190. let flag = await(this.get_quiz_result(examId,taskId,"独立导入"));
  2191.  
  2192. }else{
  2193. aner.text("题库已存在");
  2194. }
  2195. }else if(this.config.front_url[this.config.front_url.length-1] == "examrecord_recordDetail.action"){
  2196. aner.css("display","block")
  2197. aner.text("正在导入题库中");
  2198. let recordId = this.config.recordId;
  2199. if(!GM_getValue(recordId)){
  2200. let flag = await(this.get_new_quiz_result(recordId));
  2201.  
  2202. }else{
  2203. aner.text("题库已存在");
  2204. }
  2205. }else if(this.config.front_url[this.config.front_url.length-2] == "templateeight"){
  2206. this.choice_function()
  2207. if(GM_getValue("resource_farming_main_state")){
  2208. div_zhu.append("<button onclick='GM_setValue(\"resource_farming_main_state\",!1);location.reload()'><span>停止翻页</span></button>");
  2209. }else{
  2210. div_zhu.append("<button onclick='GM_setValue(\"resource_farming_main_state\",!0);location.reload()'><span>自动翻页</span></button>");
  2211. }
  2212. }else{
  2213. div_zhu.append("<button onclick='window.open(\"https://d.metost.com\");'><span>MeTo题库</span></button>");
  2214. }
  2215. }
  2216. sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
  2217. async choice_function(){
  2218. if(!GM_getValue("resource_farming_main_state")){
  2219. return
  2220. }
  2221. var divIframe
  2222. for(let i=10;i;i--){
  2223. console.log(i)
  2224. await this.sleep(1000)
  2225. divIframe = $("iframe").contents()
  2226. divIframe.find(".done_icon_show").remove()
  2227. let videoIframe = $("iframe").contents().find("iframe").contents()
  2228. if($(videoIframe).find("video").length&&$(videoIframe).find("video")[0].duration){
  2229. console.log("视频加载")
  2230. let video = $(videoIframe).find("video")[0]
  2231. video.muted = true;
  2232. while(1){
  2233. if(video.ended){
  2234. console.log("视频播放结束")
  2235. break;
  2236. }
  2237. $(videoIframe).find(".coursespace.screen-player-btn-icon.icon-play-sp-fill").click()
  2238. await this.sleep(1000)
  2239. }
  2240. break;
  2241. }
  2242. }
  2243. divIframe.find(".item_done_pos")[1].click()
  2244. this.choice_function()
  2245. }
  2246. get_user_inf(){
  2247. return new Promise((resolve,rejcet)=>{
  2248. $.ajax({
  2249. type: 'GET',
  2250. xhrFields: {
  2251. withCredentials: true //允许跨域发送cookies
  2252. },
  2253. // url:"https://sso.icve.com.cn/prod-api/user/userInfo?token="+this.getCookie("token"),
  2254. // success: function(res) {
  2255. // resolve(res.data);
  2256. // }
  2257. headers: {
  2258. "Authorization":"Bearer "+this.getCookie("Token"),
  2259. },
  2260. url:"https://zyk.icve.com.cn/prod-api/system/user/getInfo",
  2261. success: function(res) {
  2262. resolve(res.user);
  2263. }
  2264. });
  2265. });
  2266. }
  2267. get_user_inf1(){ //https://www.icve.com.cn/
  2268. return new Promise((resolve,rejcet)=>{
  2269. $.ajax({
  2270. type: 'GET',
  2271. xhrFields: {
  2272. withCredentials: true //允许跨域发送cookies
  2273. },
  2274. url:"https://www.icve.com.cn/studycenter/PersonalInfo/getUserInfo",
  2275. success: function(res) {
  2276. resolve(res.userInfo);
  2277. }
  2278. });
  2279. });
  2280. }
  2281. getCookie(objName) { //获取指定名称的cookie的值
  2282. var arrStr = document.cookie.split("; ");
  2283. for (var i = 0; i < arrStr.length; i++) {
  2284. var temp = arrStr[i].split("=");
  2285. if (temp[0] == objName) return temp[1]; //解码
  2286. }
  2287. return "";
  2288. }
  2289. async get_user_obj(){
  2290. let user_inf={}
  2291. if (_this._UID_){
  2292. user_inf.id = _this._UID_;
  2293. user_inf.displayName = _this._TRUENAME_;
  2294. }else{
  2295. user_inf = await(this.get_user_inf());
  2296. if(!user_inf){
  2297. user_inf = await(this.get_user_inf1());
  2298. if(!user_inf){
  2299. return
  2300. }
  2301. }
  2302. }
  2303. console.log(user_inf)
  2304. GM_setValue("userimg",user_inf.avatarUrl||"");
  2305. let img_table = $(shadowContent.querySelector("#x_set"))
  2306. img_table.css("background","url(" + user_inf.avatarUrl||"" + ")")
  2307. this.config.user_id = "icve_"
  2308. this.config.user_id += user_inf.id||user_inf.userId||user_inf.Id;
  2309. this.config.full_name = user_inf.displayName|| user_inf.nickName||user_inf.DisplayName;
  2310. let obj={
  2311. "unionid": this.config.user_id,
  2312. "username": this.config.full_name,
  2313. "poolId":"ec942b0b-38c6-3256-b0e1-2a33428d4bbc",
  2314. "grade": "智慧职教",
  2315. };
  2316. return obj
  2317. }
  2318.  
  2319. personResult(examId,taskId){
  2320. return new Promise((resolve,rejcet)=>{
  2321. $.ajax({
  2322. type: 'GET',
  2323. xhrFields: {
  2324. withCredentials: true //允许跨域发送cookies
  2325. },
  2326. headers: {
  2327. "Authorization":"Bearer "+this.getCookie("Token"),
  2328. },
  2329. url:"https://zyk.icve.com.cn/prod-api/teacher/taskExamProblemRecord/examRecordPaperList?examId="+examId+"&taskId="+taskId+"&groupId=0",
  2330. dataType:"json",
  2331. success: function(res) {
  2332. resolve(res);
  2333. }
  2334. });
  2335. });
  2336. }
  2337. join_class(){
  2338. return new Promise((resolve,rejcet)=>{
  2339. $.ajax({
  2340. type: 'GET',
  2341. xhrFields: {
  2342. withCredentials: true //允许跨域发送cookies
  2343. },
  2344. headers: {
  2345. "Authorization":"Bearer "+this.getCookie("Token"),
  2346. },
  2347. url:"https://zyk.icve.com.cn/prod-api/teacher/courseList/myCourseList?pageNum=1&pageSize=6&flag=1",
  2348. dataType:"json",
  2349. success: function(res) {
  2350. resolve(res);
  2351. }
  2352. });
  2353. });
  2354. }
  2355.  
  2356. get_Paper(recordId){
  2357. return new Promise((resolve,rejcet)=>{
  2358. $.ajax({
  2359. type: 'POST',
  2360. xhrFields: {
  2361. withCredentials: true //允许跨域发送cookies
  2362. },
  2363. // headers: {
  2364. // "Authorization":"Bearer "+this.getCookie("Token"),
  2365. // },
  2366. data:{
  2367. recordId:recordId,
  2368. },
  2369. url:"https://spoc-exam.icve.com.cn/student/exam/examrecord_getRecordPaperStructure.action",
  2370. dataType:"json",
  2371. success: function(res) {
  2372. resolve(res.data);
  2373. }
  2374. });
  2375. });
  2376. }
  2377. get_RecordContent(recordId,examBatchId,contentIds){
  2378. return new Promise((resolve,rejcet)=>{
  2379. $.ajax({
  2380. type: 'POST',
  2381. xhrFields: {
  2382. withCredentials: true //允许跨域发送cookies
  2383. },
  2384. data:{
  2385. recordId:recordId,
  2386. examBatchId:examBatchId,
  2387. contentIds:contentIds
  2388. },
  2389. url:"https://spoc-exam.icve.com.cn/student/exam/examrecord_getRecordContentByPage.action",
  2390. dataType:"json",
  2391. success: function(res) {
  2392. resolve(res.data);
  2393. }
  2394. });
  2395. });
  2396. }
  2397. reset_new_answer(data,ids){
  2398. let newData = {};
  2399. if(data ==null){
  2400. return console.log("并未获取到题库数据");
  2401. }
  2402. console.log("智慧职教题库重组中");
  2403. newData.rows = [];
  2404. ids.forEach(dex=>{
  2405. let _data = {};
  2406. if(!data[dex]){
  2407. return;
  2408. }
  2409. _data.id = dex;
  2410. let row = data[dex].contentHtml;
  2411. let imgs =null;
  2412. try{
  2413. imgs = $(row).find(".answerOption");
  2414. imgs.find('.exam_answers').remove()
  2415. _data.subject=imgs.find("span").text();
  2416. if(!imgs.length){
  2417. imgs = $(row).find(".divQuestionTitle"); // 去除特殊字符报错
  2418. imgs.find('[name="questionIndex"]').remove()
  2419. imgs.find('.q_score').remove()
  2420. _data.subject=imgs.text().slice(1);
  2421. }
  2422. }catch (e){
  2423. console.log(e);
  2424. }
  2425. if(imgs){
  2426. imgs.find("img").each(function(index,img){
  2427. if(img.localName == "img"){
  2428. _data.subject += img.outerHTML;
  2429. }
  2430. })
  2431. }
  2432. console.log(_data.subject)
  2433. // row.subject = row.subject.substr(0,500) //截断前500个字符
  2434. _data.options = [];
  2435. _data.answers = [];
  2436. let tmp_option = $(row).find(".q_option_readonly")
  2437. if($(row).find('[name="rightAnswer"]').length){ //选择官方正确答案
  2438. let indexs = $(row).find('[name="rightAnswer"]').text().split("")
  2439. tmp_option.each((_,option)=>{
  2440. if(option.outerText.slice(2)){ // 判断题过滤
  2441. _data.options.push(window.my.HtmlUtil.htmlDecode(option.outerText.slice(2)));
  2442. }else{
  2443. _data.options.push(window.my.HtmlUtil.htmlDecode(option.outerText));
  2444. }
  2445. indexs.forEach(index=>{
  2446. if(option.outerText[0] == index){
  2447. if(option.outerText.slice(2)){ // 判断题过滤
  2448. _data.answers.push(window.my.HtmlUtil.htmlDecode(option.outerText.slice(2)));
  2449. }else{
  2450. _data.answers.push(window.my.HtmlUtil.htmlDecode(option.outerText));
  2451. }
  2452. }
  2453. })
  2454. })
  2455. }else if($(row).find('.icon_examright').length){//自填写的正确答案
  2456. if($(row).find(".fillblank_answer").length){ //填空
  2457. $(row).find('.fillblank_answer').each((_,ans)=>{
  2458. if($(ans).find('.icon_examright').length){ //暂未验证,先去吃饭了。
  2459. _data.answers.push(window.my.HtmlUtil.htmlDecode(ans.outerText));
  2460. }
  2461. })
  2462. }else if($(row).find('[name="stuAnswer"]').length){
  2463. let indexs = $(row).find('[name="stuAnswer"]').text().split("")
  2464. tmp_option.each((_,option)=>{
  2465. if(option.outerText.slice(2)){ // 判断题过滤
  2466. _data.options.push(window.my.HtmlUtil.htmlDecode(option.outerText.slice(2)));
  2467. }else{
  2468. _data.options.push(window.my.HtmlUtil.htmlDecode(option.outerText));
  2469. }
  2470. indexs.forEach(index=>{
  2471. if(option.outerText[0] == index){
  2472. if(option.outerText.slice(2)){ // 判断题过滤
  2473. _data.answers.push(window.my.HtmlUtil.htmlDecode(option.outerText.slice(2)));
  2474. }else{
  2475. _data.answers.push(window.my.HtmlUtil.htmlDecode(option.outerText));
  2476. }
  2477. }
  2478. })
  2479. })
  2480. }else{
  2481. _data=null;
  2482. }
  2483. }else if($(row).find('.exam_rightAnswer').length){//填空正确
  2484. $(row).find(".exam_rightAnswer").find('.fillblank_answer').each((_,ans)=>{
  2485. _data.answers.push(window.my.HtmlUtil.htmlDecode(ans.outerText));
  2486. })
  2487. }
  2488. if(_data != null){
  2489. newData.rows.push(_data);
  2490. }
  2491. });
  2492. console.log(newData)
  2493. return newData;
  2494. }
  2495.  
  2496. async get_new_quiz_result(recordId){
  2497. let res = await (this.get_Paper(recordId));
  2498. var status = "error";
  2499. console.log(res)
  2500. let contentIds = ""
  2501. let ids = [];
  2502. res.contentList.forEach(row=>{
  2503. contentIds +=row.id+",";
  2504. ids.push(row.id)
  2505. })
  2506. let RecordContent = await this.get_RecordContent(recordId,res.examBatchId,contentIds)
  2507. let answers = this.reset_new_answer(RecordContent,ids);
  2508. answers.title = res.paperName
  2509. if(answers == null || JSON.stringify(answers) == '{}' ){
  2510. return status;
  2511. }
  2512. let obj={
  2513. "poolId": this.config.poolId,
  2514. "userId": this.config.tk_uid,
  2515. "tags":[answers.title,"new智慧职教"],
  2516. "title":"zhzj_"+res.paperId,
  2517. "problems":[],
  2518. };
  2519. let data={};
  2520. answers.rows.forEach(row=>{
  2521. if(row.subject.length < 4 || row.answers == ""){
  2522. console.log("题目录入有误");
  2523. return; //跳出循环
  2524. }
  2525. data={
  2526. "tags": ["智慧职教"],
  2527. "text": row.subject,
  2528. "answer": JSON.stringify(row.answers),
  2529. };
  2530. // data.tags.push(row.type);
  2531. let l = ["choice_A","choice_B","choice_C","choice_D","choice_E","choice_F","choice_G","choice_H","choice_I","choice_J","choice_K","choice_L","choice_M","choice_N","choice_O","choice_P","choice_Q","choice_R","choice_S","choice_T","choice_U","choice_V","choice_W","choice_X","choice_Y","choice_Z"];
  2532. let i=0;
  2533. row.options.forEach(option =>{
  2534. data[l[i]]=option;
  2535. i=i+1;
  2536. })
  2537. obj.problems.push(data);
  2538. });
  2539. if(obj.problems.length == 0){
  2540. return;
  2541. }
  2542. console.log(obj)
  2543. aner.css("display","block")
  2544. aner.text("因api被攻击暂不支持导入题库");
  2545. aner.append(`</br>如需请更新完整版</a>进行更多体验`)
  2546. return status;
  2547. }
  2548.  
  2549. async get_quiz_result(examId,taskId,courseId){
  2550. if(!classname){
  2551. let classListData = await (this.join_class());
  2552. if(!classListData){
  2553. return;
  2554. }
  2555. classListData.rows.forEach(course=>{
  2556. GM_setValue(course.courseId,course.courseName);//对应课名
  2557. })
  2558. var classname = GM_getValue("clazz_course_id")
  2559. if(!classname){
  2560. classname = courseId;
  2561. }
  2562. }
  2563. let res = await (this.personResult(examId,taskId));
  2564. var status = "error";
  2565. // if(res.result_code != 0){
  2566. // return alert(res.result_msg);
  2567. // }
  2568. let answers = this.reset_answer(res);
  2569. answers.title = GM_getValue(examId)||"未命名试卷"
  2570. if(answers == null || JSON.stringify(answers) == '{}' ){
  2571. return status;
  2572. }
  2573. let obj={
  2574. "poolId": this.config.poolId,
  2575. "userId": this.config.tk_uid,
  2576. "tags":[classname,answers.title,"智慧职教"],
  2577. "title":"zhzj_"+answers.id,
  2578. "problems":[],
  2579. };
  2580. let data={};
  2581. answers.rows.forEach(row=>{
  2582. if(row.subject.length < 4 || row.answers == ""){
  2583. console.log("题目录入有误");
  2584. return; //跳出循环
  2585. }
  2586. data={
  2587. "tags": ["智慧职教"],
  2588. "text": row.subject,
  2589. "answer": JSON.stringify(row.answers),
  2590. };
  2591. data.tags.push(row.type);
  2592. let l = ["choice_A","choice_B","choice_C","choice_D","choice_E","choice_F","choice_G","choice_H","choice_I","choice_J","choice_K","choice_L","choice_M","choice_N","choice_O","choice_P","choice_Q","choice_R","choice_S","choice_T","choice_U","choice_V","choice_W","choice_X","choice_Y","choice_Z"];
  2593. let i=0;
  2594. row.options.forEach(option =>{
  2595. data[l[i]]=option;
  2596. i=i+1;
  2597. })
  2598. obj.problems.push(data);
  2599. });
  2600. if(obj.problems.length == 0){
  2601. return;
  2602. }
  2603. aner.css("display","block")
  2604. aner.text("因api被攻击暂不支持导入题库");
  2605. aner.append(`</br>如需请更新完整版</a>进行更多体验`)
  2606. return status;
  2607. }
  2608.  
  2609. reset_answer(data){
  2610. let newData = {};
  2611. if(data ==null){
  2612. return console.log("并未获取到题库数据");
  2613. }
  2614. if("requestId" in data){
  2615. console.log("智慧职教题库重组中");
  2616. newData.id = data.data[0].examId;
  2617. newData.title = "暂无";
  2618. newData.rows = [];
  2619. data.data.forEach(row=>{
  2620. let _data = {};
  2621. _data.id = row.questionId;
  2622. let imgs =null;
  2623. try{
  2624. imgs = $.parseHTML(row.title); // 去除特殊字符报错
  2625. }catch (e){
  2626. console.log(e);
  2627. }
  2628. row.title=window.my.HtmlUtil.htmlDecode(row.title);
  2629. if(imgs){
  2630. imgs.forEach(async function(img,index){
  2631. if(img.localName == "img"){
  2632. row.title += img.outerHTML;
  2633. }
  2634. })
  2635. }
  2636. // row.subject = row.subject.substr(0,500) //截断前500个字符
  2637. _data.subject = row.title;
  2638. _data.options = [];
  2639. _data.answers = [];
  2640. _data.type = row.typeName;
  2641. let tmp_option = JSON.parse(row.dataJson)
  2642.  
  2643. if(row.answer){
  2644. tmp_option.forEach(option=>{
  2645. _data.options.push(window.my.HtmlUtil.htmlDecode(option.Content));
  2646. row.answer.split(",").forEach(index=>{
  2647. if(option.SortOrder == index){
  2648. _data.answers.push(window.my.HtmlUtil.htmlDecode(option.Content));
  2649. }
  2650. })
  2651. });
  2652. }else{
  2653. if(row.isRight == true){
  2654. tmp_option.forEach(option=>{
  2655. _data.options.push(window.my.HtmlUtil.htmlDecode(option.Content));
  2656. row.recordAnswer.split(",").forEach(index=>{
  2657. if(option.SortOrder == index){
  2658. _data.answers.push(window.my.HtmlUtil.htmlDecode(option.Content));
  2659. }
  2660. })
  2661. });
  2662. }else{
  2663. _data=null;
  2664. }
  2665. }
  2666. // }
  2667. if(_data != null){
  2668. newData.rows.push(_data);
  2669. }
  2670. });
  2671. }else{
  2672. console.log(data);
  2673. }
  2674. console.log(newData)
  2675. return newData;
  2676. }
  2677. get_page(courseId,courseInfoId){
  2678. return new Promise((resolve,rejcet)=>{
  2679. $.ajax({
  2680. type: 'GET',
  2681. xhrFields: {
  2682. withCredentials: true //允许跨域发送cookies
  2683. },
  2684. headers: {
  2685. "Authorization":"Bearer "+this.getCookie("Token"),
  2686. },
  2687. url:"https://zyk.icve.com.cn/prod-api/teacher/homeworkExam/answeredExamList?pageNum=1&pageSize=10&categoryId=1&flag=1&courseInfoId="+courseInfoId+"&courseId="+courseId,
  2688. dataType:"json",
  2689. success: function(res) {
  2690. resolve(res);
  2691. }
  2692. });
  2693. });
  2694. }
  2695. async upload_all_problem(show_aner){
  2696. let classListData = await (this.join_class());
  2697. if(!classListData){
  2698. return;
  2699. }
  2700. classListData.rows.forEach(course=>{
  2701. GM_setValue(course.courseId,course.courseName);//对应课名
  2702. })
  2703. this.config.class_size = 0
  2704. this.config.class_length = 0
  2705. if(show_aner){
  2706. aner.text("欢迎您的第一次使用,正在为您聚合数据中,请稍后。。。。");
  2707. aner.css("display","block")
  2708. }
  2709. for(let i=0;i<classListData.rows.length;i++){
  2710. let cl = classListData.rows[i];
  2711. this.get_page(cl.courseId,cl.courseInfoId).then((result) =>{
  2712. result.rows.forEach(async (item)=>{
  2713. if(!GM_getValue(item.id)){
  2714. GM_setValue(item.id,item.name)
  2715. this.config.class_length++;
  2716. this.config.class_size++;
  2717. try{
  2718. await(this.get_quiz_result(item.id,item.taskId,cl.courseId));
  2719. console.log(item.id+"upload成功")
  2720. }catch{
  2721. console.log(item.id+"upload失败")
  2722. }
  2723. this.config.class_size--;
  2724. if(show_aner){
  2725. aner.text("百分比长时间未动请刷新页面\n已加载:"+Math.trunc((1-(this.config.class_size/this.config.class_length))*100)+"%");
  2726. }
  2727. }
  2728. })
  2729.  
  2730. });
  2731. }
  2732. }
  2733. async start_search(){ //智慧职教搜题按钮实现
  2734. const sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
  2735. function random(min, max) {
  2736. return Math.floor(Math.random() * (max - min)) + min;
  2737. }
  2738. let HtmlUtil = window.my.HtmlUtil;
  2739. aner.css("display","block")
  2740. aner.text("正在搜索中,请稍后")
  2741. let upload_paper_flag = false;
  2742. let answers = await(window.my.getAnswers("zhzj_"+this.config.id,true));
  2743. if((answers == null)||JSON.stringify(answers) == '{}' || answers.rows.length <= 0){
  2744. let subjects = []
  2745. $('.subjectDet').each(function(index,div){
  2746. let subjct_div = $(div).find('h5');
  2747. let subject = $(subjct_div).text().trim();
  2748. let imgs = $(subjct_div).find("img");
  2749. subject=HtmlUtil.htmlDecode(subject);
  2750. imgs.each(async function(index,img){
  2751. if(img.outerHTML){
  2752. subject += img.outerHTML;
  2753. }
  2754. })
  2755. if(subject != ""){
  2756. subjects.push(subject);
  2757. }
  2758. })
  2759. answers = await(window.my.findproblems(subjects));
  2760. upload_paper_flag = true
  2761. }
  2762. if(JSON.stringify(answers) == '{}' || !(answers.rows)){
  2763. aner.text("没有搜索到答案,若提前阅卷时有答案,但此时没有请反馈")
  2764. }else{
  2765. aner.text("总共搜索到"+answers.rows.length+"题")
  2766. answers.rows.forEach(row=>{
  2767. aner.append("<hr>");
  2768. aner.append("题目:"+row.subject+"<br>"+"答案:");
  2769. row.answers.forEach(answer =>{
  2770. aner.append(answer+" ");
  2771. });
  2772. });
  2773. }
  2774. let divs = $('.subjectDet');
  2775. for(let i=0;i<divs.length;i++){
  2776. let div = divs[i];
  2777. // let Id = $(div).find('a').attr('name');
  2778. //console.log($(div).find('.t-subject.t-item.moso-text.moso-editor').html());
  2779. let subjct_div = $(div).find('h5');
  2780. let subject = $(subjct_div).text().trim();
  2781. let imgs = $(subjct_div).find("img");
  2782. subject=HtmlUtil.htmlDecode(subject);
  2783. imgs.each(async function(index,img){
  2784. if(img.outerHTML){
  2785. subject += img.outerHTML;
  2786. }
  2787. })
  2788. if( $(div).find('.show_answer').length == 0){ //添加文字答案
  2789. $(div).append("<div class='show_answer'></div>")
  2790. }
  2791. answers.rows.forEach((row,index)=>{
  2792. if(row.subject == subject){
  2793. if(!$(div).find('.show_answer')[0].outerText){
  2794. $(div).find('.show_answer').append("答案:"+JSON.stringify(row.answers)+"<br>").css('color','red'); // 添加答案在后方
  2795. }else{
  2796. $(div).append("第"+(i+1)+"题重复<br>").css('color','blue');
  2797. $(div).find('.show_answer').append("答案:"+JSON.stringify(row.answers)+"<br>").css('color','red'); // 添加答案在后方
  2798. }
  2799. }
  2800. });
  2801. let $options = $(div).find(".el-checkbox");
  2802. if($options.length == 0){
  2803. $options = $(div).find('.el-radio');
  2804. }
  2805. for(let index = 0;index<answers.rows.length;index++){
  2806. let row = answers.rows[index];
  2807. if(row.subject != subject){
  2808. continue;
  2809. }
  2810. if("checked" in answers.rows[index]&& answers.rows[index].checked == answers.rows[index].answers.length){
  2811. continue
  2812. }
  2813. answers.rows[index].checked = 0;
  2814. for(let i = 0;i < $options.length;i++){
  2815. let label = $options[i];
  2816. let content = $(label).find(".ql-editor").text()||$(label).find(".el-radio__label").text()||$(label).find(".el-checkbox__label").text();//单多选题答案获取
  2817. let content_split = content.trim().substr(2);
  2818. for(let j=0;j<row.answers.length;j++){
  2819. let answer = row.answers[j];
  2820. try{
  2821. if(content == answer || content_split == answer){
  2822. if ($(label).find(".is-checked").length) {
  2823. answers.rows[index].checked +=1;
  2824. // aner.text("答案重复,请注意分辨答案。题目:"+subject);
  2825. continue;
  2826. }
  2827. $(label).css('color','red');
  2828. $(label).click();
  2829. answers.rows[index].checked +=1;
  2830. await sleep(random(100,200));
  2831. break;
  2832. }
  2833. }catch (e){
  2834. console.log("发生异常:" + e);
  2835. }
  2836. }
  2837. }
  2838. };
  2839. await sleep(random(500,1000));
  2840. }; //结束
  2841. answers.rows.forEach((row,index)=>{
  2842. if(row.checked < row.answers.length){
  2843. delete answers.rows[index];
  2844. return;
  2845. }
  2846. for(let q =index+1;q<answers.rows.length;q++){
  2847. let row1 = answers.rows[q];
  2848. if(row.subject == row1.subject){
  2849. let tmp = window.my.compareArr(row.answers,row1.answers);
  2850. if(tmp == "disjoint"){
  2851. return;
  2852. }else if(tmp == "equal"){
  2853. console.log(row.answers);
  2854. console.log(row1.answers);
  2855. delete answers.rows[index];
  2856. return;
  2857. }else if(tmp == "subset"){
  2858. delete answers.rows[index];
  2859. return;
  2860. }else if(tmp == "superset"){
  2861. delete answers.rows[q];
  2862. return;
  2863. }else if(tmp == "mix"){
  2864. return;
  2865. }else{
  2866. console.log("未知"+tmp)
  2867. }
  2868. }
  2869. }
  2870. });
  2871. if(upload_paper_flag){
  2872. window.my.upload_papers(answers,"zhzj_"+this.config.id,"智慧职教");
  2873. }
  2874. // alert('alv');
  2875. this.upload_all_problem(false)
  2876. //题库获取模块 end
  2877. }
  2878. }
  2879. /*
  2880. * 智慧树请求
  2881. */
  2882. class zhihuishu_api{
  2883. constructor(config) {
  2884. this.config = config;
  2885. alert("由于智慧树官方代码被混淆加密,暂不公开源代码,\n需要使用该功能请访问https://metost.com/获取");
  2886. window.open("https://metost.com/docs/download");
  2887. }
  2888. }
  2889. /*
  2890. * 精品云班课请求
  2891. */
  2892. class jpyunbanke_api {
  2893. constructor(config) {
  2894. this.config = config;
  2895. }
  2896. async init_button(){
  2897. if(this.config.c === "res"||this.config.front_url[this.config.front_url.length-1] === "course-learning"){
  2898. if(GM_getValue("resource_farming_main_state")){
  2899. div_zhu.append("<button onclick='GM_setValue(\"resource_farming_main_state\",false);location.reload()'><span>停止翻页</span></button>");
  2900. this.choice_function()
  2901. aner.show("hide")
  2902. aner.text("手动切换课程后请刷新页面")
  2903. }else{
  2904. div_zhu.append("<button onclick='GM_setValue(\"resource_farming_main_state\",true);location.reload()'><span>自动翻页</span></button>");
  2905. }
  2906. // div_zhu.append("<button id='x_res' ><span>一键完成资源</span></button>");// 已失效
  2907. }else{
  2908. div_zhu.append("<button onclick='window.open(\"https://d.metost.com\");'><span>MeTo题库</span></button>");
  2909. }
  2910. }
  2911.  
  2912. sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
  2913.  
  2914. async choice_function(){
  2915. let oid = await this.resource_farming()
  2916.  
  2917. for(let i=10;i;i--){
  2918. await this.sleep(1000)
  2919. console.log("开始检测页面内容"+i)
  2920. let video
  2921. video = $("video")[0]
  2922. if(video){
  2923. console.log("视频加载")
  2924. video.muted = true;
  2925. while(1){
  2926. if(video.ended){
  2927. console.log("播放结束")
  2928. window.location.href = "https://mooc.mosoteach.cn/course-study/"+this.config.front_url[4]+"/"+this.config.front_url[5]+"/course-learning?currentOid="+oid[1]
  2929. this.choice_function() //再次循环
  2930. break;
  2931. }
  2932. // $(".playButton").click()
  2933. video.play()
  2934. // let mi = video.duration - video.currentTime
  2935. // console.log(mi)
  2936. await this.sleep(1000)
  2937. }
  2938. break;
  2939. }
  2940. }
  2941. window.location.href = "https://mooc.mosoteach.cn/course-study/"+this.config.front_url[4]+"/"+this.config.front_url[5]+"/course-learning?currentOid="+oid[1]
  2942.  
  2943. }
  2944.  
  2945. getNewProject(){
  2946. let user_inf = JSON.parse(localStorage.getItem("_user"))
  2947. let online_courses = this.config.front_url[4];
  2948. let plans = this.config.front_url[5];
  2949. return new Promise((resolve,rejcet)=>{
  2950. $.ajax({
  2951. type: 'get',
  2952. url:"https://coreapi-proxy.mosoteach.cn/index.php/online-courses/"+online_courses+"/plans/"+plans+"/members/"+user_inf.userId,
  2953. dataType:"json",
  2954. headers: {
  2955. "X-Token":localStorage.getItem("_token"),
  2956. },
  2957. success: function(res) {
  2958. resolve(res.member.chapters);
  2959. }
  2960. });
  2961. });
  2962. }
  2963. async resource_farming(){
  2964. const sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
  2965. let project_obj = await(this.getNewProject())
  2966. let project_oid = []
  2967. project_obj.forEach((item)=>{
  2968. item.sections.forEach((item)=>{
  2969. item.entities.forEach((item)=>{
  2970. if(item.gainedScore == -1){
  2971. project_oid.push(item.oid)
  2972. }
  2973. })
  2974. })
  2975. })
  2976. return project_oid
  2977. // let len = project_oid.length
  2978. // for(let i = 0;i< len;i++){
  2979. // let result = await(this.post_read_project(project_oid[i]))
  2980. // console.log(result)
  2981. // if (len - i - 1 != 0) {
  2982. // $(shadowContent.querySelector("#x_res")).text("剩下" + (len - i - 1) + "个")
  2983. // }else {
  2984. // $(shadowContent.querySelector("#x_res")).text("全部完成")
  2985. // location.reload()
  2986. // return 0
  2987. // }
  2988. // await sleep(1000);
  2989. // }
  2990. }
  2991. post_read_project(oid){
  2992. let online_courses = this.config.front_url[4];
  2993. let plans = this.config.front_url[5];
  2994. return new Promise((resolve,rejcet)=>{
  2995. $.ajax({
  2996. type: 'post',
  2997. url:"https://coreapi-proxy.mosoteach.cn/index.php/online-courses/"+online_courses+"/plans/"+plans+"/resources/"+oid+"/read",
  2998. dataType:"json",
  2999. headers: {
  3000. "X-Token":localStorage.getItem("_token"),
  3001. },
  3002. success: function(res) {
  3003. resolve(res);
  3004. }
  3005. });
  3006. });
  3007. }
  3008. async get_user_inf(){
  3009. return new Promise((resolve,rejcet)=>{
  3010. $.ajax({
  3011. type: 'get',
  3012. url:"https://coreapi-proxy.mosoteach.cn/index.php/users/my-profile",
  3013. dataType:"json",
  3014. headers: {
  3015. "X-Token":localStorage.getItem("_token"),
  3016. },
  3017. success: function(res) {
  3018. resolve(res.user);
  3019. }
  3020. });
  3021. });
  3022. }
  3023.  
  3024. }
  3025.  
  3026. /*
  3027. * 云班课请求
  3028. */
  3029. class yunbanke_api {
  3030. constructor(config) {
  3031. this.config = config;
  3032. }
  3033. async init_button(){
  3034. if(this.config.m === "reply"){ //
  3035. // this.Listener();
  3036. div_zhu.append("<button id='x_start' ><span>开始搜题</span></button>");
  3037. // document.getElementById("zhu")
  3038. }else if(this.config.c === "res"||this.config.front_url[this.config.front_url.length-1] === "course-learning"){
  3039. div_zhu.append("<button id='x_res' ><span>一键完成资源</span></button>");
  3040. }else if(this.config.m === "quiz_ranking" || this.config.m === "start_quiz_confirm"){
  3041. div_zhu.append("<button id='x_yue' ><span>提前阅卷</span></button>");
  3042. }else if(this.config.m === "person_quiz_result"||this.config.m ==="view"){
  3043. // div_zhu.append("<button id='x_start' ><span>开始搜题</span></button>");
  3044. div_zhu.append("<button id='x_recall' ><span>背题模式</span></button>");
  3045. div_zhu.append("<button id='x_error_problems' ><span>错题集</span></button>");
  3046. aner.css("display","block")
  3047. aner.text("正在导入题库中");
  3048. if(!GM_getValue(this.config.id)){
  3049. let flag = await(this.get_quiz_result(this.config.id,this.config.user_id,this.config.clazz_course_id));
  3050.  
  3051. }else{
  3052. aner.text("题库已存在");
  3053. }
  3054. }else{
  3055. div_zhu.append("<button onclick='window.open(\"https://d.metost.com\");'><span>MeTo题库</span></button>");
  3056. }
  3057. }
  3058. getListMember(clazzcourseId){
  3059. return new Promise((resolve,rejcet)=>{
  3060. $.ajax({
  3061. type: 'post',
  3062. url:"https://www.mosoteach.cn/web/index.php?c=member&m=get_list_member",
  3063. dataType:"json",
  3064. data: {
  3065. clazz_course_id: clazzcourseId,
  3066. order_item: 'score'
  3067. },
  3068. success: function(res) {
  3069. resolve(res.data.member_data);
  3070. }
  3071. });
  3072. });
  3073. }
  3074.  
  3075. personResult(id,userId,ccId){
  3076. return new Promise((resolve,rejcet)=>{
  3077. $.ajax({
  3078. type: 'post',
  3079. url:"https://www.mosoteach.cn/web/index.php?c=interaction_quiz&m=person_result",
  3080. dataType:"json",
  3081. data: {
  3082. id: id,
  3083. user_id: userId,
  3084. cc_id: ccId,
  3085. },
  3086. success: function(res) {
  3087. resolve(res);
  3088. }
  3089. });
  3090. });
  3091. }
  3092. join_class(){
  3093. return new Promise((resolve,rejcet)=>{
  3094. $.ajax({
  3095. type: 'post',
  3096. url:"https://www.mosoteach.cn/web/index.php?c=clazzcourse&m=my_joined",
  3097. dataType:"json",
  3098. success: function(res) {
  3099. resolve(res.data);
  3100. }
  3101. });
  3102. });
  3103. }
  3104. get_page(class_id){
  3105. return new Promise((resolve,rejcet)=>{
  3106. $.ajax({
  3107. type: 'post',
  3108. url:"https://www.mosoteach.cn/web/index.php?c=interaction&m=index&clazz_course_id="+class_id,
  3109. success: function(res) {
  3110. resolve(res);
  3111. }
  3112. });
  3113. });
  3114. }
  3115. get_page_status(id,ccId){
  3116. return new Promise((resolve,rejcet)=>{
  3117. $.ajax({
  3118. type: 'post',
  3119. url:"https://www.mosoteach.cn/web/index.php?c=interaction_quiz&m=get_quiz_ranking",
  3120. dataType:"json",
  3121. data: {
  3122. id: id,
  3123. ccId: ccId,
  3124. },
  3125. success: function(res) {
  3126. resolve(res);
  3127. }
  3128. });
  3129. });
  3130. }
  3131.  
  3132. async get_user_obj(){
  3133. let classListData = await (this.join_class());
  3134. if(!classListData){
  3135. return console.log("未登录(不可用)账户");
  3136. }
  3137. classListData.forEach(ccid=>{
  3138. GM_setValue(ccid.id,ccid.course.name);//对应课名
  3139. // console.log(ccid);
  3140. })
  3141. if(classListData.length == 0){
  3142. return console.log("未登录(不可用)账户");
  3143. }
  3144. let {data:objectList} = await (this.getListMember(classListData[0].id));
  3145. if(objectList.length <= 0 ){
  3146. return alert("初始化脚本失败");
  3147. }
  3148. GM_setValue("userimg",objectList[0].full_avatar_url);
  3149. GM_setValue("user_id",objectList[0].user_id);
  3150. let img_table = $(shadowContent.querySelector("#x_set"))
  3151. img_table.css("background","url(" + objectList[0].full_avatar_url + ")")
  3152. this.config.user_id = objectList[0].user_id;
  3153. this.config.user_list = objectList;
  3154. // console.log(this.config.user_list)
  3155. this.config.full_name = objectList[0].full_name;
  3156. this.config.clazz_course_id = classListData[0].id
  3157. let obj={
  3158. "unionid": objectList[0].user_id,
  3159. "username": objectList[0].full_name,
  3160. "poolId":"ec942b0b-38c6-3256-b0e1-2a33428d4bbc",
  3161. "grade": "云班课",
  3162. };
  3163. return obj
  3164. }
  3165.  
  3166. async upload_all_problem(show_aner){
  3167. let classListData = await (this.join_class());
  3168. if(!classListData){
  3169. return;
  3170. }
  3171. classListData.forEach(ccid=>{
  3172. GM_setValue(ccid.id,ccid.course.name);//对应课名
  3173. // console.log(ccid);
  3174. })
  3175. this.config.class_size = 0
  3176. this.config.class_length = 0
  3177. if(show_aner){
  3178. aner.text("欢迎您的第一次使用,正在为您聚合数据中,请稍后。。。。");
  3179. aner.css("display","block")
  3180. }
  3181. for(let i=0;i<classListData.length;i++){
  3182. let cl = classListData[i];
  3183. this.get_page(cl.id).then((result) =>{
  3184. $(result).find(".interaction-row").each(async (index,div)=>{
  3185. let id = $(div).attr('data-id');
  3186. let type = $(div).attr('data-type');
  3187. let status = $(div).attr('data-row-status');
  3188. if(type=="QUIZ"){
  3189. if(!GM_getValue(id)){
  3190. this.config.class_length++;
  3191. this.config.class_size++;
  3192. try{
  3193. await(this.get_quiz_result(id,this.config.user_id,cl.id));
  3194. console.log(id+"upload成功")
  3195. }catch{
  3196. console.log(id+"upload失败")
  3197. }
  3198. this.config.class_size--;
  3199. if(show_aner){
  3200. aner.text("百分比长时间未动请刷新页面\n已加载:"+Math.trunc((1-(this.config.class_size/this.config.class_length))*100)+"%");
  3201. }
  3202. }
  3203. }
  3204. })
  3205.  
  3206. });
  3207. }
  3208. }
  3209.  
  3210. async get_quiz_result(id,user_id,clazz_course_id){
  3211. var classname = GM_getValue(clazz_course_id)
  3212. if(!classname){
  3213. let classListData = await (this.join_class());
  3214. if(!classListData){
  3215. return;
  3216. }
  3217. classListData.forEach(ccid=>{
  3218. GM_setValue(ccid.id,ccid.course.name);//对应课名
  3219. // console.log(ccid);
  3220. })
  3221. var classname = GM_getValue(clazz_course_id)
  3222. if(!classname){
  3223. classname = "未命名课程";
  3224. }
  3225. }
  3226. let res = await (this.personResult(id,user_id,clazz_course_id));
  3227. var status = "error";
  3228. // if(res.result_code != 0){
  3229. // return alert(res.result_msg);
  3230. // }
  3231. let answers = this.reset_answer(res);
  3232. if(answers == null || JSON.stringify(answers) == '{}' ){
  3233. return status;
  3234. }
  3235. let obj={
  3236. "poolId": this.config.poolId,
  3237. "userId": this.config.tk_uid,
  3238. "tags":[classname,answers.title,"云班课"],
  3239. "title":answers.id,
  3240. "problems":[],
  3241. };
  3242. let data={};
  3243. answers.rows.forEach(row=>{
  3244. if(row.subject.length < 4 || row.answers == ""){
  3245. console.log("题目录入有误");
  3246. return; //跳出循环
  3247. }
  3248. data={
  3249. "tags": ["云班课"],
  3250. "text": row.subject,
  3251. "answer": JSON.stringify(row.answers),
  3252. };
  3253. data.tags.push(row.type);
  3254. let l = ["choice_A","choice_B","choice_C","choice_D","choice_E","choice_F","choice_G","choice_H","choice_I","choice_J","choice_K","choice_L","choice_M","choice_N","choice_O","choice_P","choice_Q","choice_R","choice_S","choice_T","choice_U","choice_V","choice_W","choice_X","choice_Y","choice_Z"];
  3255. let i=0;
  3256. row.options.forEach(option =>{
  3257. data[l[i]]=option;
  3258. i=i+1;
  3259. })
  3260. obj.problems.push(data);
  3261. });
  3262. if(obj.problems.length == 0){
  3263. return;
  3264. }
  3265. aner.css("display","block")
  3266. aner.text("因api被攻击暂不支持导入题库");
  3267. aner.append(`</br>如需请更新完整版</a>进行更多体验`)
  3268. return status;
  3269. }
  3270.  
  3271. reset_answer(data){
  3272. let newData = {};
  3273. if(data ==null){
  3274. return console.log("并未获取到题库数据");
  3275. }
  3276. if("activity" in data){
  3277. console.log("蓝墨云题库重组中");
  3278. newData.id = data.activity.id;
  3279. newData.title = data.activity.title;
  3280. newData.rows = [];
  3281. data.activity.topics.forEach(row=>{
  3282. let _data = {};
  3283. _data.id = row.topic_id;
  3284. let imgs =null;
  3285. try{
  3286. imgs = $.parseHTML(row.subject); // 去除特殊字符报错
  3287. }catch (e){
  3288. console.log(e);
  3289. }
  3290. row.subject=window.my.HtmlUtil.htmlDecode(row.subject);
  3291. if(imgs){
  3292. imgs.forEach(async function(img,index){
  3293. if(img.localName == "img"){
  3294. row.subject += img.outerHTML;
  3295. }
  3296. })
  3297. }
  3298. // row.subject = row.subject.substr(0,500) //截断前500个字符
  3299. _data.subject = row.subject;
  3300. _data.options = [];
  3301. _data.answers = [];
  3302. _data.type = row.type;
  3303. if(row.type == "TF"){
  3304. if(row.tf_answer!=null){
  3305. _data.answers.push(row.tf_answer);
  3306. }else{
  3307. if(row.result == 1){
  3308. _data.answers.push(row.user_tf_answer)
  3309. }else{
  3310. _data=null;
  3311. }
  3312. }
  3313. }else if(row.type == "FILL"){
  3314. row.fill.blank_alternatives.forEach(answer=>{
  3315. if(answer.contents[0] !=null){
  3316. _data.answers.push(answer.contents);
  3317. }else{
  3318. if(answer.result ==1){
  3319. _data.answers.push(answer.user_content)
  3320. }else{
  3321. _data=null;
  3322. }
  3323. }
  3324. });
  3325. }else{
  3326. if(row.answers.length != 0){
  3327. row.options.forEach(option=>{
  3328. _data.options.push(window.my.HtmlUtil.htmlDecode(option.content));
  3329. row.answers.forEach(index =>{
  3330. if(option.item_no == index){
  3331. _data.answers.push(window.my.HtmlUtil.htmlDecode(option.content));
  3332. }
  3333. });
  3334. });
  3335. }else{
  3336. if(row.result == 1){
  3337. row.options.forEach(option=>{
  3338. _data.options.push(window.my.HtmlUtil.htmlDecode(option.content));
  3339. row.user_answers.forEach(index =>{
  3340. if(option.item_no == index){
  3341. _data.answers.push(window.my.HtmlUtil.htmlDecode(option.content));
  3342. }
  3343. });
  3344. });
  3345. }else{
  3346. _data=null;
  3347. }
  3348. }
  3349. }
  3350. if(_data != null){
  3351. newData.rows.push(_data);
  3352. }
  3353. });
  3354. }else{
  3355. console.log(data);
  3356. }
  3357. return newData;
  3358. }
  3359. async main_resource(reslist){
  3360. var watch = reslist[0]
  3361. var req = {}
  3362. if (reslist.length != 0) {
  3363. $(shadowContent.querySelector("#x_res")).text("剩下" + reslist.length + "个")
  3364. } else {
  3365. $(shadowContent.querySelector("#x_res")).text("全部完成")
  3366. location.reload()
  3367. return 0
  3368. }
  3369. var clazz_course_id = this.config.clazz_course_id
  3370. $.ajax({
  3371. type: "POST",
  3372. url: "https://www.mosoteach.cn/web/index.php?c=res&m=request_url_for_json",
  3373. data: {
  3374. 'file_id': watch.id,
  3375. 'type': 'VIEW',
  3376. 'clazz_course_id': clazz_course_id,
  3377. },
  3378. dataType: "json",
  3379. success: msg => {
  3380. const src = msg.src
  3381. if (src.indexOf("m3u8") > -1) {
  3382. fetch(src)
  3383. .then(data => data.text())
  3384. .then(text => {
  3385. let time = 0
  3386. for (i of text.split("\n")) {
  3387. if (i.indexOf("#EXTINF:") > -1) {
  3388. i = parseFloat(i.replace("#EXTINF:", ""))
  3389. time += i
  3390. }
  3391. }
  3392. time = Math.ceil(time)
  3393. $.ajax({
  3394. type: 'post',
  3395. dataType: 'json',
  3396. url: 'https://www.mosoteach.cn/web/index.php?c=res&m=save_watch_to',
  3397. data: {
  3398. clazz_course_id: clazz_course_id,
  3399. res_id: watch.id,
  3400. watch_to: time,
  3401. duration: time,
  3402. current_watch_to: time
  3403. },
  3404. success: res => {
  3405. reslist.splice(0, 1)
  3406. this.main_resource(reslist)
  3407. }
  3408. });
  3409. })
  3410. } else {
  3411. reslist.splice(0, 1)
  3412. this.main_resource(reslist)
  3413. }
  3414. }
  3415. })
  3416. }
  3417. resource_farming(reslist){
  3418. var reslist = []
  3419. $(".res-row-open-enable").each(function() {
  3420. if ($(this).find('span[data-is-drag]')[0].dataset.isDrag == "N") {
  3421. reslist.push({
  3422. id: $(this).attr('data-value'),
  3423. state: $(this).find('span[data-is-drag]')[0].dataset.isDrag,
  3424. type: $(this).attr('data-mime')
  3425. })
  3426. }
  3427. });
  3428. this.main_resource(reslist)
  3429. }
  3430. async start_search(){ //搜题按钮实现
  3431. const sleep = (delay) => new Promise((resolve) => setTimeout(resolve, delay))
  3432. function random(min, max) {
  3433. return Math.floor(Math.random() * (max - min)) + min;
  3434. }
  3435. let HtmlUtil = window.my.HtmlUtil;
  3436. aner.css("display","block")
  3437. aner.text("正在搜索中,请稍后")
  3438. let upload_paper_flag = false;
  3439. let answers = await(window.my.getAnswers(this.config.id,true));
  3440. if(this.config.tk_uid == null || (answers == null)||JSON.stringify(answers) == '{}' || answers.rows.length <= 0){
  3441. let subjects = []
  3442. $('.topic-item').each(function(index,div){
  3443. let Id = $(div).find('a').attr('name');
  3444. let subject = $(div).find('.t-subject.t-item.moso-text.moso-editor').text().trim();
  3445. let imgs = $(div).find("img");
  3446. // console.log(imgs)
  3447. subject = HtmlUtil.htmlDecode(subject);
  3448. imgs.each(async function(index,img){
  3449. if(img.outerHTML){
  3450. subject += img.outerHTML;
  3451. }
  3452. })
  3453. if(subject != ""){
  3454. subjects.push(subject);
  3455. }
  3456. })
  3457. answers = await(window.my.findproblems(subjects));
  3458. upload_paper_flag = true
  3459. }
  3460. if(JSON.stringify(answers) == '{}' || !(answers.rows)){
  3461. aner.text("没有搜索到答案,若提前阅卷时有答案,但此时没有请反馈")
  3462. }else{
  3463. aner.text("总共搜索到"+answers.rows.length+"题")
  3464. answers.rows.forEach(row=>{
  3465. aner.append("<hr>");
  3466. aner.append("题目:"+row.subject+"<br>"+"答案:");
  3467. row.answers.forEach(answer =>{
  3468. aner.append(answer+" ");
  3469. });
  3470. });
  3471. }
  3472. window.my.config.timenum = answers.rows.length * 4 * (GM_getValue("is_wait") ? 0:1)
  3473. $(".my-sticky-bottom").children("button:first").attr('id', 'submit')
  3474. window.my.config.timer = setInterval(function() {
  3475. window.my.config.timenum--
  3476. if (window.my.config.timenum < 0) {
  3477. $("#submit").text("交卷")
  3478. $("#submit").attr("style", "")
  3479. $("#submit").attr('disabled', false)
  3480. clearInterval(window.my.config.timer)
  3481. } else {
  3482. $("#submit").attr('disabled', true)
  3483. $(shadowContent.querySelector("#x_start")).attr('disabled', true)
  3484. $("#submit").attr("style", "width:250px")
  3485. $("#submit").text("请在" +window.my.config.timenum +"秒后交卷")
  3486. }
  3487. }, 1000)
  3488. // $('.topic-item').each(function(index,div){ // 如果是这个后面记得加括号
  3489. let divs = $('.topic-item');
  3490. for(let i=0;i<divs.length;i++){
  3491. let div = divs[i];
  3492. let Id = $(div).find('a').attr('name');
  3493. let flag_FT = false
  3494. //console.log($(div).find('.t-subject.t-item.moso-text.moso-editor').html());
  3495. let subject = $(div).find('.t-subject.t-item.moso-text.moso-editor').text();
  3496. let imgs = $(div).find("img");
  3497. subject=HtmlUtil.htmlDecode(subject);
  3498. imgs.each(async function(index,img){
  3499. if(img.outerHTML){
  3500. subject += img.outerHTML;
  3501. }
  3502. })
  3503. // subject = subject.substr(0,500);
  3504. // console.log(subject);
  3505. // subject=escapeto(subject);
  3506. //let space = new RegExp(`${String.fromCharCode(160)}`,"g"); /* no breaking space*/
  3507. // console.log(subject);
  3508. if( $(div).find('.show_answer').length == 0){
  3509. $(div).find('.t-con').append("<div class='show_answer'></div>")
  3510. }
  3511. answers.rows.forEach((row,index)=>{
  3512. if(row.subject == subject){
  3513. if(!$(div).find('.show_answer')[0].outerText){
  3514. $(div).find('.show_answer').append("答案:"+JSON.stringify(row.answers)+"<br>").css('color','red'); // 添加答案在后方
  3515. }else{
  3516. $(div).append("第"+(i+1)+"题重复<br>").css('color','blue');
  3517. $(div).find('.show_answer').append("答案:"+JSON.stringify(row.answers)+"<br>").css('color','red'); // 添加答案在后方
  3518. }
  3519. }
  3520. });
  3521. let $options = $(div).find('label');
  3522. if($options.length == 0){
  3523. $options = $(div).find('input');
  3524. }
  3525. for(let index = 0;index<answers.rows.length;index++){
  3526. let row = answers.rows[index];
  3527. if(row.subject != subject){
  3528. continue;
  3529. }
  3530. if("checked" in answers.rows[index]&& answers.rows[index].checked == answers.rows[index].answers.length){
  3531. continue
  3532. }
  3533. answers.rows[index].checked = 0;
  3534. for(let i = 0;i < $options.length;i++){
  3535. let label = $options[i];
  3536. let content = $(label).find('.option-content.moso-text.moso-editor').text();//单多选题答案获取
  3537. if(content == ""){
  3538. content = $(label).find('.el-radio__label').text();//判断题答案获取
  3539. flag_FT = true
  3540. }
  3541. if(content == ""){
  3542. //填空题
  3543. if(Array.isArray(row.answers[i])){
  3544. $(label).val(row.answers[i][0]);
  3545. answers.rows[index].checked +=1;
  3546. }else{
  3547. $(label).val(row.answers[i]);
  3548. answers.rows[index].checked +=1;
  3549. }
  3550. let ev = document.createEvent("HTMLEvents");
  3551. ev.initEvent("input", true, true);
  3552. $(label)[0].dispatchEvent(ev);
  3553. }
  3554. for(let j=0;j<row.answers.length;j++){
  3555. let answer = row.answers[j];
  3556. if(flag_FT == true){
  3557. if (answer == "T"){
  3558. answer = "正确"
  3559. }else if(answer == "F"){
  3560. answer = "错误"
  3561. }
  3562. }
  3563. try{
  3564. if(content == answer){
  3565. if ($(label).find(".is-checked").length) {
  3566. answers.rows[index].checked +=1;
  3567. // aner.text("答案重复,请注意分辨答案。题目:"+subject);
  3568. continue;
  3569. }
  3570. $(label).css('color','red');
  3571. $(label).click();
  3572. answers.rows[index].checked +=1;
  3573. await sleep(random(100,200));
  3574. break;
  3575. }
  3576. }catch (e){
  3577. console.log("发生异常:" + e);
  3578. }
  3579. }
  3580. }
  3581. };
  3582. await sleep(random(500,1000));
  3583. }; //结束
  3584. answers.rows.forEach((row,index)=>{
  3585. if(row.checked < row.answers.length){
  3586. delete answers.rows[index];
  3587. return;
  3588. }
  3589. for(let q =index+1;q<answers.rows.length;q++){
  3590. let row1 = answers.rows[q];
  3591. if(row.subject == row1.subject){
  3592. let tmp = window.my.compareArr(row.answers,row1.answers);
  3593. if(tmp == "disjoint"){
  3594. return;
  3595. }else if(tmp == "equal"){
  3596. console.log(row.answers);
  3597. console.log(row1.answers);
  3598. delete answers.rows[index];
  3599. return;
  3600. }else if(tmp == "subset"){
  3601. delete answers.rows[index];
  3602. return;
  3603. }else if(tmp == "superset"){
  3604. delete answers.rows[q];
  3605. return;
  3606. }else if(tmp == "mix"){
  3607. return;
  3608. }else{
  3609. console.log("未知"+tmp)
  3610. }
  3611. }
  3612. }
  3613. });
  3614. if(upload_paper_flag){
  3615. window.my.upload_papers(answers,this.config.id,"智慧树");
  3616. }
  3617. // alert('alv');
  3618. // this.upload_all_problem(false)
  3619. //题库获取模块 end
  3620. }
  3621. }
  3622. MyPage.prototype.x_res = function(){
  3623. return this.api.resource_farming()
  3624. }
  3625. MyPage.prototype.getAnswers = async function(id,deep){
  3626. let answers = {};
  3627. let obj={
  3628. "poolId": this.config.poolId,
  3629. "userId": this.config.tk_uid,
  3630. "querry": {
  3631. "operator": "==",
  3632. "argument1": "papertitle",
  3633. "argument2": id,
  3634. },
  3635. "deep": deep,
  3636. };
  3637. await(this.upladApi("/tiku/api/v1/queryCollection",obj).then(async (resutData)=>{
  3638. if(resutData.result==="success" && !!resutData.json){
  3639. var data = resutData.json.results;
  3640. console.log("总共查询到数据库数量"+data.length+"个");
  3641. data.forEach((item, index) =>{
  3642. if(index == 0){
  3643. answers =this.resoluAnswers(item);
  3644. }else{
  3645. this.resoluAnswers(item).rows.forEach(i =>{
  3646. answers.rows.push(i);
  3647. })
  3648. }
  3649. });
  3650. }
  3651. }));
  3652.  
  3653. return answers;
  3654. }
  3655.  
  3656. MyPage.prototype.arrowMove = function(e){
  3657. // var e = document.getElementById(e);
  3658. // 元素大小
  3659. let elW = e.currentTarget.offsetWidth
  3660. let elH = e.currentTarget.offsetHeight
  3661. // 元素位置
  3662. let elL = e.currentTarget.parentNode.parentNode.offsetLeft
  3663. let elT = e.currentTarget.parentNode.parentNode.offsetTop
  3664. // 鼠标位置
  3665. let x = e.clientX
  3666. let y = e.clientY
  3667. // 窗口大小
  3668. let w = window.innerWidth
  3669. let h = window.innerHeight
  3670. // 鼠标到元素左边距离
  3671. let moveX = x - elL
  3672. let moveY = y - elT
  3673. let el = e.currentTarget
  3674. document.onmousemove = function (e) {
  3675. // el.style.position = 'fixed';
  3676. el.parentNode.parentNode.style.left = e.clientX -moveX + 'px'
  3677. el.parentNode.parentNode.style.top =e.clientY - moveY + 'px'
  3678. }
  3679. document.onmouseup = function (e) {
  3680. document.onmousemove = null
  3681. document.onmouseup = null
  3682. }
  3683. };
  3684.  
  3685. MyPage.prototype.initMenu = function(show){
  3686. let $ = this.$,menu = this.menu;
  3687. // $(shadowContent.querySelector("#x_set"))[0].parentNode.remove()
  3688.  
  3689. /**
  3690. * MosoteachHelper CSS
  3691. */
  3692. const styleTag = `
  3693. #${menu.id} #zhu_${menu.id} button[disabled]{
  3694. color: white !important;
  3695. background-color: rgb(188, 188, 188) !important;
  3696. }
  3697. #${menu.id} #zhu_${menu.id} button{
  3698. float:left;
  3699. margin:25px 2px;
  3700. // width:70px;
  3701. // height:25px;
  3702. /* 把按钮撑大 */
  3703. padding: 4px 8px;
  3704. /* 去除默认边框 */
  3705. border: none;
  3706. /* 圆角 */
  3707. border-radius: 50px;
  3708. /* 按钮背景色 */
  3709. background-color: #8888ff;
  3710. /* 字体颜色、大小、粗细、字间距 */
  3711. color: #fff;
  3712. font-size: 12px;
  3713. font-weight: bold;
  3714. letter-spacing: 1px;
  3715. /* 鼠标小手 */
  3716. cursor: pointer;
  3717. /* 给个定位 */
  3718. position: relative;
  3719. /* 3D模式 */
  3720. transform-style: preserve-3d;
  3721. /* 过度动画时间 */
  3722. transition: ease-in-out 2s;
  3723. }
  3724. #${menu.id} #zhu_${menu.id} button:hover {
  3725. /* 鼠标放上来旋转一圈 */
  3726. transform: rotateX(360deg);
  3727. }
  3728. #${menu.id} #zhu_${menu.id} button::before,
  3729. #${menu.id} #zhu_${menu.id} button:after {
  3730. content: "";
  3731. /* 白色边框线 */
  3732. border: 0.8px solid #fff;
  3733. /* 圆角 */
  3734. border-radius: 50px;
  3735.  
  3736. /* 通过定位来撑开边框,简单来说,确定4边的距离,中间自然就固定了 */
  3737. position: absolute;
  3738. top: 1px;
  3739. left: 1px;
  3740. right: 1px;
  3741. bottom: 1px;
  3742.  
  3743. /* 3D模式 */
  3744. transform-style: preserve-3d;
  3745. /* 设置透视参数,向 Z轴方向移动,正常时候就是向屏幕外面移动 */
  3746. transform: perspective(1000px) translateZ(5px);
  3747. }
  3748. #${menu.id} #zhu_${menu.id} button::after {
  3749. /* 另一边反着移动一下 */
  3750. transform: perspective(1000px) translateZ(-5px);
  3751. }
  3752. #${menu.id} #zhu_${menu.id} button span {
  3753. /* 设置 span 为块元素 */
  3754. display: block;
  3755. /* 3D模式 */
  3756. transform-style: preserve-3d;
  3757. /* 同样设置透视,抬高 Z轴距离 */
  3758. transform: perspective(500px) translateZ(8px);
  3759. }
  3760. #${menu.id}{
  3761. color: #000;
  3762. ${GM_getValue("is_hide")?'display: none;':''}
  3763. font-size:14px;
  3764. z-index: 9999;
  3765. display: ${show};
  3766. text-align:center;
  3767. // width:0;
  3768. // height:0;
  3769. position:fixed;
  3770. pointer-events: none;
  3771. left:${menu.pos.x}px;
  3772. top:${menu.pos.y}px;
  3773. // background:${menu.background};
  3774. // opacity:${menu.opacity};
  3775. }
  3776. #${menu.id} #zhu_${menu.id}{
  3777. pointer-events: visible;
  3778. }
  3779. #${menu.id} .drawer{
  3780. pointer-events: visible;
  3781. position:relative;
  3782. max-height:400px;
  3783. overflow:auto;
  3784. text-align: center;
  3785. display: none;
  3786. background: #fff;
  3787. border-radius: 10px;
  3788. box-shadow: 0 5px 15px rgba(0,0,0,0.2);
  3789. width: 100%; /* initially */
  3790. max-width: 300px;
  3791. opacity: 0.9;
  3792. z-index: 199;
  3793. padding:10px 0px;
  3794. margin:10px;
  3795. }
  3796. #${menu.id} p{
  3797. text-align:left;
  3798. padding-left:5px;
  3799. }
  3800. #${menu.id} .drawer input{
  3801. border-radius: 3px;
  3802. border: 1px solid #000;
  3803. color: #000;
  3804. background-color: #FFF;
  3805. width:160px;
  3806. }
  3807. #${menu.id} .drawer button{
  3808. white-space: pre; /*禁止换行*/
  3809. width:40px;
  3810. display:inline;
  3811. border: 1px solid;
  3812. background-color: transparent;
  3813. text-transform: uppercase;
  3814. padding: 1px 0px;
  3815. font-weight: 300;
  3816. }
  3817. #${menu.id} .drawer button:hover {
  3818. color: white;
  3819. border: 0;
  3820. background-color: #4cc9f0;
  3821. -webkit-box-shadow: 10px 10px 99px 6px rgba(76,201,240,1);
  3822. -moz-box-shadow: 10px 10px 99px 6px rgba(76,201,240,1);
  3823. box-shadow: 10px 10px 99px 6px rgba(76,201,240,1);
  3824. }
  3825. #${menu.id} #x_set{
  3826. animation: change 3s linear 0s infinite;
  3827. float:left;
  3828. position:relative;
  3829. z-index: 200;
  3830. margin:10px;
  3831. border-radius:50%;
  3832. overflow:hidden;
  3833. height: 50px;
  3834. width:50px;
  3835. border: solid 2px #00ff00;
  3836. background: url(${GM_getValue("userimg") ? GM_getValue("userimg"):"https://i.jpg.dog/8a4f4bd4c5ea7b1eff20a2978885f2b1.jpeg"});
  3837. background-size: 50px 50px;
  3838. }
  3839. @keyframes change {
  3840. 0% {border: solid 2px #333;}
  3841. 25% {border: solid 2px #f60;}
  3842. 50% {border: solid 2px #f00;}
  3843. 75% {border: solid 2px #1ab558;}
  3844. 100% {border: solid 2px #333;}
  3845. }`;
  3846.  
  3847. let $menu =
  3848. `
  3849. <div id='${menu.id}'>
  3850. <div id ="zhu_${menu.id}" >
  3851. <div id="x_set"></div>
  3852. </div>
  3853. <div class= "drawer" id="set">
  3854. <div>
  3855. 🦄️ <input id = "tiku_user" readonly="readonly" value="未获取到用户名,请刷新重试" />
  3856. ${GM_getValue("ti_uid")?`<button onclick="GM_setValue('ti_uid','');confirm('确认退出') && location.reload()">退出</button>`:`<button onclick="window.open('${this.ChatIP}/#/activate', 'Meto登陆');">登陆</button>`}
  3857. <button id="x_charge" ><a target="_blank" href = "https://d.metost.com/buy/3">赞赏</a></button>
  3858. </div>
  3859. <div>
  3860. 🔎 <input id = "find_input" placeholder="搜索题目需要6个字符以上" />
  3861. <button id="x_find" >MT搜</button>
  3862. <button id="x_AIfind" >AI搜</button>
  3863. </div>
  3864. <div>
  3865. 本项目非盈利,欢迎给项目发电<br/>
  3866. 大家的支持才有我开发的动力<br/>
  3867. <a target="_blank" href = "https://pd.qq.com/s/7hrwqmix1">QQ频道:🌈点我进群🌈</a><br/>
  3868. <a target="_blank" href = "https://t.me/tg_meto">TG群:🐟点我进群(需魔法)🐟</a><br/>
  3869. </div>
  3870. </div>
  3871. <div class= "drawer" id="aner">
  3872. <p>
  3873. 正在获取试卷中,请稍等
  3874. </p>
  3875. </div>
  3876. </div>
  3877. `;
  3878. // 使用自定义元素
  3879. const hostElement = $("html")[0].appendChild(document.createElement('div'));;
  3880. const shadowRoot = hostElement.attachShadow({ mode: 'closed' });
  3881. // 创建样式元素并将样式添加到影子根节点中
  3882. const stylesElement = document.createElement('style');
  3883. stylesElement.textContent = styleTag;
  3884. shadowRoot.appendChild(stylesElement);
  3885.  
  3886. // 创建影子 DOM 中的内容
  3887. shadowContent = document.createElement('div');
  3888. shadowContent.innerHTML = $menu;
  3889. this.shadowContent=shadowContent
  3890.  
  3891. // 将影子元素添加到影子根节点中
  3892. shadowRoot.appendChild(shadowContent);
  3893.  
  3894. GM_registerMenuCommand("基本设置",function(){
  3895. div_set.toggle('active');
  3896. });
  3897. GM_registerMenuCommand(GM_getValue("is_hide") ? "显示脚本UI" : "隐藏脚本UI" ,function(){
  3898. GM_setValue("is_hide",!GM_getValue("is_hide"));
  3899. GM_getValue("is_hide")?$(shadowContent).find('#'+menu.id).hide():$(shadowContent).find('#'+menu.id).show();
  3900. });
  3901. GM_registerMenuCommand(GM_getValue("is_wait") ? "开启延迟交卷" : "关闭延迟交卷(不建议)" ,function(){
  3902. GM_setValue("is_wait",!GM_getValue("is_wait"));
  3903. location.reload();
  3904. });
  3905. GM_registerMenuCommand("重置脚本",function(){
  3906. GM_setValue("overdue",1);
  3907. GM_setValue("window.al_yun_xx",null);
  3908. location.reload();
  3909. });
  3910. $(shadowContent).on('mousedown', '#x_set', function (e) {
  3911. e.stopPropagation();
  3912. window.my.arrowMove(e);//.target.parentNode.id
  3913. });
  3914. $(shadowContent).on('click', '#x_start', function () {
  3915. window.my.start();
  3916. });
  3917. $(shadowContent).on('click', '#x_set', function () {
  3918. if(document.querySelectorAll("#wzq").length>1 || document.querySelectorAll("#qptjb").length==1){
  3919. alert("检测到您安装了多个不同版本的脚本\n导致脚本发生冲突\n请关闭除《"+GM_info.script.name+"》以外的脚本")
  3920. }
  3921. div_set.toggle('active');
  3922. aner.hide("slow");
  3923. });
  3924. // $(document).on('click', '#x_charge', function () {
  3925. // aner.css("display","block")
  3926. // aner.text("");
  3927. // aner.append("充电地址:");
  3928.  
  3929. // });
  3930. $(shadowContent).on('click', '#x_find',async function () {
  3931. aner.show("slow");
  3932. aner.text("");
  3933. if(find_input.value.length <6){
  3934. aner.append("搜索题目需要6个字符以上");
  3935. return;
  3936. }
  3937. aner.append("若长时间未返回信息,请反馈<hr>");
  3938. // problem = window.my.HtmlUtil.htmlDecode(text.value);
  3939. // console.log(problem)
  3940. await window.my.findproblem(find_input.value.replace(/ /g," ").substr(0,30))
  3941. aner.text("");
  3942. aner.append("搜索到"+window.my.config.answer.rows.length+"条相关题目<hr>");
  3943. window.my.config.answer.rows.forEach(row=>{
  3944. aner.append("题目:"+row.subject+"<br>"+"答案:");
  3945. row.answers.forEach(answer =>{
  3946. aner.append(answer+" ");
  3947. });
  3948. aner.append("<hr>");
  3949. });
  3950. });
  3951. $(shadowContent).on('click', '#x_AIfind',async function () {
  3952. aner.show("slow");
  3953. aner.text("");
  3954. if(find_input.value.trim() == ""){
  3955. aner.append("请输入内容");
  3956. return;
  3957. }
  3958. aner.append("若长时间未返回信息,请反馈<hr>");
  3959.  
  3960. let obj ={
  3961. "messages": [
  3962. {
  3963. "role": "user",
  3964. "content": find_input.value
  3965. }
  3966. ],
  3967. "stream": true,
  3968. "model": "gpt-3.5-turbo",
  3969. "temperature": 0.5,
  3970. "presence_penalty": 0,
  3971. "frequency_penalty": 0,
  3972. "top_p": 1
  3973. };
  3974. GM_xmlhttpRequest({
  3975. responseType:"stream",
  3976. timeout: 10000,
  3977. method: "post",
  3978. url: window.my.ChatIP+"/api/openai/v1/chat/completions",
  3979. headers:{
  3980. // Authorization:'Bearer nk-wangzeqing',
  3981. Authorization:'Bearer nk-'+window.my.config.tk_uid+","+window.my.config.poolId,
  3982. // Cookie:"next-auth.csrf-token=e8b5559fadb5ce3684e9a0611591684ffffc2224d9125a49e7081a92425c3026%7C47d575638e3a14f787462c27c1fe8895d740210370848182a740fa71dfb55211; next-auth.callback-url=http%3A%2F%2Flocalhost%3A3000; next-auth.session-token=eyJhbGciOiJkaXIiLCJlbmMiOiJBMjU2R0NNIn0..wNFkEP1XItcDCpY2.nJBc4rvu8_cAGx0mtDdm2pvIjPAWGMGou24L2ZzoyImrCIqLDiAMS5w6WzN6dm_8GuI331tfqxHc_V4LRoAmmFT0A8X5ln9C1iC4p47IQM_4RF2B-8iLGElCkVOYJieCkvV1lVrFHVT31nzI12n8Xpwttrw5yGhywCR3sWZ1J7sr4QCXeCA-lpOdITDyW8AdNPjH4QQ7vhtCIzjzFoepmJKk5mE2lPmksDiGrQX3d1POPwfQqdHafb8rgZJl_BC4_wDXloIt6mtTfQ4._NPSNHQIhsWS5eQprCIeCQ",
  3983. },
  3984. data: JSON.stringify(obj),
  3985. onloadstart: function(response) {
  3986. aner.text("");
  3987. // console.log(response.response)
  3988. const reader = response.response.getReader();
  3989. var error_d = "";
  3990. function read() {
  3991. reader.read().then(({ done, value }) => {
  3992. if (done) {
  3993. console.log('读取完毕');
  3994. return;
  3995. }
  3996. let data = new TextDecoder().decode(value)
  3997. data.split("data:").forEach(d=>{
  3998. if(d!=""&&d.indexOf("[DONE]") == -1){
  3999. let Json_msg=null;
  4000. try{
  4001. if(error_d){
  4002. d = error_d +d;
  4003. error_d="";
  4004. }
  4005. Json_msg = $.parseJSON(d)
  4006. if(Json_msg.msg=="empty access code"||Json_msg.msg=="wrong access code"){
  4007. aner.append("若需要使用AI功能请先<button onclick=\"window.open('"+window.my.ChatIP+"/#/activate', 'Meto登陆');\">登陆</button>");
  4008. return;
  4009. }else if(Json_msg.msg=="剩余token不足请[充值](https://d.metost.com/)"){
  4010. aner.append("您的AI剩余TOKEN已不足请<button onclick=\"window.open('https://d.metost.com/', 'Meto登陆');\">充值</button><br/>未登陆账号请<button onclick=\"window.open('"+window.my.ChatIP+"/#/activate', 'Meto登陆');\">登陆</button>");
  4011. return;
  4012. }
  4013. aner.append(Json_msg.choices[0].delta.content);
  4014. aner.scrollTop(aner.prop("scrollHeight"));
  4015. }catch (e){
  4016. if(Json_msg){
  4017. aner.append("发生异常:" + d);
  4018. }else{
  4019. console.log("发生异常:" + d)
  4020. }
  4021. error_d=d;
  4022. }
  4023. }
  4024. });
  4025. // console.log($.parseJSON(data));
  4026. // 继续读取下一个数据块
  4027. read();
  4028. });
  4029. }
  4030. // 开始读取数据
  4031. read();
  4032. },
  4033. onerror : function(err){
  4034. console.log('error')
  4035. aner.append("发生异常:" + err);
  4036. },
  4037. ontimeout : function(inf){
  4038. console.log('请求超时')
  4039. aner.append("请求超时:" + inf);
  4040. }
  4041. })
  4042. });
  4043. $(shadowContent).on('click', '#x_yue', async function () {
  4044. aner.show("slow");
  4045. $(shadowContent.querySelector("#x_yue")).attr("disabled", true)
  4046. aner.text("正在搜索答案中");
  4047. let answers = await(window.my.getAnswers(window.my.config.id,true));
  4048. if(!answers||JSON.stringify(answers) == "{}"){
  4049. aner.text("暂时没有此试卷信息。可直接开始答题进行搜索(可能最终答案没那么全)");
  4050. return;
  4051. }
  4052. aner.text("搜索到"+ answers.rows.length +"条题目信息");
  4053. answers.rows.forEach(row=>{
  4054. aner.append("<hr>");
  4055. aner.append("题目:"+row.subject+"<br>"+"答案:");
  4056. row.answers.forEach(answer =>{
  4057. aner.append(answer+" ");
  4058. });
  4059. });
  4060. });
  4061. $(shadowContent).on('click', '#x_res', async function () {
  4062. $(shadowContent.querySelector("#x_res")).attr("disabled", true)
  4063. window.my.x_res()
  4064. });
  4065. $(shadowContent).on('click', '#x_forum', async function () {
  4066. let texts = prompt("请添加讨论词,使用英文逗号,进行分隔\n注意最后不要加上,", "我是一号讨论词,我是二号讨论词")
  4067. GM_setValue("forum_texts", texts);
  4068. });
  4069.  
  4070. $(shadowContent).on('click', '#x_recall', async function () {
  4071. $(shadowContent.querySelector("#x_recall")).attr("disabled", true)
  4072. $(shadowContent.querySelector("#"+menu.id)).css("left","0").css("top","0");
  4073. $(shadowContent.querySelector(".drawer")).hide();
  4074. $(".t-answer").each((index,div) =>{
  4075. $(div).append("<button class =\"addpro\" style = \"height:30px; background:#c9fff5 ;border-radius: 50px;padding: 3px;margin-top: 10px;\">添加到错题</button>")
  4076. $(div).find("span").css("color","#FFF").css("display","block").css("width","70px").css("font-size","25px").css("border","1px solid black").click(function(_this){
  4077. $(_this.currentTarget).css("color","#0bd")
  4078. });
  4079. $(div).find(".answer-r").hide();
  4080. })
  4081. });
  4082. $(shadowContent).on('click', '#x_error_problems', async function () {
  4083. let error_problem = GM_getValue(window.my.config.id+"_error_problem");
  4084. if(!error_problem){
  4085. error_problem = {};
  4086. alert("您还未建立错题集");
  4087. return;
  4088. }
  4089. $(shadowContent.querySelector("#x_recall")).attr("disabled", true)
  4090. $(shadowContent.querySelector("#"+menu.id)).css("left","0").css("top","0");
  4091. $(shadowContent.querySelector(".drawer")).hide();
  4092. $(".topic-list").text("");
  4093. for (var i in error_problem) {
  4094. $(".topic-list").append(error_problem[i]);
  4095.  
  4096. };
  4097. $(".t-answer").each((index,div) =>{
  4098. $(div).find("span").css("color","#FFF").css("display","block").css("width","70px").css("font-size","25px").css("border","1px solid black").click(function(_this){
  4099. $(_this.currentTarget).css("color","#0bd")
  4100. });
  4101. });
  4102. });
  4103.  
  4104. $(document).on('click', '.addpro', async function (_this) {
  4105. $(_this.currentTarget).attr("class","delpro").css("background","#f2ffc9").text("移出错题集");
  4106. let error_problem = GM_getValue(window.my.config.id+"_error_problem");
  4107. if(!error_problem){
  4108. error_problem = {};
  4109. console.log("新建错题库");
  4110. }
  4111. error_problem[$(_this.currentTarget.offsetParent).find(".t-index").text()] = _this.currentTarget.offsetParent.outerHTML;
  4112. GM_setValue(window.my.config.id+"_error_problem",error_problem);
  4113. console.log(error_problem);
  4114. });
  4115. $(document).on('click', '.delpro', async function (_this) {
  4116. $(_this.currentTarget).attr("class","addpro").css("background","#c9fff5").text("添加到错题");
  4117. let error_problem = GM_getValue(window.my.config.id+"_error_problem");
  4118. delete error_problem[$(_this.currentTarget.offsetParent).find(".t-index").text()];
  4119. GM_setValue(window.my.config.id+"_error_problem",error_problem);
  4120.  
  4121. });
  4122.  
  4123.  
  4124.  
  4125. window.aner = $(shadowContent.querySelector("#aner"));
  4126. window.div_zhu = $(shadowContent.querySelector("#zhu_"+menu.id));
  4127. window.div_set = $(shadowContent.querySelector("#set"));
  4128. window.find_input = shadowContent.querySelector("#find_input");
  4129. //暴露到全局
  4130. _this.aner =window.aner
  4131. _this.div_zhu =window.div_zhu
  4132. _this.div_set =window.div_set
  4133. _this.find_input = window.find_input
  4134. // GM_setValue("update_time","")
  4135. if(!GM_getValue("update_time")){//全脚本首次安装
  4136. GM_setValue("update_time",Date.now()/1000/60/60)
  4137. div_set.css("display","block")
  4138. aner.css("display","block")
  4139. aner.text("meto欢迎您的使用");
  4140. aner.append("<br/>欢迎关注公众号meto搜题<br/>可以试着移动、点击头像<br/>装载截图识别文字(shift+↑)<br/>关闭截图识别文字(shift+↓)")
  4141. // aner.append('<br/><div text-align: center;"><p>此页面仅在首次加载时出现</p> <p>网络讨口子来咯(商家码)</p> <img src="https://d.metost.com/uploads/images/IMG_2484.PNG" style="width:200px" ></div>')
  4142. }
  4143. }
  4144.  
  4145. MyPage.prototype.initData = async function(){ //初始化
  4146. // this.api.upload_all_problem(true) //测试全局上传
  4147. this.config.tk_uid=GM_getValue("ti_uid");
  4148. this.config.pp = GM_getValue("pp");
  4149. this.config.poolId = GM_getValue("poolId");
  4150. console.log(this.config.front_url)
  4151. //GM_getValue("overdue") != this.config.hostname || //暂时去除,保留登陆信息
  4152. if(GM_getValue("overdue") == 1
  4153. ||!this.config.tk_uid || !this.config.pp || !this.config.poolId
  4154. || this.config.tk_uid == "null" || this.config.pp == "null" || this.config.poolId == "null")
  4155. {
  4156. GM_setValue("overdue",this.config.hostname)
  4157. try{
  4158. var obj =await this.api.get_user_obj();
  4159. console.log(obj)
  4160. if(!obj.unionid){
  4161. console.log("未获取到用户id")
  4162. return
  4163. }
  4164. }catch(e){
  4165. console.log(e)
  4166. aner.show("slow");
  4167. aner.text("该网站暂时不支持快速登陆,请点击登陆按钮进行手动登陆,或者联系管理员适配")
  4168. $(shadowContent.querySelector(".drawer")).show("slow");
  4169. return;
  4170. }
  4171. aner.show("slow");
  4172. aner.text("因恶意攻击关闭快捷登录(不可用),请手动登录(不可用)")
  4173. // aner.append(`</br>或<a href="https://metost.com/docs/download/">更新完整版</a>进行更多体验`)
  4174. $(shadowContent.querySelector(".drawer")).show("slow");
  4175. }
  4176. shadowContent.querySelector("#tiku_user").value=this.config.tk_uid||"您的版本过低,请手动登录(不可用)";
  4177. try{
  4178. this.api.init_button()
  4179. }catch(e){
  4180. console.log("暂时未定义button",e)
  4181. }
  4182. document.hasFocus = ()=> { //移出窗口
  4183. return true
  4184. }
  4185. /*
  4186. * 主要应用于智慧树不可复制
  4187. */
  4188. document.onselectstart = true;
  4189. document.oncopy = true;
  4190. document.oncut = true;
  4191. document.onpaste = true;
  4192. document.oncontextmenu = true;
  4193. window.getSelection().removeAllRanges = function (){}
  4194. window.getSelection().empty = function (){}
  4195. }
  4196.  
  4197.  
  4198.  
  4199. MyPage.prototype.prival_global= async function(){
  4200. /*
  4201. * 全局定时器
  4202. */
  4203. var flag=true;
  4204. let GlobalInterval=setInterval(()=> {
  4205. if(this.config.front_url[2]=="www.icourse163.org"){
  4206. // console.log(this.config.aid)
  4207. }else{
  4208. if(this.config.front_url[this.config.front_url.length-1] != window.location.href.split("?")[0].split("/")[window.location.href.split("?")[0].split("/").length-1] || this.config.front_url[this.config.front_url.length-2] != window.location.href.split("?")[0].split("/")[window.location.href.split("?")[0].split("/").length-2]){
  4209. clearInterval(GlobalInterval)//部分网站会死循环
  4210. location.reload()
  4211. }
  4212. }
  4213. let yaya_select = window.getSelection().toString();
  4214. if(yaya_select){
  4215. try{
  4216. find_input.value = window.getSelection().toString()
  4217. }catch{
  4218. clearInterval(GlobalInterval)
  4219. }
  4220. }
  4221. if($("video").length&&flag){
  4222. flag = false
  4223. window.my.video_spend()
  4224. }
  4225. }, 400)
  4226. return this;
  4227. }
  4228. MyPage.prototype.findproblem = async function(text){
  4229. let obj={
  4230. "poolId": this.config.poolId,
  4231. "userId": this.config.tk_uid,
  4232. "querry": {
  4233. "operator": "contains",
  4234. "argument1":"problemText",
  4235. "argument2":text,
  4236. }
  4237. }
  4238. /////
  4239. await(this.upladApi("/tiku/api/v1/queryProblems",obj).then(async (resutData)=>{
  4240. if(resutData.result==="success" && !!resutData.json){
  4241. var data = resutData.json.results;
  4242. //处理数据,添加标识头
  4243. let obj = {
  4244. flag: "metoproblems",
  4245. problems : data,
  4246. }
  4247. this.config.answer =this.resoluAnswers(obj);
  4248. }
  4249. }))
  4250. }
  4251.  
  4252. MyPage.prototype.findproblems = async function(problems){
  4253. let answer = []
  4254. let obj={
  4255. "poolId": this.config.poolId,
  4256. "userId": this.config.tk_uid,
  4257. "querry": {
  4258. "operator": "mulit",
  4259. "argument1":"1",
  4260. "argument2":"2",
  4261. "problems":[]
  4262. }
  4263. }
  4264. /////
  4265. problems.forEach(problem =>{
  4266. let problemobj = {
  4267. "operator": "==",
  4268. "argument1": "problemText",
  4269. "argument2": problem,
  4270. }
  4271. obj.querry.problems.push(problemobj);
  4272. })
  4273. await(this.upladApi("/tiku/api/v1/queryProblems",obj).then(async (resutData)=>{
  4274. if(resutData.result==="success" && !!resutData.json){
  4275. var data = resutData.json.results;
  4276. //处理数据,添加标识头
  4277. let obj = {
  4278. flag: "metoproblems",
  4279. problems : data,
  4280. }
  4281. answer = this.resoluAnswers(obj)
  4282. // console.log(this.config.answers);
  4283. }
  4284. }))
  4285. return answer
  4286. }
  4287.  
  4288. MyPage.prototype.upload_papers = async function(answers,title,platform){
  4289. var classname = GM_getValue(this.config.clazz_course_id)
  4290. if(!classname){
  4291. classname = "未命名课程";
  4292. }
  4293. let obj={
  4294. "poolId": this.config.poolId,
  4295. "userId": this.config.tk_uid,
  4296. "problemIds": [],
  4297. "title":title,
  4298. "tags":[classname,platform],
  4299. }
  4300. answers.rows.forEach(row=>{
  4301. for(let i =0;i<obj.problemIds.length;i++){
  4302. if(obj.problemIds[i] == row.problemId){
  4303. return;
  4304. }
  4305. }
  4306. obj.problemIds.push(row.problemId);
  4307. });
  4308. // console.log(obj);
  4309. await(this.upladApi("/tiku/api/v1/collection",obj).then(async (resutData)=>{
  4310. if(resutData.result==="success" && !!resutData.json){
  4311. // var data = resutData.json.results;
  4312. console.log(resutData);
  4313. }
  4314. }))
  4315. }
  4316.  
  4317.  
  4318. MyPage.prototype.Listener = function(){
  4319. $('body').append(
  4320. `<script>
  4321. ;(function() {
  4322. if (typeof window.CustomEvent === 'function') return false;
  4323. function CustomEvent(event, params) {
  4324. params = params || { bubbles: false, cancelable: false, detail: undefined };
  4325. // 创建自定义事件
  4326. var evt = document.createEvent('CustomEvent');
  4327. // 第一个参数为要处理的事件名
  4328. // 第二个参数为表明事件是否冒泡
  4329. // 第三个参数为表明是否可以取消事件的默认行为
  4330. // 第四个参数为细节参数
  4331. evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
  4332. return evt;
  4333. }
  4334. CustomEvent.prototype = window.Event.prototype;
  4335. window.CustomEvent = CustomEvent;
  4336. })();
  4337. (function() {
  4338. function ajaxEventTrigger(event) {
  4339. // 创建事件对象
  4340. var ajaxEvent = new CustomEvent(event, { detail: this });
  4341. // 触发执行
  4342. window.dispatchEvent(ajaxEvent);
  4343. }
  4344. var oldXHR = window.XMLHttpRequest;
  4345. function newXHR() {
  4346. var realXHR = new oldXHR();
  4347. realXHR.addEventListener('abort', function() { ajaxEventTrigger.call(this, 'ajaxAbort'); }, false);
  4348. realXHR.addEventListener('error', function() { ajaxEventTrigger.call(this, 'ajaxError'); }, false);
  4349. realXHR.addEventListener('load', function() { ajaxEventTrigger.call(this, 'ajaxLoad'); }, false);
  4350. realXHR.addEventListener('loadstart', function() { ajaxEventTrigger.call(this, 'ajaxLoadStart'); }, false);
  4351. realXHR.addEventListener('progress', function() { ajaxEventTrigger.call(this, 'ajaxProgress'); }, false);
  4352. realXHR.addEventListener('timeout', function() { ajaxEventTrigger.call(this, 'ajaxTimeout'); }, false);
  4353. realXHR.addEventListener('loadend', function() { ajaxEventTrigger.call(this, 'ajaxLoadEnd'); }, false);
  4354. realXHR.addEventListener('readystatechange', function() { ajaxEventTrigger.call(this, 'ajaxReadyStateChange'); }, false);
  4355. // l.onreadystatechange = function() {
  4356. // if (l && 4 === l.readyState && (0 !== l.status || l.responseURL && 0 === l.responseURL.indexOf("file:"))) {
  4357. // var n = "getAllResponseHeaders"in l ? a(l.getAllResponseHeaders()) : null
  4358. // , r = e.responseType && "text" !== e.responseType ? l.response : l.responseText
  4359. // , i = {
  4360. // data: r,
  4361. // status: l.status,
  4362. // statusText: l.statusText,
  4363. // headers: n,
  4364. // config: e,
  4365. // request: l
  4366. // };
  4367. // o(t, f, i),
  4368. // l = null
  4369. // }
  4370. // }
  4371. return realXHR;
  4372. }
  4373. window.XMLHttpRequest = newXHR;
  4374. })();
  4375. // 调用
  4376. window.addEventListener('ajaxReadyStateChange', function(e) {
  4377. // if (e.detail.readyState === 1) {
  4378. // console.log(123);
  4379. // e.detail.setRequestHeader('token', '1326');
  4380. // }
  4381. e.detail.onload = function() {
  4382. // if(e.detail.responseURL=="https://www.mosoteach.cn/web/index.php?c=interaction_quiz&m=save_answer"){
  4383. console.log('event====>', e.detail);
  4384. // }
  4385. };
  4386. });
  4387. `
  4388. )
  4389.  
  4390. }
  4391.  
  4392. MyPage.prototype.compareArr = function(arr1 = [], arr2 = []) {
  4393. // arr1.sort();
  4394. // arr2.sort();
  4395. const setA = new Set(arr1);
  4396. const setB = new Set(arr2);
  4397. const intersection = new Set([...setA].filter(x => setB.has(x))); // 交集
  4398. const union = new Set([...setA, ...setB]); // 并集
  4399. const differenceA = new Set([...setA].filter(x => !setB.has(x))); // a数组中有而b数组中没有的元素
  4400. const differenceB = new Set([...setB].filter(x => !setA.has(x))); // b数组中有而a数组中没有的元素
  4401. if (intersection.size === 0) {
  4402. return 'disjoint'; // a、b不相交
  4403. } else if (intersection.size === setA.size && intersection.size === setB.size) {
  4404. return 'equal'; // a、b相等
  4405. } else if (intersection.size === setA.size) {
  4406. return 'subset'; // a是子集
  4407. } else if (intersection.size === setB.size) {
  4408. return 'superset'; // a是父集
  4409. } else {
  4410. return 'mix';// a、b相交但不包含
  4411. }
  4412. }
  4413.  
  4414. MyPage.prototype.start =function(reslist){
  4415. return this.api.start_search()
  4416. }
  4417. _this.MyPage = MyPage;
  4418. })(unsafeWindow||window);
  4419.  
  4420. if(window.location == window.parent.location){ // 判断是否为ifarm
  4421. window.my = new unsafeWindow.MyPage({
  4422. id:"mm_"+Math.floor(100000+Math.random()*100000),
  4423. width:80,
  4424. background:'#fff',
  4425. opacity:0.8,
  4426. pos:{
  4427. x:80,
  4428. y:80
  4429. }
  4430. });
  4431. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址