Greasy Fork is available in English.

奥鹏在线作业助手

奥鹏在线答题小助手

  1. // ==UserScript==
  2. // @name 奥鹏在线作业助手
  3. // @namespace https://github.com/ousui/open-learn-helper
  4. // @version 0.9.4
  5. // @description 奥鹏在线答题小助手
  6. // @author shuai.w
  7. // @match https://learn.open.com.cn/StudentCenter/OnLineJob/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13. // 页面执行完执行
  14. var check = setInterval(main, 250);
  15.  
  16. var is_test = false;
  17. var btn_pcls = 'Opration-Btn-Box';
  18.  
  19. function main() {
  20. if (
  21. document.getElementsByClassName('Opration-Btn-Box').length == 0 &&
  22. document.getElementsByClassName('resultshow').length == 0
  23. ) {
  24. console.info('>>> 循环检测页面作业类型......');
  25. return; };
  26. is_test = document.getElementsByClassName('resultshow').length > 0;
  27. if (is_test) {
  28. btn_pcls = 'right-bottom';
  29. console.info('>>> 作业类型: 作业考核');
  30. } else {
  31. console.info('>>> 作业类型: 平时作业');
  32. }
  33. clearInterval(check);
  34.  
  35. // 这里执行比较快,需要延迟执行
  36. setTimeout(crack_common, 3000);
  37. add_btn_group();
  38. }
  39.  
  40. function add_btn_group() {
  41. $('.' + btn_pcls).append('<hr />');
  42. add_btn('show', do_tags, '搜题');
  43. add_btn('clean', do_clean, '重做');
  44. }
  45.  
  46. function add_btn(tag, func, text) {
  47. $('.'+btn_pcls).append(
  48. '<button class="same-margin relative" x-btn-'+tag+'>'+text+'</button>'
  49. );
  50.  
  51. $('.'+btn_pcls+' button[x-btn-'+tag+']')
  52. .css({
  53. 'background': '#0089ff',
  54. })
  55. .hover(function(){
  56. $(this).css({
  57. '-webkit-box-shadow': '0 0 4px #5f5a5a',
  58. 'box-shadow': '0 0 4px #5f5a5a'
  59. });
  60. }, function(){
  61. $(this).css({
  62. '-webkit-box-shadow': '',
  63. 'box-shadow': ''
  64. });
  65. })
  66. .on('click', func);
  67. }
  68.  
  69. function do_clean() {
  70. $('.Choosed').click();
  71. }
  72.  
  73. function do_tags() {
  74.  
  75. $('.Subject-Title').each(function(i, e){
  76. var parent = $(e).parents('.Subject-Area');
  77. if (!!parent.attr('x-init')) {
  78. return;
  79. }
  80.  
  81. parent.attr('x-init', true);
  82. var question = $(e).text();
  83. var equestion = encodeURIComponent(question);
  84.  
  85. var query = $('<div>').css({
  86. 'background': '#efefef',
  87. 'margin-top': '-10px'
  88. });
  89.  
  90. parent.find('.Subject-Title').after(query);
  91. get_forword_tag(query, 0, "https://www.shangxueba.com/ask/search.aspx?key="+ equestion, "上学吧");
  92. get_forword_tag(query, 1, "https://www.baidu.com/s?wd="+ equestion, "百度!");
  93. query.find('a[x-query-li]').css({
  94. 'color': '#03b000',
  95. 'margin': '3px 5px 3px 3px',
  96. 'padding': '0px 5px',
  97. 'font-weight': 800,
  98. 'cursor': 'pointer',
  99. 'font-size': 'larger',
  100. 'padding': '0 8px'
  101. });
  102. });
  103.  
  104. // fix_width();
  105. }
  106.  
  107. function get_forword_tag(el, i, link, text) {
  108. var el_a = $('<a />').attr({
  109. 'x-query-li': i,
  110. 'href': link,
  111. 'title': text,
  112. 'target': '_blank'
  113. }).html(text);
  114. el.append(el_a);
  115. }
  116.  
  117. function fix_width() {
  118. $('.blank-title td img').css('width', 'auto');
  119. $('.question-options li img').css('width', 'auto');
  120. }
  121.  
  122. function request_monitoring() {
  123. $(document).ajaxComplete(
  124. function(event, xhr, settings) {
  125.  
  126. if (settings.url.indexOf('OnlineJob/DoHomework') <= 0) {
  127. return;
  128. }
  129. $('.qestitle').each(function(i, e){
  130. var question = $(e).text();
  131. var equestion = encodeURIComponent(question);
  132. var td = $(e).attr('style', '');
  133. td.parent().prepend('<td><a href="http://www.baidu.com/s?wd='+ question +'" target="_blank">Q</a></td>');
  134. var height = td.height();
  135.  
  136. td.html('<textarea readonly style="width: 100%; border:0; font-weight:400;">'+question+'</textarea>').find('textarea').height(height);
  137. // 太丑
  138. // var squestion = question.replace(' )', ' ').replace('(', '').replace('。', '');
  139. // td.parent().parent().append('<tr><td colspan="3"><input style="width: 100%; height:20px; font-size: 14px;font-weight:100;" value="' + squestion + '" /></td></tr>');
  140. });
  141. }
  142. );
  143. }
  144.  
  145. // 破解常规限制:右键、 ctrl+c、 选中禁用
  146. function crack_common() {
  147. console.info('>>> 解除右键限制');
  148. // 禁用右键
  149. document.oncontextmenu = function () {
  150. return true;
  151. }
  152. console.info('>>> 解除禁用ctrl+c功能');
  153. //禁用ctrl+c功能
  154. document.onkeydown = function () {
  155. if (event.ctrlKey && window.event.keyCode == 67) {
  156. return true;
  157. }
  158. }
  159. console.info('>>> 解除禁用选中功能');
  160. //禁用选中
  161. $(document).unbind('selectstart');
  162. }
  163. })();