学习通一键讨论

学习通一键复制最近的一条评论进行回复,需要当前页保持在讨论页,在屏幕右方会出现按钮

当前为 2022-12-07 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         学习通一键讨论
// @namespace    https://bbs.tampermonkey.net.cn/
// @version      0.1.0
// @description  学习通一键复制最近的一条评论进行回复,需要当前页保持在讨论页,在屏幕右方会出现按钮
// @author       Circle
// @match        https://mooc1-2.chaoxing.com/bbscircle/grouptopic*
// @license MIT
// ==/UserScript==

(async function () {
    'use strict';
    const body = document.querySelector("body")
    const btn = document.createElement("button")
    btn.onclick = allComment
    btn.style.padding = "10px"
    btn.style.backgroundColor = "skyblue"
    btn.style.position = "fixed"
    btn.style.right = "100px"
    btn.style.top = "400px"
    btn.textContent = "一键回复"
    body.appendChild(btn)
    async function allComment() {
        console.log("1111")
        const name = document.querySelector(".zt_u_name").textContent
        const commentDoms = document.querySelectorAll("#showTopics .content1118 .oneDiv")
        for (let i = 0; i < commentDoms.length; i++) {
            if (commentDoms[i].innerHTML.indexOf(name) === -1) {
                const comment = commentDoms[i].querySelector(".hf_pct").textContent
                const replyBtn = commentDoms[i].querySelector(".clearfix .tl1")
                replyBtn.click()
                let textarea = commentDoms[i].querySelector(".plDiv textarea")
                while (!textarea) {
                    textarea = commentDoms[i].querySelector(".plDiv textarea")
                }
                textarea.value = comment
                const uploadBtn = commentDoms[i].querySelector(".plDiv grenBtn")
                uploadBtn.click()
                await new Promise((re) => {
                    setTimeout(() => { re() }, 200)
                })
                console.log(comment, replyBtn)
            }
        }
    }
})();