百度题库自动展开

百度题库自动展开,若自动展开失败就刷新页面,去除页面内的浮动广告。

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         百度题库自动展开
// @namespace    http://tampermonkey.net/
// @version      v0.31
// @description  百度题库自动展开,若自动展开失败就刷新页面,去除页面内的浮动广告。
// @author       沧浪之水
// @match        https://easylearn.baidu.com/edu-page/tiangong/*
// @icon         https://edu-fe.cdn.bcebos.com/public/business-cop-icon.png
// @grant        none
// @license MIT
// ==/UserScript==

(function () {
    'use strict';

    // Your code here...
    function clickExerciseBtn() {
        document.querySelector(".exercise-btn.exercise-btn-4").click();
    }

    function clickExerciseBtn2() {
        document.querySelector(".expand-btn").click();
    }


    function runClick() {

        // 获取所有 `class="toogle-btn"` 标签
        var elements = document.querySelectorAll(".toogle-btn");

        // 循环点击所有标签
        for (var i = 0; i < elements.length; i++) {
            elements[i].click();
        }

        // 在 一定时长后调用 clickExerciseBtn() 函数
        setTimeout(clickExerciseBtn, 500);
        setTimeout(clickExerciseBtn2, 1000);


    }

    // 调用脚本
    setTimeout(runClick, 1000);
    // 监听 DOM 元素添加事件
    const timer = setInterval(() => {
        // 执行命令
        document.querySelector(".vip-banner-cont").remove();
        document.querySelector(".vip-card-warp").remove();

        // 检查是否成功执行
        if (!document.querySelector(".vip-banner-cont")) {
            // 停止定时器
            clearInterval(timer);
        }
    }, 1000);

})();