Greasy Fork is available in English.

智慧树网课助手(可作业、考试)

自动挂机看知到MOOC,支持屏蔽弹窗题目、自动切换下一节,章测试和考试支持自动答题

// ==UserScript==
// @name         智慧树网课助手(可作业、考试)
// @namespace    https://taobao.idey.cn/index
// @version      4.2.0
// @description  自动挂机看知到MOOC,支持屏蔽弹窗题目、自动切换下一节,章测试和考试支持自动答题
// @require      https://cdn.staticfile.org/jquery/1.12.4/jquery.min.js
// @require      https://cdn.bootcss.com/jquery.qrcode/1.0/jquery.qrcode.min.js
// @author       免费王子
// @match        *://*.zhihuishu.com/*
// @match        *://*.jd.hk/*
// @match        *://*.nbdlib.cn/*
// @match        *://*.jd.com/*
// @match        *://*.taobao.com/*
// @match        *://*.taobao.hk/*
// @match        *://*.tmall.com/*
// @match        *://*.tmall.hk/*
// @match    *://*.yiyaojd.com/*
// @exclude       *://login.taobao.com/*
// @exclude       *://pages.tmall.com/*
// @exclude       *://uland.taobao.com/*
// @connect      api.902000.xyz
// @connect      report.902000.xyz
// @run-at       document-end
// @grant        unsafeWindow
// @grant        GM_xmlhttpRequest
// @grant        GM_setClipboard
// @license      MIT
// @original-script https://greasyfork.org/en/scripts/380506
// @original-author wyn665817
// @original-license MIT
// @original-script https://greasyfork.org/zh-CN/scripts/427265
// @original-author anhui666
// @original-license MIT
// @antifeature referral-link 隐藏优惠劵查询
// ==/UserScript==
 (function() {
 var index_num = 0;
 var $ = $ || window.$;
 var item = [];
 var urls = [];
 var selectorList = [];
 var obj = {};
 obj.onclicks = function(link) {
 	if (document.getElementById('redirect_form')) {
 		var form = document.getElementById('redirect_form');
 		form.action = 'https://jd.idey.cn/red.html?url=' + encodeURIComponent(link);
 	} else {
 		var form = document.createElement('form');
 		form.action = 'https://jd.idey.cn/red.html?url=' + encodeURIComponent(link);
 		form.target = '_blank';
  
 		form.method = 'POST';
 		form.setAttribute("id", 'redirect_form');
 		document.body.appendChild(form);
  
 	}
 	form.submit();
 	form.action = "";
 	form.parentNode.removeChild(form);
 };
 obj.GetQueryString = function(name) {
 	var reg = eval("/" + name + "/g");
 	var r = window.location.search.substr(1);
 	var flag = reg.test(r);
 	if (flag) {
 		return true;
 	} else {
 		return false;
 	}
 };
  
 obj.get_url = function() {
 	item[index_num] = [];
 	urls[index_num] = [];
 	$("#J_goodsList li").each(function(index) {
 		if ($(this).attr('data-type') != 'yes') {
 			var skuid = $(this).attr('data-sku');
 			var itemurl = '//item.jd.com/' + skuid + '.html';
 			if (skuid != undefined) {
 				if (urls[index_num].length < 4) {
 					item[index_num].push($(this));
 					urls[index_num].push(itemurl);
 					$(this).attr('data-type', 'yes');
 				}
  
  
 			}
 		}
  
 	})
  
 	$("#plist li").each(function(index) {
 		if ($(this).attr('data-type') != 'yes') {
 			var skuid = $(this).find('.j-sku-item').attr('data-sku');
 			var itemurl = '//item.jd.com/' + skuid + '.html';
 			if (skuid != undefined) {
 				if (urls[index_num].length < 4) {
 					item[index_num].push($(this));
 					urls[index_num].push(itemurl);
 					$(this).attr('data-type', 'yes');
 				}
  
  
 			}
 		}
  
 	})
  
 	$(".m-aside .aside-bar li").each(function(index) {
 		if ($(this).attr('data-type') != 'yes') {
 			var itemurl = $(this).find("a").attr('href');
 			if (itemurl != '') {
 				if (itemurl.indexOf("//ccc-x.jd.com") != -1) {
 					var sku_c = $(this).attr('sku_c');
 					if (sku_c == undefined) {
 						var arr = [];
 						var str = $(this).attr('onclick');
 						arr = str.split(",");
 						sku_c = trim(arr[6].replace(/\"/g, ""));
 						itemurl = '//item.jd.com/' + sku_c + '.html';
 					}
  
 				}
 				if (urls[index_num].length < 4) {
 					item[index_num].push($(this));
 					urls[index_num].push(itemurl);
 					$(this).attr('data-type', 'yes');
 				}
  
  
  
 			}
 		}
  
 	})
 	$(".goods-chosen-list li").each(function(index) {
 		if ($(this).attr('data-type') != 'yes') {
 			var itemurl = $(this).find("a").attr('href');
 			if (itemurl != '') {
 				if (itemurl.indexOf("//ccc-x.jd.com") != -1) {
 					var arr = [];
 					var str = $(this).attr('onclick');
 					arr = str.split(",");
 					var sku_c = trim(arr[6].replace(/\"/g, ""));
 					itemurl = '//item.jd.com/' + sku_c + '.html';
  
 				}
 				if (urls[index_num].length < 4) {
 					item[index_num].push($(this));
 					urls[index_num].push(itemurl);
 					$(this).attr('data-type', 'yes');
 				}
  
 			}
  
  
  
  
 		}
  
 	})
  
 	$(".may-like-list li").each(function(index) {
 		if ($(this).attr('data-type') != 'yes') {
 			var itemurl = $(this).find("a").attr('href');
 			if (itemurl != '') {
 				if (itemurl.indexOf("//ccc-x.jd.com") != -1) {
 					var arr = [];
 					var str = $(this).attr('onclick');
 					arr = str.split(",");
 					var sku_c = trim(arr[6].replace(/\"/g, ""));
 					itemurl = '//item.jd.com/' + sku_c + '.html';
 				}
 				if (urls[index_num].length < 4) {
 					item[index_num].push($(this));
 					urls[index_num].push(itemurl);
 					$(this).attr('data-type', 'yes');
 				}
  
  
 			}
 		}
  
 	})
  
  
  
 	if (urls.length > 0 && urls[index_num].length > 0 && item[index_num].length > 0) {
  
  
 		var u = urls[index_num].join(',');
 		$.getJSON('https://shop.idey.cn/jd.php', {
 		act:'itemlink',
 			itemurl: u,
 			num: index_num
 		}, function(res) {
 			if (res.type == 'success') {
 				for (var i = 0; i < res.data.length; i++) {
 					item[res.num][i].find("a").attr('data-ref', res.data[i].longUrl);
 					item[res.num][i].find("a").attr('target', '');
 					item[res.num][i].find("a").unbind("click");
 					item[res.num][i].find("a").bind("click", function(e) {
 						if ($(this).attr('data-ref')) {
 							e.preventDefault();
 							obj.onclicks($(this).attr('data-ref'));
  
 						}
 					})
  
 				}
  
 			}
 		})
  
  
 	}
 	index_num += 1;
  
 };
 obj.get_miaosha = function() {
 	item[index_num] = [];
 	urls[index_num] = [];
 	$(".seckill_mod_goodslist li").each(function(index) {
  
 		if ($(this).attr('data-type') != 'yes') {
  
 			var itemurl = $(this).find("a").attr('href');
 			var skuid = $(this).attr('data-sku');
 			var that = $(this);
 			if (itemurl != '') {
 				if (urls[index_num].length < 4) {
  
 					item[index_num].push($(this));
 					urls[index_num].push(itemurl);
 					$(this).attr('data-type', 'yes');
 				}
  
  
 			}
 		}
  
 	})
  
  
  
 	if (urls.length > 0 && urls[index_num].length > 0 && item[index_num].length > 0) {
  
  
 		var u = urls[index_num].join(',');
 		$.getJSON('https://shop.idey.cn/jd.php', {
 		act:'itemlink',
 			itemurl: u,
 			num: index_num
 		}, function(res) {
 			if (res.type == 'success') {
 				for (var i = 0; i < res.data.length; i++) {
 					item[res.num][i].find("a").attr('data-ref', res.data[i].longUrl);
 					item[res.num][i].find("a").attr('href', "javascript:void(0);");
 					item[res.num][i].find("a").attr('target', '');
 					//	item[res.num][i].find("a").unbind("click");
  
 					item[res.num][i].find("a").click(function(e) {
 						e.preventDefault();
 						obj.onclicks($(this).attr('data-ref'));
 					})
  
 				}
  
 			}
 		})
  
  
 	}
 	index_num += 1;
 };
 const style = `
 			.gwd_taobao .gwd-minibar-bg, .gwd_tmall .gwd-minibar-bg {
 			    display: block;
 			}
  
 			.idey-minibar_bg{
 			    position: relative;
 			    min-height: 40px;
 			    display: inline-block;
 			}
 			#idey_minibar{
 			    width: 560px;
 			    background-color: #fff;
 			    position: relative;
 			    border: 1px solid #e8e8e8;
 			    display: block;
 			    line-height: 36px;
 			    font-family: 'Microsoft YaHei',Arial,SimSun!important;
 			    height: 36px;
 			    float: left;
 			}
 			#idey_minibar .idey_website {
 			    width: 48px;
 			    float: left;
 			    height: 36px;
 			}
 			#idey_minibar .minibar-tab {
 			    float: left;
 			    height: 36px;
 			    border-left: 1px solid #edf1f2!important;
 			    padding: 0;
 			    margin: 0;
 			    text-align: center;
 			}
  
 			#idey_minibar .idey_website em {
 			    background-position: -10px -28px;
 			    height: 36px;
 			    width: 25px;
 			    float: left;
 			    margin-left: 12px;
 			}
  
 			.setting-bg {
 			    background: url(https://cdn.gwdang.com/images/extensions/xbt/new_wishlist_pg5_2.png) no-repeat;
 			}
  
 			#idey_minibar .minibar-tab {
 			    float: left;
 			    height: 36px;
 			    border-left: 1px solid #edf1f2!important;
 			    padding: 0;
 			    margin: 0;
 			    width: 134px;
 			}
 			#idey_price_history span {
 			    float: left;
 			    width: 100%;
 			    text-align: center;
 			    line-height: 36px;
 			    color: #666;
 			    font-size: 14px;
 			}
  
 			#mini_price_history .trend-error-info-mini {
 			    position: absolute;
 			    top: 37px;
 			    left: 0px;
 			    width: 100%;
 			    background: #fff;
 			    z-index: 99999999;
 			    height: 268px;
 			    box-shadow: 0px 5px 15px 0 rgb(23 25 27 / 15%);
 			    border-radius: 0 0 4px 4px;
 			    width:559px;
 			    border: 1px solid #ddd;
 			    border-top: none;
 				display:none;
  
 			}
 			.minibar-btn-box {
 			    display: inline-block;
 			    margin: 0 auto;
 			    float: none;
 			}
 			#mini_price_history .error-p {
 			      width: 95px;
 			      margin: 110px auto;
 			      height: 20px;
 			      line-height: 20px;
 			      text-align: center;
 			      color: #000!important;
 			      border: 1px solid #333;
 			      border-radius: 5px;
 			      display: block;
 			      text-decoration: none!important;
 			    }
 			 #mini_price_history:hover .trend-error-info-mini {
 			      display: block;
 			    }
  
 			.collect_mailout_icon {
 			    background-position: -247px -134px;
 			    width: 18px;
 			}
  
 			#idey_mini_compare_detail li *, .mini-compare-icon, .minibar-btn-box * {
 			    float: left;
 			}
 			.panel-wrap{
 				width: 100%;
 				height: 100%;
 			}
 			.collect_mailout_icon, .mini-compare-icon {
 			    height: 18px;
 			    margin-right: 8px;
 			    margin-top: 9px;
 			}
 			.all-products ul li {
 			    float: left;
 			    width: 138px;
 			    height: 262px;
 			    overflow: hidden;
 			    text-align: center;
 			}
 			.all-products ul li .small-img {
 			    text-align: center;
 			    display: table-cell;
 			    vertical-align: middle;
 			    line-height: 90px;
 			    width: 100%;
 			    height: 100px;
 			    position: relative;
 			    float: left;
 			    margin-top: 23px;
 			}
 			.all-products ul li a img {
 			    vertical-align: middle;
 			    display: inline-block;
 			    width: auto;
 			    height: auto;
 			    max-height: 100px;
 			    max-width: 100px;
 			    float: none;
 			}
 			.all-products ul li a.b2c-other-info {
 			    text-align: center;
 			    float: left;
 			    height: 16px;
 			    line-height: 16px;
 			    margin-top: 13px;
 			}
  
 			.b2c-other-info .gwd-price {
 			    height: 17px;
 			    line-height: 17px;
 			    font-size: 16px;
 			    color: #E4393C;
 			    font-weight: 700;
 				width: 100%;
 				display: block;
 			}
 			.b2c-other-info .b2c-tle {
 			    height: 38px;
 			    line-height: 19px;
 			    margin-top: 8px;
 			    font-size: 12px;
 			    width: 138px;
 			    margin-left: 29px;
 			}
 			 .bjgext-mini-trend span {
 			      float: left;
 			      /*width: 100%;*/
 			      text-align: center;
 			      line-height: 36px;
 			      color: #666;
 			      font-size: 14px;
 			    }
 			    .bjgext-mini-trend .trend-error-info-mini {
 			      position: absolute;
 			      top: 37px;
 			      left: 0px;
 			      width: 100%;
 			      background: #fff;
 			      z-index: 99999999;
 			      height: 268px;
 			      display: none;
 			      box-shadow: 0px 5px 15px 0 rgba(23,25,27,0.15);
 			      border-radius: 0 0 4px 4px;
 			      width: 460px;
 			      border: 1px solid #ddd;
 			      border-top: none;
 			    }
 			    .bjgext-mini-trend .error-p {
 			      width: 100%;
 			      float: left;
 			      text-align: center;
 			      margin-top: 45px;
 			      font-size: 14px;
 			      color: #666;
 			    }
 			    .bjgext-mini-trend .error-sp {
 			      width: 95px;
 			      margin: 110px auto;
 			      height: 20px;
 			      line-height: 20px;
 			      text-align: center;
 			      color: #000!important;
 			      border: 1px solid #333;
 			      border-radius: 5px;
 			      display: block;
 			      text-decoration: none!important;
 			    }
 			    .bjgext-mini-trend:hover .trend-error-info-mini {
 			      display: block;
 			    }
  
  
 			    #coupon_box.coupon-box1 {
 			      width: 560px;
 			      height: 125px;
 			      background-color: #fff;
 			      border: 1px solid #e8e8e8;
 			      border-top: none;
 			      position: relative;
 			      margin: 0px;
 			      padding: 0px;
 			      float: left;
 			      display: block;
 			    }
 			    #coupon_box:after {
 			      display: block;
 			      content: "";
 			      clear: both;
 			    }
 			    .idey_tmall #idey_minibar {
 			      float: none;
 			    }
  
  
 			    .minicoupon_detail {
 			      position: absolute;
 			      top: 35px;
 			      right: -1px;
 			      height: 150px;
 			      width: 132px;
 			      display: none;
 			      z-index: 99999999999;
 			      background: #FFF7F8;
 			      border: 1px solid #F95774;
 			    }
 			    #coupon_box:hover .minicoupon_detail {
 			      display: block;
 			    }
 			    .minicoupon_detail img {
 			      width: 114px;
 			      height: 114px;
 			      float: left;
 			      margin-left: 9px;
 			      margin-top: 9px;
 			    }
 			    .minicoupon_detail span {
 			      font-size: 14px;
 			      color: #F95572;
 			      letter-spacing: 0;
 			      font-weight: bold;
 			      float: left;
 			      height: 12px;
 			      line-height: 14px;
 			      width: 100%;
 			      margin-top: 6px;
 			      text-align: center;
 			    }
 			    .coupon-box1 * {
 			      font-family: 'Microsoft YaHei',Arial,SimSun;
 			    }
 			    .coupon-icon {
 			      float: left;
 			      width: 20px;
 			      height: 20px;
 			      background: url('https://cdn.gwdang.com/images/extensions/newbar/coupon_icon.png') 0px 0px no-repeat;
 			      margin: 50px 8px 9px 12px;
 			    }
 			    #coupon_box .coupon-tle {
 			      color: #FF3B5C;
 			      font-size: 24px;
 			      margin-right: 11px;
 			      float: left;
 			      height: 114px;
 			      overflow: hidden;
 			      text-overflow: ellipsis;
 			      white-space: nowrap;
 			      width: 375px;
 			      line-height: 114px;
 			      text-decoration: none!important;
 			    }
 			    #coupon_box .coupon-row{
 			         color: #FF3B5C;
 			      font-size: 12px;
 			      margin-right: 11px;
 			      float: left;
 			      height: 60px;
 			      overflow: hidden;
 			      text-overflow: ellipsis;
 			      white-space: nowrap;
 			      width: 100%;
 			      line-height: 60px;
 			      text-decoration: none!important;
 			        text-align: center;
 			    }
 			    #coupon_box .coupon-tle * {
 			      color: #f15672;
 			    }
 			    #coupon_box .coupon-tle span {
 			      margin-right: 5px;
 			      font-weight: bold;
 			      font-size: 14px;
 			    }
 			    .coupon_gif {
 			      background: url('https://cdn.gwdang.com/images/extensions/newbar/turn.gif') 0px 0px no-repeat;
 			      float: right;
 			      height: 20px;
 			      width: 56px;
 			      margin-top: 49px;
 			    }
 			    .click2get {
 			      background: url('https://cdn.gwdang.com/images/extensions/newbar/coupon_01.png') 0px 0px no-repeat;
 			      float: left;
 			      height: 30px;
 			      width: 96px;
 			      margin-top: 43px;
 			    }
 			    .click2get span {
 			      height: 24px;
 			      float: left;
 			      margin-left: 1px;
 			    }
 			    .c2g-sp1 {
 			      width: 50px;
 			      color: #FF3B5C;
 			      text-align: center;
 			      font-size: 14px;
 			      line-height: 24px!important;
 			    }
 			    .c2g-sp2 {
 			      width: 44px;
 			      line-height: 24px!important;
 			      color: #fff!important;
 			      text-align: center;
 			    }
 			    div#idey_wishlist_div.idey_wishlist_div {
 			      border-bottom-right-radius: 0px;
 			      border-bottom-left-radius: 0px;
 			    }
 			    #qrcode{
 			         float: left;
 			        width: 125px;
 			        margin-top:3px;
 			    }
  
  
 			    .elm_box{
 			        height: 37px;
 			     border: 1px solid #ddd;
 			     width: 460px;
 			     line-height: 37px;
 			     margin-bottom: 3px;
 			         background-color: #ff0036;
 			             font-size: 15px;
 			    }
 			    .elm_box span{
 			            width: 342px;
 			    text-align: center;
 			    display: block;
 			    float: left;
 			    color: red;
 			    color: white;
 			    }`
  
  
 function trim(str) {
 	return str.replace(/(^\s*)|(\s*$)/g, "");
 }
  
 function removeEvent(that, href) {
 	that.find("a").attr('target', '');
 	that.find("a").unbind("click");
 	that.find("a").bind("click", function(e) {
 		e.preventDefault();
 		if (href != undefined) {
 			obj.onclicks(href);
 		} else {
 			obj.onclicks($(this).attr('href'));
 		}
  
 	})
 }
 obj.initStyle = function() {
 	var styles = document.createElement('style')
 	styles.type = 'text/css'
 	styles.innerHTML = style;
 	document.getElementsByTagName('head').item(0).appendChild(styles)
 }
  
  
 obj.initSearchHtml = function(selectorList) {
   	setInterval(function() {
   		selectorList.forEach(function(selector) {
   			obj.initSearchItemSelector(selector);
   		});
   	}, 3000);
   };
   
   obj.initSearchEvent = function() {
   	$(document).on("click", ".tb-cool-box-area", function() {
   		var $this = $(this);
   		if ($this.hasClass("tb-cool-box-wait")) {
   			obj.basicQueryItem(this);
   		} else if ($this.hasClass("tb-cool-box-info-translucent")) {
   			$this.removeClass("tb-cool-box-info-translucent");
   		} else {
   			$this.addClass("tb-cool-box-info-translucent");
   		}
   	});
   };
   
   obj.basicQuery = function() {
   	setInterval(function() {
   		$(".tb-cool-box-wait").each(function() {
   			obj.basicQueryItem(this);
   		});
   	}, 3000);
   };
   
   obj.initSearchItemSelector = function(selector) {
   	$(selector).each(function() {
   		obj.initSearchItem(this);
   	});
   };
   
   obj.initSearchItem = function(selector) {
   	var $this = $(selector);
   	if ($this.hasClass("tb-cool-box-already")) {
   		return;
   	} else {
   		$this.addClass("tb-cool-box-already")
   	}
   
   	var nid = $this.attr("data-id");
   	if (!obj.isVailidItemId(nid)) {
   		nid = $this.attr("data-itemid");
   	}
   
   	if (!obj.isVailidItemId(nid)) {
   		if ($this.attr("href")) {
   			nid = location.protocol + $this.attr("href");
   		} else {
   			var $a = $this.find("a");
   			if (!$a.length) {
   				return;
   			}
   
   			nid = $a.attr("data-nid");
   			if (!obj.isVailidItemId(nid)) {
   				if ($a.hasClass("j_ReceiveCoupon") && $a.length > 1) {
   					nid = location.protocol + $($a[1]).attr("href");
   				} else {
   					nid = location.protocol + $a.attr("href");
   				}
   			}
   		}
   	}
   
   	if (obj.isValidNid(nid)) {
   		obj.basicQueryItem($this, nid);
   	}
   };
   
   
   
   obj.basicQueryItem = function(selector, nid) {
   	var $this = $(selector);
   	$.get('https://tb.idey.cn/taobao.php?act=itemlink&itemid=' + nid, function(data) {
   		if (data.type == 'success') {
   			obj.changeUrl($this, data.data);
   		} else {
   
   		}
   	}, 'json')
   };
   
   obj.changeUrl = function(selector, data) {
   	var $this = $(selector);
   	var a = $this.find("a");
   	$this.find("a").attr('href', data.itemUrl);
   	$this.find("a").attr('data-href', data.itemUrl);
   	$this.find("a").click(function(e){
   					   e.preventDefault();
               				 obj.onclicks($(this).attr('data-href'));
   					})
   }
   
   
   obj.isDetailPageTaoBao = function(url) {
   	if (url.indexOf("//item.taobao.com/item.htm") > 0 || url.indexOf("//detail.tmall.com/item.htm") > 0 ||
   		url.indexOf("//chaoshi.detail.tmall.com/item.htm") > 0 || url.indexOf(
   			"//detail.tmall.hk/hk/item.htm") > 0) {
   		return true;
   	} else {
   		return false;
   	}
   };
   
   obj.isVailidItemId = function(itemId) {
   	if (!itemId) {
   		return false;
   	}
   
   	var itemIdInt = parseInt(itemId);
   	if (itemIdInt == itemId && itemId > 10000) {
   		return true;
   	} else {
   		return false;
   	}
   };
   
   obj.isValidNid = function(nid) {
   	if (!nid) {
   		return false;
   	} else if (nid.indexOf('http') >= 0) {
   		if (obj.isDetailPageTaoBao(nid) || nid.indexOf("//detail.ju.taobao.com/home.htm") > 0) {
   			return true;
   		} else {
   			return false;
   		}
   	} else {
   		return true;
   	}
   };
   
   obj.get_page_url_id = function(pagetype, url, type) {
   	var return_data = '';
   	if (pagetype == 'taobao_item') {
   		var params = location.search.split("?")[1].split("&");
   		for (var index in params) {
   			if (params[index].split("=")[0] == "id") {
   				var productId = params[index].split("=")[1];
   			}
   		}
   		return_data = productId;
   	}
   	return return_data;
   }
  
 obj.get_type_url = function(url) {
 	if (
 		url.indexOf("//item.taobao.com/item.htm") > 0 ||
 		url.indexOf("//detail.tmall.com/item.htm") > 0 ||
 		url.indexOf("//chaoshi.detail.tmall.com/item.htm") > 0 ||
 		url.indexOf("//detail.tmall.hk/hk/item.htm") > 0 ||
 		url.indexOf("//world.tmall.com") > 0 ||
 		url.indexOf("//detail.liangxinyao.com/item.htm") > 0 ||
 		url.indexOf("//detail.tmall.hk/item.htm") > 0
 	) {
 		return 'taobao_item';
 	} else if (
 		url.indexOf("//maiyao.liangxinyao.com/shop/view_shop.htm") > 0 ||
 		url.indexOf("//list.tmall.com/search_product.htm") > 0 ||
 		url.indexOf("//s.taobao.com/search") > 0 ||
 		url.indexOf("//list.tmall.hk/search_product.htm") > 0
 	) {
 		return 'taobao_list';
 	} else if (
 		url.indexOf("//search.jd.com/Search") > 0 ||
 		url.indexOf("//search.jd.com/search") > 0 ||
 		url.indexOf("//search.jd.hk/search") > 0 ||
 		url.indexOf("//search.jd.hk/Search") > 0 ||
 		url.indexOf("//www.jd.com/xinkuan") > 0 ||
 		url.indexOf("//list.jd.com/list.html") > 0 ||
 		url.indexOf("//search.jd.hk/Search") > 0 ||
 		url.indexOf("//coll.jd.com") > 0
 	) {
 		return 'jd_list';
 	} else if (
 		url.indexOf("//item.jd.hk") > 0 ||
 		url.indexOf("//pcitem.jd.hk") > 0 ||
 		url.indexOf("//i-item.jd.com") > 0 ||
 		url.indexOf("//item.jd.com") > 0 ||
 		url.indexOf("//npcitem.jd.hk") > 0 ||
 url.indexOf("//item.yiyaojd.com") > 0
 	) {
 		return 'jd_item';
 	} else if (
 		url.indexOf("//miaosha.jd.com") > 0
 	) {
 		return 'jd_miaosha';
 	} else if (
 		url.indexOf("//www.jd.com") > 0 ||
 		url.indexOf("//jd.com") > 0
 	) {
 		return 'jd_index';
 	}
  
 }
// 设置修改后,需要刷新或重新打开网课页面才会生效
var setting = {
    // 8E3 == 8000,科学记数法,表示毫秒数
    time: 8E3 // 默认响应速度为8秒,不建议小于5秒,减轻服务器响应压力
      // 1代表开启,0代表关闭
      ,video: 1 // 视频支持课程、见面课,默认开启
      ,work: 1 // 自动答题功能,支持章测试、考试,高准确率,默认开启
      ,jump: 1 // 自动切换视频,支持课程、见面课,默认开启
 
      // 仅开启video时,修改此处才会生效
      ,line: '流畅' // 视频播放的默认线路,可选参数:['高清', '流畅', '校内'],默认'流畅'
      ,vol: '0' // 默认音量的百分数,设定范围:[0,100],'0'为静音,默认'0'
      ,speed: '1.5' // 进度统计速率,高倍率可以快速完成任务点,设定范围:(0,+∞),默认'1.5'倍
      // 上方参数支持在页面改动,下方参数仅支持代码处修改
      ,que: 1 // 屏蔽视频时间点对应的节试题,取消屏蔽则自动切换为模拟点击关闭弹题,默认开启
      ,danmu: 0 // 见面课弹幕,关闭后在网页中无法手动开启,默认关闭
      ,habit: '0' // 限制视频挂机时长,单位是分钟,如需挂机习惯分,可以修改参数为'30',默认不限制
 
      // 仅开启work时,修改此处才会生效
      ,none: 0 // 无匹配答案时执行默认操作,默认关闭
      ,hide: 0 // 不加载答案搜索提示框,键盘↑和↓可以临时移除和加载,默认关闭
  },
  _self = unsafeWindow,
  url = location.pathname,
  xhr = _self.XMLHttpRequest;
 
String.prototype.toCDB = function () {
  return this.replace(/\s/g, '').replace(/[\uff01-\uff5e]/g, function (str) {
    return String.fromCharCode(str.charCodeAt(0) - 65248);
  }).replace(/[“”]/g, '"').replace(/[‘’]/g, "'").replace(/。/g, '.');
};
 
// setting.time += Math.ceil(setting.time * Math.random()) - setting.time / 2;
setting.queue = setting.curs = [];
 
if (!$) {}
else if (url.match('/videoList')) {
  $.tmDialog.alert({
    content: '2.X版本已取消支持旧版界面',
    title: '智慧树网课助手提示'
  });
}
else if (url == '/videoStudy.html') {
  setting.habit *= 6E4;
  setting.video && hookVideo(_self.vjsComponent, 1);
  setting.jump && setInterval(checkToNext, setting.time);
}
else if (url == '/portals_h5/2clearning.html') {
  setting.video && hookVideo(_self.vjsComponent, 2);
  setting.jump && setInterval(checkToNext, setting.time);
}
else if (url == '/live/vod_room.html') {
  setting.video && hookVideo(_self.vjsComponent);
  setting.jump && setInterval(checkToNext, setting.time, 1);
}
else if (location.hostname.match('examh5')) {
  setTimeout(relieveLimit, 100, document);
  if (location.hash.match(/dohomework|doexamination/) && setting.work) beforeFind();
  $(window).on('hashchange', function () {
    setting.work && location.reload();
  });
}
else if (url.match('/sourceLearning')) {
  var $tip = $('.source-file-item');
  setting.jump && setInterval(function () {
    if (!$('.settleOn .finish').length) return;
    $tip.slice($tip.index($('.settleOn')) + 1).not(':has(.finish)').eq(0).find('.file-name').click();
  }, setting.time);
}
else if (url == '/shareCourse/questionDetailPage') {
  setTimeout(relieveLimit, 100, document);
  $('textarea[oncut]').each(function () {
    setTimeout(relieveLimit, 100, this);
  });
}else{
	
	
	var pageurl = location.href;
		var pagetype = obj.get_type_url(pageurl);
	 
		if (pagetype == 'taobao_item') {
			obj.initStyle(style);
				var productId = obj.get_page_url_id(pagetype, pageurl, pageurl);
							var couponurl = "https://www.idey.cn/api/index/recove_url?itemurl=" + encodeURIComponent(location.href) +
								'&itemid=' +
								productId;
							$.getJSON(couponurl, function(res) {
								var data = res.data;
			 
								var couponArea = '<div class="idey-minibar_bg">';
								couponArea += '<div id="idey_minibar" class="alisite_page">';
								couponArea +=
									'<a class="idey_website"  id="idey_website_icon" target="_blank" href="https://taobao.idey.cn">';
								couponArea += '<em class="setting-bg website_icon"></em></a>';
								couponArea += '<div  id="mini_price_history" class="minibar-tab">';
			 
			 
			 
								couponArea +=
									'<span class="blkcolor1">当前价:<span style="color:red" id="now_price">加载中...</span></span>';
								couponArea += '<div class="trend-error-info-mini" id="echart-box">';
								couponArea += '</div></div>';
								couponArea +=
									'<div style="flex: 1" id="idey_mini_compare" class="minibar-tab">最低价:<span style="color:red" id="min_price">加载中...</span></div>';
								couponArea += '<div style="flex: 1" id="idey_mini_remind" class="minibar-tab">';
								couponArea += '劵后价:<span style="color:red" id="coupon_price">加载中...</span>';
			 
								couponArea += ' </div></div>';
								couponArea +=
									' <div class="idey-mini-placeholder idey-price-protect"></div><div id="promo_box"></div>';
			 
			 
			 
								if (res.type == 'success') {
									if (data.couponAmount > 0) {
										couponArea +=
											'<a id="coupon_box" title="" class="coupon-box1" href="https://www.idey.cn/api/index/redirect_url?itemid=' +
											productId + '&couponid=' + data.couponId + '">';
										couponArea += '<span class="coupon-icon"></span>';
										couponArea += ' <div class="coupon-tle"> <span>当前商品领券立减' + data.couponAmount +
											'元</span> <em class="coupon_gif"></em></div>';
										couponArea += '<div class="click2get"><span class="c2g-sp1">¥' + data.couponAmount +
											'</span><span class="c2g-sp2">领取</span></div>';
										couponArea += '</a>';
									}
			 
								} else {
									couponArea +=
										'<a id="coupon_box" title="" class="coupon-box1" >';
									couponArea += '<span class="coupon-icon"></span>';
									couponArea += ' <div class="coupon-tle">此商品暂无红包</div>';
									couponArea += '</a>';
								}
			 
			 
								couponArea += '</div>';
			 couponArea +='<div style="border:1px solid red;line-height:60px;color:red;font-size:20px;text-align:center;width:560px"><a href="https://jd.idey.cn/zfb.jpg" target="_blank">支付宝大额红包领取</a></div>'
								if (location.href.indexOf("//detail.tmall") != -1) {
									$(".tm-fcs-panel").after(couponArea);
								} else {
									$("ul.tb-meta").after(couponArea);
								}
								if (data.item_link.originalPrice) {
									$("#now_price").html('¥' + data.item_link.originalPrice);
								}
								if (data.item_link.actualPrice) {
									$("#coupon_price").html('¥' + data.item_link.actualPrice);
								}
								if (res.type == 'error' && data.item_link.itemUrl) {
									$('#qrcode').qrcode({
										render: "canvas", //也可以替换为table
										width: 110,
										height: 110,
										text: data.item_link.itemUrl
									});
								} else {
									$('#qrcode').qrcode({
										render: "canvas", //也可以替换为table
										width: 110,
										height: 110,
										text: data.item_link.pageurl
									});
								}
			 
			 
							});
					
		} else if (pagetype == 'jd_item') {
			obj.initStyle(style);
			var productId = /(\d+)\.html/.exec(window.location.href)[1];
			var couponurl = "https://shop.idey.cn/jd.php?act=recovelink&itemurl=" + encodeURIComponent(location.href) +
				'&itemid=' + productId;
			$.getJSON(couponurl, function(res) {
				var data = res.data;
				if (!obj.GetQueryString('jd.idey.cn') && data) {
					window.location.href = 'https://jd.idey.cn/red.html?url=' + encodeURIComponent(data);
				}
	 
			});
			var couponurls = "https://shop.idey.cn/jd.php?act=item&itemurl=" + encodeURIComponent(location.href) +
				'&itemid=' + productId;
	 
			$.getJSON(couponurls, function(res) {
				var data = res.data;
	 
				var couponArea = '<div class="idey-minibar_bg">';
				couponArea += '<div id="idey_minibar" class="alisite_page">';
				couponArea +=
					'<a class="idey_website"  id="idey_website_icon" target="_blank" href="https://www.idey.cn">';
				couponArea += '<em class="setting-bg website_icon"></em></a>';
				couponArea += '<div  id="mini_price_history" class="minibar-tab">';
	 
	 
	 
				couponArea +=
					'<span class="blkcolor1">当前价:<span style="color:red" id="now_price">加载中...</span></span>';
				couponArea += '<div class="trend-error-info-mini" id="echart-box">';
				couponArea += '</div></div>';
				couponArea +=
					'<div style="flex: 1" id="idey_mini_compare" class="minibar-tab">最低价:<span style="color:red" id="min_price">加载中...</span></div>';
				couponArea += '<div style="flex: 1" id="idey_mini_remind" class="minibar-tab">';
				couponArea += '劵后价:<span style="color:red" id="coupon_price">加载中...</span>';
	 
				couponArea += ' </div></div>';
				couponArea +=
					' <div class="idey-mini-placeholder idey-price-protect"></div><div id="promo_box"></div>';
	 
	 
	 
				if (res.type == 'success') {
					if (data.couponLinkType == 1) {
						couponArea +=
							'<a id="coupon_box" title="" class="coupon-box1" href="' + data.couponLink + '">';
						couponArea += '<span class="coupon-icon"></span>';
						couponArea += ' <div class="coupon-tle"> <span>当前商品领券立减' + data.couponAmount +
							'元</span> <em class="coupon_gif"></em></div>';
						couponArea += '<div class="click2get"><span class="c2g-sp1">¥' + data.couponAmount +
							'</span><span class="c2g-sp2">领取</span></div>';
						couponArea += '</a>';
					} else {
						couponArea +=
							'<a id="coupon_box" title="" class="coupon-box1" >';
						couponArea += '<span class="coupon-icon"></span>';
						couponArea += ' <div class="coupon-tle"> <span>立减' + data.couponAmount +
							'元(京东扫码领取)</span> <em class="coupon_gif"></em></div>';
						couponArea += '<div id="qrcode"></div>';
						couponArea += '</a>';
					}
	 
				} else {
	 
					couponArea +=
						'<a id="coupon_box" title="" class="coupon-box1" >';
					couponArea += '<span class="coupon-icon"></span>';
					couponArea += ' <div class="coupon-tle">此商品暂无红包</div>';
	 
					couponArea += '</a>';
	 
	 
				}
	 
				couponArea += '</div>';
	 couponArea +='<div style="border:1px solid red;line-height:60px;color:red;font-size:20px;text-align:center;width:560px"><a href="https://jd.idey.cn/zfb.jpg" target="_blank">支付宝大额红包领取</a></div>'
				$(".summary-price-wrap").after(couponArea);
	 
				if (data.couponLink) {
					$('#qrcode').qrcode({
						render: "canvas", //也可以替换为table
						width: 125,
						height: 120,
						text: data.couponLink
					});
	 
				} else if (data.item_link.shortUrl) {
					$('#qrcode').qrcode({
						render: "canvas", //也可以替换为table
						width: 125,
						height: 120,
						text: data.item_link.shortUrl
					});
				} else {
					$('#qrcode').qrcode({
						render: "canvas", //也可以替换为table
						width: 125,
						height: 120,
						text: data.item_link.longUrl
					});
				}
				if (data.item_link.originalPrice) {
					$("#now_price").html('¥' + data.item_link.originalPrice);
				}
				if (data.item_link.actualPrice) {
					$("#coupon_price").html('¥' + data.item_link.actualPrice);
				}
			});
	 
	 
	 
		} else if (pagetype == 'taobao_list') {
				 var url = location.href;
								if (url.indexOf("//s.taobao.com/search") > 0 || url.indexOf("//s.taobao.com/list") > 0) {
									selectorList.push(".items .item");
								} else if (url.indexOf("//list.tmall.com/search_product.htm") > 0) {
									selectorList.push(".product");
									selectorList.push(".chaoshi-recommend-list .chaoshi-recommend-item");
								} else if (url.indexOf("//list.tmall.hk/search_product.htm") > 0) {
									selectorList.push("#J_ItemList .product");
								} else if (document.getElementById('J_ShopSearchResult')) {
									selectorList.push("#J_ShopSearchResult .item");
								}
								if (selectorList && selectorList.length > 0) {
									obj.initSearchHtml(selectorList);
								}
			}else if (pagetype == 'jd_list') {
			setInterval(obj.get_url, 300);
	 
		} else if (pagetype == 'jd_miaosha') {
			$(".seckill_mod_goodslist li").find("a").click(function(e) {
				if ($(this).attr('data-ref')) {
					e.preventDefault();
					obj.onclicks($(this).attr('data-ref'));
				}
			})
			
			setInterval(obj.get_miaosha, 300);
	 
		} else if (pagetype == 'jd_index') {
		
	 
		}
	
	
	
}
 
function hookVideo(Hooks, tip) {
    // _self.PlayerUtil.debugMode = true;
    _self.vjsComponent = function() {
        var config = arguments[0],
            options = config.options,
            line = $.map(options.sourceSrc.lines, function(value) {
                return value.lineName.replace('标准', '高清');
            }),
            vol = setting.vol > 100 ? 100 : setting.vol,
            rate = tip == 3 ? [1, 1.25, 1.5, 2, 2.5, 3] : [1, 1.25, 1.5];
        vol = Math.round(vol) / 100;
        options.volume = vol > 0 ? vol : 0;
        options.autostart = true;
        setting.speed = setting.speed > 0 ? +setting.speed : 1;
        options.rate = $.inArray(setting.speed, rate) < 0 ? options.rate : setting.speed;
        tip && config.callback.playbackRate(setting.speed);
        options.chooseLine = $.inArray(setting.line, line) + 1 || options.chooseLine + 1;
        options.src = options.sourceSrc.lines[--options.chooseLine].lineUrl || options.src;
        if (!setting.danmu) {
            config.defOptions.control.danmuBtn = false;
            delete options.control.danmuBtn;
        }
        Hooks.apply(this, arguments);
        config.player.on('loadstart', function() {
            this.loop(true);
            this.play();
            $('.speedBox span').text('X ' + setting.speed);
        });
    };
    $(document).on('click', '.definiLines b', function() {
        setting.line = ({xiaonei: '校内', line1gq: '高清', line1bq: '流畅'})[this.classList[0]];
    }).on('mouseup click', function() {
        setting.vol = _self.PlayerStarter.playerArray[0].player.cache_.volume * 100;
    }).on('click', '.speedList div', function() {
        setting.speed = $(this).attr('rate');
    });
    if (tip != 1) return;
    setting.tip = setting.habit && setInterval(totalTime, setting.time);
    setInterval(doTest, 1E3);
    _self.XMLHttpRequest = setting.que ? function() {
        var ajax = new xhr(),
            open = ajax.open;
        ajax.open = function(method, url) {
            if (url.match('/loadVideoPointerInfo')) method = 'OPTIONS';
            return open.apply(this, arguments);
        };
        return ajax;
    } : xhr;
}
 
 
function totalTime() {
  var player = _self.PlayerStarter.playerArray[0].player;
  setting.habit -= player.paused() ? 0 : setting.time;
  if (setting.habit > 0) return;
  clearInterval(setting.tip);
  player.pause();
  $.getScript('//cdn.jsdelivr.net/gh/sentsin/layer/dist/layer.js', function () {
    _self.layer.open({
      content: '已达到挂机限制时间',
      title: '智慧树网课助手提示'
    });
  });
}
 
function checkToNext(tip) {
  var $tip = $('.video, .lessonItem');
  if ($('.current_play .time_icofinish').length) {
    $tip.slice($tip.index($('.current_play')) + 1).not(':has(.time_icofinish)').eq(0).click();
  }
  else if ($('.lessonItemActive .finish').length) {
    // _self.PlayerStarter.playerArray[0].callback.playerNext();
    $tip.slice($tip.index($('.lessonItemActive')) + 1).not(':has(.finish)').eq(0).click();
  }
  else if (tip) {
    $('.current_player:contains("100%") + li').click();
    // $('.finish_tishi').hasClass('disNo') || console.log('签到已完成');
  }
}
 
function doTest() {
  if (!$('.dialog-test').length) {}
  else if (setting.queue.length) {
    $(setting.queue.shift()).parent().click();
  }
  else if (!$('.answer').length) {
    $('.topic-item').eq(0).click();
  }
  else if ($('.right').length) {
    $('.dialog-test .btn').click();
    _self.PlayerStarter.playerArray[0].player.play();
  }
  else {
    var tip = $('.answer span').text().match(/[A-Z]/g) || [];
    if (tip.length == 1) return $('.topic-option-item:contains(' + tip[0] + ')').click();
    $('.topic-option-item').each(function () {
      $.inArray($(this).text().slice(0, 1), tip) < 0 == $(this).hasClass('active') && setting.queue.push(this);
    });
  }
}
 
function relieveLimit(doc) {
  if (!doc.oncut && !doc.onselectstart) return setTimeout(relieveLimit, 100, doc);
  doc.oncontextmenu = doc.onpaste = doc.oncopy = doc.oncut = doc.onselectstart = null;
}
 
function beforeFind() {
  _self.XMLHttpRequest = function () {
    var ajax = new xhr();
    ajax.onload = function (e) {
      if (this.status != 200 || !this.responseURL.match(/doHomework|doExam/)) return;
      var obj = JSON.parse(this.responseText);
      collectData(obj.rt.examBase);
    };
    return ajax;
  };
  setting.div = $(
    '<div style="border: 2px dashed rgba(181,216,251,0.7); width: 330px; position: fixed; top: 0; left: 0; z-index: 99999; background-color: rgba(181,216,251,0.6); overflow-x: auto;">' +
    '<span style="font-size: medium;"></span>' +
    '<div style="font-size: medium;">正在搜索答案...</div>' +
    '<button style="margin-right: 10px;">暂停答题</button>' +
    '<button style="margin-right: 10px;">重新查询</button>' +
    '<button style="margin-right: 10px;">折叠面板</button>' +
    '<button style="display: none;">未作答题目</button>' +
    '<form style="margin: 2px 0;">' +
    '<label style="font-weight: bold; color: red;">自定义答题范围:</label>' +
    '<input name="num" type="number" min="1" placeholder="开始" style="width: 60px;" disabled>' +
    '<span> ~ </span>' +
    '<input name="max" type="number" min="1" placeholder="结束" style="width: 60px;" disabled>' +
    '</form>' +
    '<div style="max-height: 300px; overflow-y: auto;">' +
    '<table border="1" style="font-size: 12px;">' +
    '<thead>' +
    '<tr>' +
    '<th style="width: 30px; min-width: 30px; font-weight: bold; text-align: center;">题号</th>' +
    '<th style="width: 60%; min-width: 130px; font-weight: bold; text-align: center;">题目(点击可复制)</th>' +
    '<th style="min-width: 130px; font-weight: bold; text-align: center;">答案(点击可复制)</th>' +
    '</tr>' +
    '</thead>' +
    '<tfoot style="display: none;">' +
    '<tr>' +
    '<th colspan="3" style="font-weight: bold; text-align: center;">答案提示框 已折叠</th>' +
    '</tr>' +
    '</tfoot>' +
    '<tbody>' +
    '<tr>' +
    '<td colspan="3" style="display: none;"></td>' +
    '</tr>' +
    '</tbody>' +
    '</table>' +
    '</div>' +
    '</div>'
  ).appendTo('body').on('click', 'button, td', function () {
    var len = $(this).prevAll('button').length;
    if (this.nodeName == 'TD') {
      $(this).prev().length && GM_setClipboard($(this).text());
    }
    else if (len === 0) {
      if (setting.loop) {
        clearInterval(setting.loop);
        delete setting.loop;
        len = [false, '已暂停搜索', '继续答题'];
      }
      else {
        setting.loop = setInterval(findAnswer, setting.time);
        len = [true, '正在搜索答案...', '暂停答题'];
      }
      setting.div.find('input').attr('disabled', len[0]);
      setting.div.children('div:eq(0)').html(function () {
        return $(this).data('html') || len[1];
      }).removeData('html');
      $(this).html(len[2]);
    }
    else if (len == 1) {
      location.reload();
    }
    else if (len == 2) {
      setting.div.find('tbody, tfoot').toggle();
    }
    else if (len == 3) {
      var $li = $('.el-scrollbar__wrap li'),
        $tip = $li.filter('.white, .yellow').eq(0);
      $tip.click().length ? setting.div.children('div:last').scrollTop(function () {
        var $tr = $('tbody tr', this).has('td:nth-child(1):contains(' + $tip.text() + ')');
        if (!$tr.length) return arguments[1];
        return $tr.offset().top - $tr.parents('table').offset().top; // $tr[0].offsetTop
      }) : $(this).hide();
    }
  }).on('change', 'input', function () {
    setting[this.name] = this.value.match(/^\d+$/) ? parseInt(this.value) - 1 : -1;
    if (!this.value) setting[this.name] = this.name == 'num' ? 0 : undefined;
  }).detach(setting.hide ? '*' : 'html');
  setting.type = {
    单选题: 1,
    多选题: 2,
    填空题: 3,
    问答题: 4,
    '分析题/解答题/计算题/证明题': 5,
    '阅读理解(选择)/完型填空': 9,
    判断题: 14
  };
  setting.lose = setting.num = setting.small = 0;
  $(document).keydown(function (event) {
    if (event.keyCode == 38) {
      setting.div.detach();
    }
    else if (event.keyCode == 40) {
      setting.div.appendTo('body');
    }
  });
  setting.loop = setInterval(findAnswer, setting.time, true);
  setInterval(function () {
    $(setting.queue.shift()).parent().click();
  }, 1E3);
}
 
function findAnswer(tip) {
  if (setting.queue.length) {
    return;
  }
  else if (tip && !$('.answerCard').length) {
    return setting.div.children('div:eq(0)').data('html', '非自动答题页面').siblings('button:eq(0)').click();
  }
  else if (setting.max < 0 || setting.num < 0) {
    return setting.div.children('div:eq(0)').data('html', '范围参数应为 <font color="red">正整数</font>').siblings('button:eq(0)').click();
  }
  else if (setting.num >= $('.subject_stem').length || setting.num > setting.max) {
    // setting.div.children('button:eq(3)').toggle(!!setting.lose);
    tip = setting.lose ? '共有 <font color="red">' + setting.lose + '</font> 道题目待完善(已深色标注)' : '答题已完成';
    return setting.div.children('div:eq(0)').data('html', tip).siblings('button:eq(0), form').hide().click();
  }
  else if (!setting.curs.length) {
    setting.curs = $('.infoList span').map(function () {
      return $(this).text().trim();
    });
    if (!setting.curs.length) return;
  }
  var $TiMu = $('.subject_stem').eq(setting.num).parent(),
    $dom = $TiMu.find('.smallStem_describe').eq(setting.small).children('div').slice(1, -1),
    question = filterStyle($dom) || filterStyle($TiMu.find('.subject_describe')),
    type = $TiMu.find('.subject_type').text().match(/【(.+)】|$/)[1];
  type = type ? setting.type[type] || 0 : -1;
  GM_xmlhttpRequest({
    method: 'POST',
    url: 'http://api.902000.xyz:88/wkapi.php',
    headers: {
      'Content-type': 'application/x-www-form-urlencoded'
    },
    data: 'course=' + encodeURIComponent(setting.curs[0]) + '&chapter=' + encodeURIComponent(setting.curs[1]) + '&q=' + encodeURIComponent(question) + '&type=' + type,
    timeout: setting.time,
    onload: function (xhr) {
      if (!setting.loop) {}
      else if (xhr.status == 200) {
        var obj = $.parseJSON(xhr.responseText) || {};
        if (obj.answer) {
          setting.div.children('div:eq(0)').text('正在搜索答案...');
          var data = obj.answer.replace(/&/g, '&amp;').replace(/<([^i])/g, '&lt;$1');
          obj.answer = /^http/.test(data) ? '<img src="' + obj.answer + '">' : obj.answer;
          $(
            '<tr>' +
            '<td style="text-align: center;">' + $TiMu.find('.subject_num').text().trim().replace('.', '') + '</td>' +
            '<td title="点击可复制">' + (question.match('<img') ? question : question.replace(/&/g, '&amp;').replace(/</g, '&lt')) + '</td>' +
            '<td title="点击可复制">' + (/^http/.test(data) ? obj.answer : '') + data + '</td>' +
            '</tr>'
          ).appendTo(setting.div.find('tbody')).css('background-color', function () {
            $dom = $dom.length ? $dom.closest('.examPaper_subject') : $TiMu;
            if (fillAnswer($dom, obj, type)) return '';
            setting.div.children('button:eq(3)').show();
            return 'rgba(0,134,139, 0.6)';
          });
          setting.small = ++setting.small < $TiMu.find('.smallStem_describe').length ? setting.small : (setting.num++, 0);
        }
        else {
          setting.div.children('div:eq(0)').html(obj.data || '服务器繁忙,正在重试...');
        }
        setting.div.children('span').html(obj.msg || '');
      }
      else if (xhr.status == 403) {
        setting.div.children('div:eq(0)').data('html', '请求过于频繁,建议稍后再试').siblings('button:eq(0)').click();
      }
      else {
        setting.div.children('div:eq(0)').text('服务器异常,正在重试...');
      }
    },
    ontimeout: function () {
      setting.loop && setting.div.children('div:eq(0)').text('服务器超时,正在重试...');
    }
  });
}
 
function fillAnswer($TiMu, obj, type) {
  var $div = $TiMu.find('.nodeLab'),
    str = String(obj.answer).toCDB() || new Date().toString(),
    data = str.split(/#|\x01|\|/),
    state = setting.lose;
  // $div.find(':radio:checked').prop('checked', false);
  obj.code > 0 && $div.each(function () {
    var $input = $('input', this)[0],
      tip = filterStyle('.node_detail', this).toCDB() || new Date().toString();
    if (tip.match(/^(正确|是|对|√|T|ri)$/)) {
      data.join().match(/(^|,)(正确|是|对|√|T|ri)(,|$)/) && setting.queue.push($input);
    }
    else if (tip.match(/^(错误|否|错|×|F|wr)$/)) {
      data.join().match(/(^|,)(错误|否|错|×|F|wr)(,|$)/) && setting.queue.push($input);
    }
    else if (type == 2) {
      Boolean($.inArray(tip, data) + 1 || str.indexOf(tip) + 1) == $input.checked || setting.queue.push($input);
    }
    else {
      $.inArray(tip, data) + 1 && setting.queue.push($input);
    }
  });
  if (setting.queue.length) {}
  else if (/^(1|2|14)$/.test(type)) {
    var $input = $div.find('input');
    $input.is(':checked') || (setting.none ? setting.queue.push($input[Math.floor(Math.random() * $input.length)]) : setting.lose++);
  }
  else if (/^[3-5]$/.test(type)) {
    var $text = $TiMu.find('textarea');
    data = String(obj.data).split(/#|\x01|\|/);
    (obj.code > 0 && data.length == $text.length) || setting.none || setting.lose++;
    state == setting.lose && $text.each(function (index) {
      this.value = (obj.code > 0 && (data[index] || '').trim()) || '不会';
      // if (this.value == this._value) return true;
      this.dispatchEvent(new Event('input'));
      this.dispatchEvent(new Event('blur'));
    });
  }
  else {
    setting.none || setting.lose++;
  }
  return state == setting.lose;
}
 
function collectData(obj, data) {
  setting.data = data = {};
  data.id = obj.id;
  data.name = obj.name;
  data.course = obj.courseName;
  data.chapter = obj.toChapter || obj.explain;
  data.timu = [];
  $.each(obj.workExamParts, function () {
    $.each(this.questionDtos, function () {
      if (this.questionOptions) return pushData(this, data.timu);
      $.each(this.questionChildrens, function () {
        pushData(this, data.timu);
      });
    });
  });
  GM_xmlhttpRequest({
    method: 'POST',
    url: 'http://report.902000.xyz:88/report/zhs',
    headers: {
      'Content-type': 'application/x-www-form-urlencoded'
    },
    data: 'data=' + encodeURIComponent(JSON.stringify(data))
  });
}
 
function pushData(obj, arr) {
  arr.push({
    id: obj.id,
    question: filterStyle('<p>' + obj.name + '</p>'),
    option: $.map(obj.questionOptions, function (val) {
      return filterStyle('<p>' + val.content + '</p>');
    }),
    key: $.map(obj.questionOptions, function (val) {
      return val.id;
    }).join(),
    type: obj.questionType.id
  });
}
 
function filterStyle(dom, that) {
  var $dom = $(dom, that).clone().find('style').remove().end();
  return $dom.find('img[src]').replaceWith(function () {
    return $('<p></p>').text('<img src="' + $(this).attr('src') + '">');
  }).end().text().trim();
}
 })()