开启辅助访问 切换到窄版

登录  | 立即注册

游客您好!登录后享受更多精彩

查看: 23|回复: 2

[脚本]学银在线解除作业粘贴限制-

[复制链接]

6

主题

18

回帖

87

积分

版主

积分
87

论坛元老

发表于 2025-11-24 11:15:52 | 显示全部楼层 |阅读模式
学校有的课程是AI开课,在学银在线平台上。提交作业居然还要手打,禁止复制。

进控制台看一下,可以发现是前端JS限制,写一个油猴脚本过掉就行。
  1. // ==UserScript==
  2. // @name         学银在线允许粘贴
  3. // @namespace    https://blog.esing.dev/
  4. // @version      0.7.2.1
  5. // @description  移除学银在线的编辑器限制,允许粘贴
  6. // @match        https://mooc1.xueyinonline.com/mooc-ans/*
  7. // @run-at       document-end
  8. // @grant        none
  9. // ==/UserScript==

  10. (function () {
  11.     "use strict";

  12.     // 尝试对所有 UEditor 实例移除 beforepaste 的 editorPaste 监听
  13.     function unlockPaste() {
  14.         // UEditor 全局对象一般叫 UE
  15.         if (!window.UE || !UE.instants) return false;

  16.         let done = false;
  17.         for (const key in UE.instants) {
  18.             if (!Object.prototype.hasOwnProperty.call(UE.instants, key)) continue;
  19.             const ed = UE.instants[key];
  20.             try {
  21.                 // 如果全局有 editorPaste 函数,并且这个编辑器有 removeListener 方法
  22.                 if (typeof window.editorPaste === "function" && ed.removeListener) {
  23.                     ed.removeListener("beforepaste", window.editorPaste);
  24.                     console.log("[Userscript] removed beforepaste listener from editor:", key);
  25.                     done = true;
  26.                 }
  27.             } catch (e) {
  28.                 console.error("[Userscript] removeListener error:", e);
  29.             }
  30.         }
  31.         return done;
  32.     }

  33.     // 初次尝试
  34.     unlockPaste();

  35.     // 有时候编辑器是异步初始化的,这里轮询几次,确保挂到实例上之后再移除
  36.     const timer = setInterval(() => {
  37.         if (unlockPaste()) {
  38.             clearInterval(timer);
  39.         }
  40.     }, 1000);

  41.     if (!document.getElementById("paste-unlock-indicator")) {
  42.         const div = document.createElement("div");
  43.         div.id = "paste-unlock-indicator";
  44.         div.textContent = "粘贴已解锁😋";
  45.         div.style.cssText =
  46.             "position:fixed;bottom:10px;right:10px;padding:4px 8px;font-size:12px;background:#4caf50;color:#fff;z-index:99999;border-radius:4px;opacity:0.7;";
  47.         document.body.appendChild(div);
  48.     }
  49. })();
复制代码


回复

使用道具 举报

30

主题

45

回帖

339

积分

管理员

枫之小铭

积分
339

论坛元老

发表于 2025-11-28 17:49:46 | 显示全部楼层
建议补一补介绍一下油猴?给个链接也可以
回复

使用道具 举报

6

主题

18

回帖

87

积分

版主

积分
87

论坛元老

 楼主| 发表于 3 天前 | 显示全部楼层
xming 发表于 2025-11-28 17:49
建议补一补介绍一下油猴?给个链接也可以

有道理
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|电信科协官网

GMT+8, 2025-12-17 01:49 , Processed in 0.153776 second(s), 28 queries .

Powered by Discuz! X3.5

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表