gdst-study

javascripts for auto study

  1. // ==UserScript==
  2. // @name gdst-study
  3. // @description javascripts for auto study
  4. // @match http://online.enetedu.com/gdst/SchoolCourse/Process*
  5. // @include http://online.enetedu.com/gdst/SchoolCourse/Process*
  6. // @match http://online.enetedu.com/gdst/Activities/NetworkVoting*
  7. // @include http://online.enetedu.com/gdst/Activities/NetworkVoting*
  8. // @run-at document-start
  9. // @grant none
  10. // @version 1.0
  11. // @namespace https://greasyfork.org/users/86831
  12. // ==/UserScript==
  13. // *** put your code inside letsJQuery: ***
  14. function getValueByName(str, d1, d2, name) {
  15. var arr = str ? str.split(d1) : [
  16. ];
  17. for (var i = arr.length - 1; i >= 0; i--) {
  18. arr2 = arr[i].split(d2);
  19. if (arr2.shift() == name) {
  20. return arr2.join();
  21. }
  22. }
  23. return '';
  24. }
  25. function sleep(sleepDuration) {
  26. var now = new Date().getTime();
  27. while (new Date().getTime() < now + sleepDuration) { /* do nothing */
  28. }
  29. }
  30. function readCookie(name) {
  31. return getValueByName(document.cookie, ';', '=', name);
  32. };
  33. function emptyFunction() {
  34. };
  35. if (window.location.href.indexOf('/gdst/SchoolCourse/Process?course_id=') >= 0) {
  36. var learn = readCookie(' enet_studentCourseWareLearn0');
  37. var stu_id = getValueByName(learn, '&', ',', 'student_id');
  38. var cour_id = getValueByName(learn, '&', ',', 'course_id');
  39. setTimeout(function () {
  40. var list = $('a.video_number');
  41. if (list.length > 0) {
  42. var timestamp = parseInt(new Date().getTime());
  43. for (var i = list.length - 1; i >= 0; i--) {
  44. if (list[i].parentNode.style['background-color'] != 'rgb(112, 240, 106)') {
  45. var v_id = getValueByName(list[i]['href'], '&', '=', 'courseware_id');
  46. if (v_id == '') continue;
  47. var url = '/gdst/VideoPlay/StudyRecode?is_elective=&end=100000&start=100000';
  48. url = url + '&student_id=' + stu_id;
  49. url = url + '&course_id=' + cour_id;
  50. url = url + '&courseware_id=' + v_id;
  51. url = url + '&timestamp=' + timestamp;
  52. $.get(url);
  53. timestamp = timestamp + parseInt(Math.random() * 5000);
  54. }
  55. }
  56. } else {
  57. setTimeout(arguments.callee, 300);
  58. }
  59. }, 500);
  60. }
  61. if (window.location.href.indexOf('/gdst/Activities/NetworkVoting') >= 0) {
  62.  
  63. function doVote(id, t_id) {
  64. //alert("doVote:"+id + t_id);
  65. $.get('/gdst/Activities/NetworkVotingDetail?id=' + id, function (result) {
  66. var reg = /id=\"voteid\"\s+value=\"(\d+)\"/gi;
  67. var res = reg.exec(result);
  68. if (res == null || res.length < 2) return;
  69. var v_id = res[1];
  70. var url = '/gdst/Activities/SubmitZAN?&t=' + Math.random();
  71. var paras = {
  72. 'zantype': Math.random() > 0.5 ? 1 : 0,
  73. 'id': id,
  74. 'voteid': v_id
  75. };
  76. $.post(url, paras);
  77. //alert(list[i].innerHTML);
  78. $('#' + t_id)[0].innerHTML = '[已投票!]' + $('#' + t_id)[0].innerHTML;
  79. });
  80. };
  81. setTimeout(function () {
  82. var list = $('a.searchtopic');
  83. if (list.length > 0) {
  84. for (var i = list.length - 1; i >= 0; i--) {
  85. var id = getValueByName(list[i]['href'], '?', '=', 'id');
  86. if (id == '') continue;
  87. list[i].id = 'doVoteid_' + parseInt(Math.random() * 1000000);
  88. //alert('doVote(' + id + ',' + list[i].id + ');');
  89. //setTimeout('doVote(' + id + ',' + list[i].id + ');', 50);
  90. doVote(id, list[i].id);
  91. // break;
  92. }
  93. } else {
  94. setTimeout(arguments.callee, 300);
  95. }
  96. }, 500);
  97. }