// ==UserScript== // @name wuxuejiaoyu // @namespace http://tampermonkey.net/ // @version 0.1 // @description 个人脚本! // @author You // @match http://learning.wuxuejiaoyu.cn/openlearning/console/* // @icon https://www.google.com/s2/favicons?sz=64&domain=wuxuejiaoyu.cn // @grant none // @license none // @downloadURL none // ==/UserScript== (function() { 'use strict'; // Your code here... var inputbtn = document.createElement('input'); inputbtn.id="btn"; inputbtn.type="button"; inputbtn.value="获取"; inputbtn.style.width="100px"; inputbtn.style.height="50px"; inputbtn.style.backgroundColor="green"; inputbtn.style.border='none'; inputbtn.onclick = getanswer; document.body.appendChild(inputbtn); var inputbtn2 = document.createElement('input'); inputbtn2.id="btn2"; inputbtn2.type="button"; inputbtn2.value="输出"; inputbtn2.style.width="100px"; inputbtn2.style.height="50px"; inputbtn2.style.backgroundColor="red"; inputbtn2.style.border='none'; inputbtn2.style.marginLeft = "50px" inputbtn2.onclick = setanswer; document.body.appendChild(inputbtn2); function getanswer(){ var child = self.parent['w_main'].document.getElementById('cboxIframe').contentWindow.document.getElementById('w_lms_content').contentWindow.document.getElementById('w_lms_sco').contentWindow.document.querySelectorAll('[style="color:darkred;font-size:10pt"]') var index = 0; for(var i = 0;i < child.length;i++){ if(child[i].innerText.length != 6){ sessionStorage.setItem(index,child[i].innerText.substring(child[i].innerText.indexOf(':') + 1 ,child[i].innerText.indexOf(']'))); index++; } } alert("已获取答案"); console.log(sessionStorage); } function setanswer(){ var child = self.parent['w_main'].document.getElementById('cboxIframe').contentWindow.document.getElementById('w_lms_content').contentWindow.document.getElementById('w_lms_sco').contentWindow.document.getElementsByName('w_right')[0].contentWindow.document.querySelectorAll('[optiontype="radio"],[isitt001input="1"]'); for(var i = 0;i < child.length;i++){ if(child[i].tagName == "INPUT"){ child[i].value = sessionStorage.getItem(i); }else{ child[i].querySelector('[value="'+sessionStorage.getItem(i)+'"]').click(); } } } })();