Greasy Fork

Greasy Fork is available in English.

cnmooc 测验显示所有题目

无描述

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         cnmooc 测验显示所有题目
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  无描述
// @author       Teruteru
// @match        https://www.cnmooc.org/examTest/stuExamList/*.mooc
// @icon         https://www.google.com/s2/favicons?sz=64&domain=cnmooc.org
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';


    let targetNode = document.querySelector('#examContentDiv');
    let observerOptions = {
        childList: true, // 观察目标子节点的变化,添加或删除
        attributes: true, // 观察属性变动
        subtree: true, //默认是false,设置为true后可观察后代节点
    }
    function callback(mutationList, observer) {
        mutationList.forEach((mutation) => {
            switch(mutation.type) {
                case 'childList':
                    //console.log(mutation);
                    break;
                case 'attributes':
                    //console.log(mutation.target.className);
                    var wrapper = document.querySelector('#practice-wrapper');
                    if (mutation.target.className === "practice-wrapper")
                    {
                        mutation.target.style.height = "auto";
                        mutation.target.addEventListener('scroll', function(e){e.stopPropagation()}, true);

                    }
                    if (mutation.target.className === "view-test practice-item"){
                        function addClass(obj, cls){
                            var obj_class = obj.className,
                                blank = (obj_class != '') ? ' ' : '';
                            obj.className = obj_class + blank + cls;
                        };
                        addClass(mutation.target, "current");
                    }
                    break;
            }
        });
    }

    let observer = new MutationObserver(callback);
    observer.observe(targetNode, observerOptions);
})();