Greasy Fork

Greasy Fork is available in English.

wuxuejiaoyu

个人脚本!

当前为 2022-09-28 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==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
// ==/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();
            }
        }
    }
})();