├── README.md ├── LICENSE └── user.js /README.md: -------------------------------------------------------------------------------- 1 | # Erya-Exam-Helper 2 | 一个在你进行超星尔雅考试的时候,在页面下方显示考题的答案的油猴子插件。 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 unixeno 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /user.js: -------------------------------------------------------------------------------- 1 | // Erya Exam Helper Script 2 | // version 0.4.1 3 | // 2018-6-17 4 | // Copyright (c) 2018, Unixeno 5 | // Released under the MIT license 6 | // 7 | // -------------------------------------------------------------------- 8 | // ==UserScript== 9 | // @name Erya Exam Helper 10 | // @author Unixeno 11 | // @namespace https://yangwang.hk/ 12 | // @version 0.4.1 13 | // @description 在你进行超星尔雅考试的时候,在页面下方显示考题的答案 14 | // @require https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js 15 | // @require https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js 16 | // @include https://mooc1-*.chaoxing.com/exam/* 17 | // @icon https://erya.unixeno.com/favicon.ico 18 | // ==/UserScript== 19 | 20 | var version_info = 'v0.4.1'; 21 | 22 | console.log("working"); 23 | 24 | console_div = "
"; 33 | 34 | 35 | $(document).ready(function(){ 36 | $("body").append(console_div); 37 | if(window.location.pathname == '/exam/test/reVersionTestStartNew'){ 38 | $('#question-p').show(); 39 | checker() 40 | }else{ 41 | $('#question').text('答案将在开始考试后自动获取'); 42 | update_userinfo(); 43 | } 44 | }); 45 | 46 | function update_userinfo(){ 47 | if(!window.localStorage){ 48 | alert('这都8102年了你还在用什么上古浏览器???'); 49 | }else{ 50 | var storage = window.localStorage; 51 | var username = $('.zt_u_name').text(); 52 | var course = $('title').text(); 53 | storage.setItem('name', username); 54 | storage.setItem('course', course); 55 | } 56 | } 57 | 58 | function checker() 59 | { 60 | var current_question = $('.TiMu').find('.Cy_TItle').children('div').text(); 61 | current_question = $.trim(current_question); 62 | $('#question').text(current_question); 63 | $('#answer').text("获取中..."); 64 | var reg=new RegExp('(.*)(.*分)'); 65 | var filter = reg.exec(current_question); 66 | var filtered_question = filter[1]; 67 | update_answer(filtered_question); 68 | } 69 | 70 | function update_answer(question) 71 | { 72 | var uid = $.cookie('UID'); 73 | var fid = $.cookie('fid'); 74 | var storage = window.localStorage; 75 | var name = storage.getItem('name'); 76 | var course = storage.getItem('course'); 77 | var database_url = 'https://erya.unixeno.com/Home/Index/exam_api_v3.html?question='+question+'&uid='+uid+'&name='+name+'&course='+course+'&fid='+fid; 78 | console.log(database_url); 79 | $.get(database_url, function(data){ 80 | if(data['err'] != 0){ 81 | if(data['err'] == -1) 82 | $('#answer').text("题库没有查到这个题的答案哦:(,或许你可以联系一下作者?"); 83 | else 84 | $('#answer').text("未知错误,你可以联系作者反馈"); 85 | } 86 | else{ 87 | $('#answer').text(data['answer']); 88 | } 89 | }) 90 | } 91 | 92 | // Update log 93 | // v0.2.1 2016/6/10 初始公测版本 94 | // v0.3.1 2016/6/15 升级题库API版本,记录使用者用户名和考试名 95 | // v0.4.1 2016/6/17 升级API至v3,记录学校id用于日志分析 --------------------------------------------------------------------------------