您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
2024/1/23 15:25:23
当前为
// ==UserScript== // @name becoder // @namespace Violentmonkey Scripts // @match https://www.becoder.com.cn/* // @grant none // @version 1.7 // @author EarthMessenger // @description 2024/1/23 15:25:23 // @grant GM.getValue // @grant unsafeWindow // @license MIT // ==/UserScript== (() => { const fixRightClick = () => { window.oncontextmenu = null; document.oncontextmenu = null; }; const fixPDF = () => { const iframes = document.querySelectorAll("iframe"); const pat = /https:\/\/www\.becoder\.com\.cn\/js\/pdf\/web\/viewer\.html\?file=(\S*)/gm; for (const oldPdf of iframes) { const res = pat.exec(oldPdf.src); if (res == null) continue; const url = res[1]; fetch(url) .then((resp) => resp.blob()) .then((blob) => blob.slice(0, blob.size, "application/pdf")) .then((blob) => { const newPdf = document.createElement("iframe"); newPdf.src = URL.createObjectURL(blob); newPdf.width = oldPdf.width; newPdf.height = oldPdf.height; const parent = oldPdf.parentNode; parent.replaceChild(newPdf, oldPdf); }); } }; const fixHomePage = () => { if (window.location.pathname !== "/index") return; const mainDiv = document.querySelector("div.main > div"); mainDiv.children[0].classList.replace("eleven", "sixteen"); mainDiv.removeChild(mainDiv.children[1]); // 右欄 const column = mainDiv.children[0]; column.removeChild(column.children[4]); // 提交次數統計圖 column.removeChild(column.children[0]); // AI 頭圖 }; const redirectHomePage = () => { if (window.location.pathname === "/") { window.location.replace(new URL("/index", location.href).toString()); } }; const fillLoginCredentials = async () => { if (window.location.pathname !== "/login") return; // 根據 https://wiki.greasespot.net/GM.getValue,GM.getValue 應該是不支持 object 的, // 但是相信 2025 年不會有人使用 Greasemonkey 的。而且 Tampermonkey 和 Violentmonkey 都支持, // 那就假裝它確實是可行的。 const credentials = await GM.getValue("credentials"); if (credentials === undefined) return; try { const {username, password} = credentials; document.getElementById("username").value = username; document.getElementById("password").value = password; const captcha = document.getElementById("captcha"); const autoSubmitCaptcha = (ev) => { if (ev.target.value.length !== 4) return ; unsafeWindow.login(); }; captcha.addEventListener("input", autoSubmitCaptcha); captcha.focus(); } catch (error) { console.error("填寫的憑據無效。"); } }; const fixNavbar = () => { const navbar = document.querySelector("html > body > div:first-of-type > div"); if (navbar === null) return; navbar.removeChild(navbar.children[8]); // 工具 navbar.removeChild(navbar.children[7]); // 課程 navbar.removeChild(navbar.children[3]); // 題單 navbar.removeChild(navbar.children[1]); // 首頁 navbar.children[0].href = "/index"; // 使用舊首頁 }; fixRightClick(); fixPDF(); fixHomePage(); redirectHomePage(); fillLoginCredentials(); fixNavbar(); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址