|
|
学校有的课程是AI开课,在学银在线平台上。提交作业居然还要手打,禁止复制。
进控制台看一下,可以发现是前端JS限制,写一个油猴脚本过掉就行。
- // ==UserScript==
- // @name 学银在线允许粘贴
- // @namespace https://blog.esing.dev/
- // @version 0.7.2.1
- // @description 移除学银在线的编辑器限制,允许粘贴
- // @match https://mooc1.xueyinonline.com/mooc-ans/*
- // @run-at document-end
- // @grant none
- // ==/UserScript==
- (function () {
- "use strict";
- // 尝试对所有 UEditor 实例移除 beforepaste 的 editorPaste 监听
- function unlockPaste() {
- // UEditor 全局对象一般叫 UE
- if (!window.UE || !UE.instants) return false;
- let done = false;
- for (const key in UE.instants) {
- if (!Object.prototype.hasOwnProperty.call(UE.instants, key)) continue;
- const ed = UE.instants[key];
- try {
- // 如果全局有 editorPaste 函数,并且这个编辑器有 removeListener 方法
- if (typeof window.editorPaste === "function" && ed.removeListener) {
- ed.removeListener("beforepaste", window.editorPaste);
- console.log("[Userscript] removed beforepaste listener from editor:", key);
- done = true;
- }
- } catch (e) {
- console.error("[Userscript] removeListener error:", e);
- }
- }
- return done;
- }
- // 初次尝试
- unlockPaste();
- // 有时候编辑器是异步初始化的,这里轮询几次,确保挂到实例上之后再移除
- const timer = setInterval(() => {
- if (unlockPaste()) {
- clearInterval(timer);
- }
- }, 1000);
- if (!document.getElementById("paste-unlock-indicator")) {
- const div = document.createElement("div");
- div.id = "paste-unlock-indicator";
- div.textContent = "粘贴已解锁😋";
- div.style.cssText =
- "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;";
- document.body.appendChild(div);
- }
- })();
复制代码
|
|