gdst-study

javascripts for auto study

当前为 2016-12-14 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name gdst-study
// @description javascripts for auto study
// @match			http://online.enetedu.com/gdst/SchoolCourse/Process*
// @include			http://online.enetedu.com/gdst/SchoolCourse/Process*
// @match			http://online.enetedu.com/gdst/Activities/NetworkVoting*
// @include			http://online.enetedu.com/gdst/Activities/NetworkVoting*
// @run-at      document-start
// @grant          none
// @version     1.0
// @namespace https://greasyfork.org/users/86831
// ==/UserScript==
// *** put your code inside letsJQuery: ***
function getValueByName(str, d1, d2, name) {
  var arr = str ? str.split(d1)  : [
  ];
  for (var i = arr.length - 1; i >= 0; i--) {
    arr2 = arr[i].split(d2);
    if (arr2.shift() == name) {
      return arr2.join();
    }
  }
  return '';
}
function sleep(sleepDuration) {
  var now = new Date().getTime();
  while (new Date().getTime() < now + sleepDuration) { /* do nothing */
  }
}
function readCookie(name) {
  return getValueByName(document.cookie, ';', '=', name);
};
function emptyFunction() {
};
if (window.location.href.indexOf('/gdst/SchoolCourse/Process?course_id=') >= 0) {
  var learn = readCookie(' enet_studentCourseWareLearn0');
  var stu_id = getValueByName(learn, '&', ',', 'student_id');
  var cour_id = getValueByName(learn, '&', ',', 'course_id');
  setTimeout(function () {
    var list = $('a.video_number');
    if (list.length > 0) {
      var timestamp = parseInt(new Date().getTime());
      for (var i = list.length - 1; i >= 0; i--) {
        if (list[i].parentNode.style['background-color'] != 'rgb(112, 240, 106)') {
          var v_id = getValueByName(list[i]['href'], '&', '=', 'courseware_id');
          if (v_id == '') continue;
          var url = '/gdst/VideoPlay/StudyRecode?is_elective=&end=100000&start=100000';
          url = url + '&student_id=' + stu_id;
          url = url + '&course_id=' + cour_id;
          url = url + '&courseware_id=' + v_id;
          url = url + '&timestamp=' + timestamp;
          $.get(url);
          timestamp = timestamp + parseInt(Math.random() * 5000);         
        }
      }
    } else {
      setTimeout(arguments.callee, 300);
    }
  }, 500);
}
if (window.location.href.indexOf('/gdst/Activities/NetworkVoting') >= 0) {

  function doVote(id, t_id) { 
    //alert("doVote:"+id + t_id);
    $.get('/gdst/Activities/NetworkVotingDetail?id=' + id, function (result) {
      var reg = /id=\"voteid\"\s+value=\"(\d+)\"/gi;
      var res = reg.exec(result);
      if (res == null || res.length < 2) return;
      var v_id = res[1];
      var url = '/gdst/Activities/SubmitZAN?&t=' + Math.random();
      var paras = {
        'zantype': Math.random() > 0.5 ? 1 : 0,
        'id': id,
        'voteid': v_id
      };
      $.post(url, paras);
      //alert(list[i].innerHTML);
      $('#' + t_id)[0].innerHTML = '[已投票!]' + $('#' + t_id)[0].innerHTML;
    });
  };
  
  setTimeout(function () {
    var list = $('a.searchtopic');
    if (list.length > 0) {
      for (var i = list.length - 1; i >= 0; i--) {
        var id = getValueByName(list[i]['href'], '?', '=', 'id');
        if (id == '') continue;
        list[i].id = 'doVoteid_' + parseInt(Math.random() * 1000000);
        //alert('doVote(' + id + ',' + list[i].id + ');');
        //setTimeout('doVote(' + id + ',' + list[i].id + ');', 50);
        doVote(id, list[i].id);
        // break;
      }
    } else {
      setTimeout(arguments.callee, 300);
    }
  }, 500);
}