Greasy Fork

Greasy Fork is available in English.

中色科技视频快进

可快速看完中色Oa内的视频 自动学习试卷并答题(模拟试卷提交后可以学习)

当前为 2017-08-18 提交的版本,查看 最新版本

// ==UserScript==
// @name        中色科技视频快进
// @namespace   xcg
// @version     2
// @grant       none
// @match       *://127.0.0.1/t/*
// @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
// @description       可快速看完中色Oa内的视频  自动学习试卷并答题(模拟试卷提交后可以学习)
// ==/UserScript==
(function () {
  'use strict';
  var video = /Video.aspx/i;
  var VideoList = /VideoList.aspx/i;
  var VideoData = /VideoData.aspx/i;
  var caiurl = /answerlist.aspx/i;
  var caiurl2 = /Practice.aspx/i;
  var caiurl3 = /Formal.aspx/i;
  var caix = 0;
  var url = window.location.href;
  var Btn1 = '<a id="fastBtn" style="cursor:pointer;text-decoration:none;color:red;padding:2 5px;border:1px solid red;">快进</a>';
  var Btn2 = '<a id="fastBtn2" style="cursor:pointer;text-decoration:none;color:red;padding:2 5px;border:1px solid red;">全部打开</a>';
  var Btn3 = '<a id="fastBtn3" style="cursor:pointer;text-decoration:none;color:red;padding:2 5px;border:1px solid red;">全部快进</a>';
  var Btn4 = '<a id="fastBtn4" style="cursor:pointer;text-decoration:none;color:red;padding:2 5px;border:1px solid red;"> 学习 </a>';
  var Btn5 = '<a id="fastBtn5" style="cursor:pointer;text-decoration:none;color:red;padding:2 5px;border:1px solid red;"> 答题 </a>';
  var Btn6 = '<td>已学习: <a id="学习数量1"></a></td><td>已答题: <a id="答题数量1"></a></td>';
  var Btn9 = '已答题: <a id="答题数量1"></a></td>';
  var I64BIT_TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_-'.split('');
  //哈希算法
  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;
  } //在视频播放页面添加快进按钮

  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 (VideoList.test(url)) {
    var title = $('.Grid');
    if (title.length !== 0) {
      title.after(Btn3).after(Btn2);
      $('#fastBtn2').css({
        'font-size': '30px',
        'display': 'inline-block',
        'height': '40px',
        'line-height': '40px',
        'line-width': '80px',
        'margin': '2 5px',
        'vertical-align': 'bottom'
      });
      $('#fastBtn3').css({
        'font-size': '30px',
        'display': 'inline-block',
        'height': '40px',
        'line-height': '40px',
        'line-width': '80px',
        'margin': '2 5px',
        'vertical-align': 'bottom'
      });
    }
  } //在视频列表页面添加全播放,全快进

  if (VideoData.test(url)) {
    var title = $('.Grid');
    if (title.length !== 0) {
      title.after(Btn3).after(Btn2);
      $('#fastBtn2').css({
        'font-size': '30px',
        'display': 'inline-block',
        'height': '40px',
        'line-height': '40px',
        'line-width': '80px',
        'margin': '2 5px',
        'vertical-align': 'bottom'
      });
      $('#fastBtn3').css({
        'font-size': '30px',
        'display': 'inline-block',
        'height': '40px',
        'line-height': '40px',
        'line-width': '80px',
        'margin': '2 5px',
        'vertical-align': 'bottom'
      });
    }
  } //在模拟答案页面添加学习,答题

  if (caiurl.test(url)) {
    var title = $('#table1').find('[id=\'HyperLink1\']');
    if (title.length !== 0) {
      title.after(Btn6).after(Btn5).after(Btn4);
      $('#fastBtn4').css({
        'font-size': '30px',
        'display': 'inline-block',
        'height': '40px',
        'line-height': '40px',
        'line-width': '80px',
        'margin': '2 5px',
        'vertical-align': 'bottom'
      });
      $('#fastBtn5').css({
        'font-size': '30px',
        'display': 'inline-block',
        'height': '40px',
        'line-height': '40px',
        'line-width': '80px',
        'margin': '2 5px',
        'vertical-align': 'bottom'
      });
    }
  } //在模拟考试页面添加 答题

  if (caiurl2.test(url)) {
    var title = $('#table1').find('[align=\'center\']');
    if (title.length !== 0) {
      title.after(Btn9).after(Btn5);
      $('#fastBtn5').css({
        'font-size': '30px',
        'display': 'inline-block',
        'height': '40px',
        'line-height': '40px',
        'line-width': '80px',
        'margin': '2 5px',
        'vertical-align': 'bottom'
      });
    }
  } //在正式考试页面添加 答题

  if (caiurl3.test(url)) {
    var title = $('#table1').find('[align=\'center\']');
    if (title.length !== 0) {
      title.after(Btn9).after(Btn5);
      $('#fastBtn5').css({
        'font-size': '30px',
        'display': 'inline-block',
        'height': '40px',
        'line-height': '40px',
        'line-width': '80px',
        'margin': '2 5px',
        'vertical-align': 'bottom'
      });
    }
  }
  $('#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 = $.cookie(s12);
      if (m2 == 'A' || m2 == 'B' || m2 == 'C' || m2 == 'D')
      {
      } 
      else
      {
        $.cookie(s12, s11, 2);
        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 = $.cookie(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;
    }
    )
  });
}) ();