// ==UserScript== // @name 中色科技视频快进 // @namespace xcg // @version 5 // @grant none // @description 可快速看完中色Oa内的视频 可学习并答题(模拟试卷提交后可以学习),可学习并答题知识竞赛 // @author NianJiTao // @match *://127.0.0.1/t/* // @include *://tqm.caq.org.cn:8080/* // @include *://tqm.caq.org.cn/* // @match *://192.1.1.86/*Video.aspx* // @match *://192.1.1.86/*VideoList.aspx* // @match *://192.1.1.86/*VideoData.aspx* // @match *://192.1.1.86/*/Answer/answerlist.aspx* // @match *://192.1.1.86/*/Answer/Practice.aspx* // @match *://192.1.1.86/*/Answer/Formal.aspx* // @require http://cdn.bootcss.com/jquery/1.8.3/jquery.min.js // @require http://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js // @grant none // @downloadURL none // ==/UserScript== (function () { 'use strict'; var video = /Video.aspx/i; var VideoList = /VideoList.aspx/i; var VideoData = /VideoData.aspx/i; var caiurl = /answerlist/i; var caiurl2 = /Practice/i; var caiurl3 = /Formal.aspx/i; var loginAnswer = /loginAnswer/i; var caix = 0; var url = window.location.href; var Btn1 = '快进'; var Btn2 = '全部打开'; var Btn3 = '全部快进'; var Btn4 = '学习'; var Btn5 = '答题'; var Btn7 = '清除记忆'; var Btn6 = '已学习: 已答题: '; var Btn9 = '已答题: '; var I64BIT_TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-'.split(''); var Btn10 = '答题'; var Btn11 = '学习'; var Btn12 = '
'; var Btn13 = '显示答案'; var Btn14 = '
'; var Btn15 = '导入答案'; //哈希算法 function hash3(input) { var hash = 5381; var i = input.length - 1; if (typeof input == 'string') { for (; i > - 1; i--) hash += (hash << 5) + input.charCodeAt(i); } else { for (; i > - 1; i--) hash += (hash << 5) + input[i]; } var value = hash & 2147483647; var retValue = ''; do { retValue += I64BIT_TABLE[value & 63]; } while (value >>= 6); return retValue; } //保存答案 function save2(name, value2) { if (window.localStorage) { localStorage.setItem(name, value2); } else { $.cookie(name, value2, 3); } } //读取答案 function read2(name) { var m2 = ''; if (window.localStorage) { if (localStorage.hasOwnProperty(name)) { m2 = localStorage.getItem(name); } } else { m2 = $.cookie(name); } return m2; } function css2(name) { name.css({ 'font-size': '30px', 'margin': '5 5px', }); } //在视频播放页面添加快进按钮 if (video.test(url)) { var title = $('body') if (title.length !== 0) { title.after(Btn1); $('#fastBtn').css({ 'font-size': '30px', 'display': 'inline-block', 'height': '40px', 'line-height': '40px', 'line-width': '80px', 'margin': '2 5px', 'vertical-align': 'bottom' }); } } //在竞赛页面添加答题按钮 if (loginAnswer.test(url)) { var title = $('#trainExamName') if (title.length !== 0) { title.after(Btn6).after(Btn11).after(Btn10); css2($('#fastBtn10')); css2($('#fastBtn11')); } var title = $('#handPaper') if (title.length !== 0) { title.parent().after(Btn14).after(Btn15).after(Btn12).after(Btn13); css2($('#fastBtn15')); css2($('#fastBtn13')); $('#fastBtn12').css({ 'width': '1100px', }); $('#fastBtn14').css({ 'width': '1100px', }); } } //在视频列表页面添加全播放,全快进 if (VideoList.test(url)) { var title = $('.Grid'); if (title.length !== 0) { title.after(Btn3).after(Btn2); css2($('#fastBtn2')); css2($('#fastBtn3')); } } //在视频列表页面添加全播放,全快进 if (VideoData.test(url)) { var title = $('.Grid'); if (title.length !== 0) { title.after(Btn3).after(Btn2); css2($('#fastBtn2')); css2($('#fastBtn3')); } } //在模拟答案页面添加学习,答题 if (caiurl.test(url)) { var title = $('#table1').find('[id=\'HyperLink1\']'); if (title.length !== 0) { title.after(Btn6).after(Btn7).after(Btn5).after(Btn4); css2($('#fastBtn4')); css2($('#fastBtn5')); css2($('#fastBtn7')); } } //在模拟考试页面添加 答题 if (caiurl2.test(url)) { var title = $('#table1').find('[align=\'center\']'); if (title.length !== 0) { title.append(Btn5).append(Btn9); css2($('#fastBtn5')); } } //在正式考试页面添加 答题 if (caiurl3.test(url)) { var title = $('#table1').find('[align=\'center\']'); if (title.length !== 0) { title.append(Btn5).append(Btn9); css2($('#fastBtn5')); } } //在知识竞赛答题页面添加 答题 //清除记忆答案 $('#fastBtn7').on('click', function () { localStorage.clear(); }); //快进 $('#fastBtn').on('click', function () { var url3 = url.replace(/video/i, 'SetFinish'); window.open(url3); }); //全部打开 $('#fastBtn2').on('click', function () { var test = $('.Grid').find('a'); test.each(function () { var url4 = $(this).attr('href'); window.open(url4); }) }); //全部快进 $('#fastBtn3').on('click', function () { var test = $('.Grid').find('a'); test.each(function () { var url4 = $(this).attr('href').replace(/video/i, 'SetFinish'); window.open(url4); }) }); //学习 $('#fastBtn4').on('click', function () { var test = $('#DataList1').find('[id=\'table2\']'); test.each(function () { var s10 = $(this).find('span').eq(0).text().replace(/[^\u4e00-\u9fa5]+/g, ''); var s11 = $(this).find('span').eq(1).text(); var s12 = hash3(s10); var m2 = read2(s12); if (m2 == 'A' || m2 == 'B' || m2 == 'C' || m2 == 'D') { } else { save2(s12, s11); caix = caix + 1; } document.getElementById('学习数量1').innerHTML = caix; }) }); //答题 $('#fastBtn5').on('click', function () { var x = 0; var test = $('#DataList1').find('[id=\'table2\']'); test.each(function () { var s10 = $(this).find('span').eq(0).text().replace(/[^\u4e00-\u9fa5]+/g, ''); var s12 = hash3(s10); var m2 = read2(s12); var y3 = 9; if (m2 == 'A') { y3 = 0 } if (m2 == 'B') { y3 = 1 } if (m2 == 'C') { y3 = 2 } if (m2 == 'D') { y3 = 3 } if (y3 < 9) { $(this).find('[type=\'radio\']').eq(y3).attr('checked', true); x = x + 1; } }) document.getElementById('答题数量1').innerHTML = x; }); //知识竞赛答题 $('#fastBtn10').on('click', function () { var x = 0; var test = $('#singleSelect').children(); test.each(function () { var s10 = $(this).find('.content_style').text().replace(/[^\u4e00-\u9fa5]+/g, ''); var s12 = hash3(s10); var m2 = read2(s12); var y3 = 9; if (m2 == 'A') { y3 = 0 } if (m2 == 'B') { y3 = 1 } if (m2 == 'C') { y3 = 2 } if (m2 == 'D') { y3 = 3 } if (y3 < 9) { $(this).find('[type=\'radio\']').eq(y3).attr('checked', true); x = x + 1; } }) var test2 = $('#multipleSelect').children(); test2.each(function () { var s10 = $(this).find('.content_style').text().replace(/[^\u4e00-\u9fa5]+/g, ''); var s12 = hash3(s10); var m2 = ''; m2 = read2(s12); // document.getElementById('答题数量1').innerHTML += m2; var y3 = 0; if (m2.length !== 0) { if (m2.indexOf('A') >= 0) { $(this).find('[type=\'checkbox\']').eq(0).attr('checked', true); } if (m2.indexOf('B') >= 0) { $(this).find('[type=\'checkbox\']').eq(1).attr('checked', true); } if (m2.indexOf('C') >= 0) { $(this).find('[type=\'checkbox\']').eq(2).attr('checked', true); } if (m2.indexOf('D') >= 0) { $(this).find('[type=\'checkbox\']').eq(3).attr('checked', true); } if (m2.indexOf('E') >= 0) { $(this).find('[type=\'checkbox\']').eq(4).attr('checked', true); } } if (y3 < 9) { x = x + 1; } }) document.getElementById('答题数量1').innerHTML = x; }); //知识竞赛学习 $('#fastBtn11').on('click', function () { var x = 0; var test = $('#singleSelect').children(); test.each(function () { var s10 = $(this).find('.content_style').text().replace(/[^\u4e00-\u9fa5]+/g, ''); var s12 = hash3(s10); var s13 = $(this).find('[type=\'radio\']'); if (s13.eq(0).attr('checked')) { x = x + 1; save2(s12, 'A'); } if (s13.eq(1).attr('checked')) { x = x + 1; save2(s12, 'B'); } if (s13.eq(2).attr('checked')) { x = x + 1; save2(s12, 'C'); } if (s13.eq(3).attr('checked')) { x = x + 1; save2(s12, 'D'); } }) var test2 = $('#multipleSelect').children(); test2.each(function () { var s10 = $(this).find('.content_style').text().replace(/[^\u4e00-\u9fa5]+/g, ''); var s12 = hash3(s10); var m2 = ''; var s13 = $(this).find('[type=\'checkbox\']'); if (s13.eq(0).attr('checked')) { m2 += 'A'; } if (s13.eq(1).attr('checked')) { m2 += 'B'; } if (s13.eq(2).attr('checked')) { m2 += 'C'; } if (s13.eq(3).attr('checked')) { m2 += 'D'; } if (s13.eq(4).attr('checked')) { m2 += 'E'; } if (m2.length !== 0) { x = x + 1; save2(s12, m2); } }) document.getElementById('学习数量1').innerHTML = x; }); //显示竞赛学习答案 $('#fastBtn13').on('click', function () { var x = 0; var an = ''; var test = $('#singleSelect').children(); test.each(function () { var s10 = $(this).find('.content_style').text().replace(/[^\u4e00-\u9fa5]+/g, ''); var s12 = hash3(s10); var s13 = $(this).find('[type=\'radio\']'); if (s13.eq(0).attr('checked')) { an += s12 + ':A;'; } if (s13.eq(1).attr('checked')) { an += s12 + ':B;'; } if (s13.eq(2).attr('checked')) { an += s12 + ':C;'; } if (s13.eq(3).attr('checked')) { an += s12 + ':D;'; } }) var test2 = $('#multipleSelect').children(); test2.each(function () { var s10 = $(this).find('.content_style').text().replace(/[^\u4e00-\u9fa5]+/g, ''); var s12 = hash3(s10); var m2 = ''; var s13 = $(this).find('[type=\'checkbox\']'); if (s13.eq(0).attr('checked')) { m2 += 'A'; } if (s13.eq(1).attr('checked')) { m2 += 'B'; } if (s13.eq(2).attr('checked')) { m2 += 'C'; } if (s13.eq(3).attr('checked')) { m2 += 'D'; } if (s13.eq(4).attr('checked')) { m2 += 'E'; } if (m2.length !== 0) { an = an + s12 + ':' + m2 + ';'; } }) document.getElementById('fastBtn12').value = an; }); //显示竞赛学习答案 $('#fastBtn15').on('click', function () { var str = document.getElementById('fastBtn14').value; var strs = new Array(); //定义一数组 var strs2 = new Array(); strs = str.split(';'); //字符分割 var i = 0; var n = 0; for (i = 0; i < strs.length; i++) { var k = strs[i]; strs2 = k.split(':'); if (strs2.length === 2) { var read3 = read2(strs2[0]); if (read3 !== strs2[1]) { n += 1; save2(strs2[0], strs2[1]); } } } var text = '导入:' + strs.length + ' 新:' + n; window.alert(text); }); }) ();