🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

智慧树 - 提交作业页面添加作业详情文字内容

为智慧树作业的“提交作业”页面添加“作业详情”中的文字内容

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name        智慧树 - 提交作业页面添加作业详情文字内容
// @description 为智慧树作业的“提交作业”页面添加“作业详情”中的文字内容
// @namespace   UnKnown
// @match        https://hiexam.zhihuishu.com/atHomeworkExam/stu/homeworkQ/homeworkDetail/*
// @version     1
// @grant       none
// @run-at      document-end
// ==/UserScript==

const main = async (count) => {

  const delay = 250; // 每次尝试前的等待间隔
   this.limit = 32;  // 尝试次数限制

  // 达到/超过次数限制时停止尝试
  if (count <= 0) return false;

  // 等一波
  await new Promise(
    resolve => setTimeout(resolve, delay)
  );

  if ( // 验证是否加载完毕
    document.querySelector("#pane-doHomeWork .doexam-div") &&
    document.querySelector("#pane-homeworkDetail .detail-text > p")
  ) { // 加载完毕时

    const parentNode = document.querySelector("#pane-doHomeWork .doexam-div");
    const newNode = document.createElement("div");

    newNode.className = "detail-content stu-detail Jobcontent-p";

    // 作业详情
    newNode.appendChild(
      (function() {
        const h2 = document.createElement("h2");
        h2.textContent = "作业详情";
        h2.setAttribute("style", "margin:30px 0 -20px;color:#3d4059");
        return h2;
      })()
    );

    // 内容
    newNode.appendChild(
      document.querySelector("#pane-homeworkDetail .detail-text")
              .cloneNode(true)
    );

    parentNode.insertBefore(
      newNode,
      parentNode.querySelector(".Jobcontent-div")
    );

  } else { // 没有加载完毕时,利用递归继续重试。
    // console.info(count);
    main(--count);
  }

};

main(main.limit);