您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
用于给word文档添加习题。在习题详情页,添加一键复制习题id按钮。复制习题id到粘贴板,手动粘贴到word文档,并添加该习题到试题蓝,最后需手动组卷。
当前为
// ==UserScript== // @name 复制习题id并添加到试题蓝 // @namespace http://tampermonkey.net/ // @version 1.0 // @description 用于给word文档添加习题。在习题详情页,添加一键复制习题id按钮。复制习题id到粘贴板,手动粘贴到word文档,并添加该习题到试题蓝,最后需手动组卷。 // @author Jin // @match http://*.com/*/ques/detail/* // @match http://*.com/search* // @match http://*.com/*/ques/search* // @grant GM_setClipboard // @grant GM_setValue // @grant GM_getValue // ==/UserScript== // 习题详情页 (async function(){ 'use strict'; if( !/\/ques\/detail/.test(location.pathname) ){ return; } // 是否自动添加到试题蓝 let autoAdd2Cart = GM_getValue("autoAdd2Cart",{exId:"", expirationDate:0}); let exId = location.pathname.split("/").pop(); if( autoAdd2Cart.exId === exId && autoAdd2Cart.expirationDate > Date.now() ){ await new Promise( r => setTimeout(r, 1000) ); document.querySelector("i.i-add")?.click(); // 关闭页面 await new Promise(r => {setTimeout(close, 5*1000);}); return; } // 插入按钮【ID+】 let count=0; document.querySelectorAll(".fieldtip-right") .forEach(parentElement=>{ parentElement.insertBefore(createButton(), parentElement.firstElementChild); count++; }); function createButton(){ let newElement = document.createElement('div'); newElement.innerHTML = '<a href="javascript:void(0)" style="font-family:math" title="油猴脚本,复制当前习题id,添加到试题蓝"><i class="icon i-orange-down"></i>ID+</a>'; newElement = newElement.firstElementChild; // 功能脚本 newElement.onclick = async function(event){ let fieldset = event.currentTarget.parentElement.parentElement.previousElementSibling; GM_setClipboard("【id】"+fieldset.id); event.currentTarget.textContent = fieldset.id.left(3)+"···"+fieldset.id.substr(fieldset.id.length-3,3); document.querySelector("i.i-add")?.click(); } return newElement; } })(); // 搜索或组卷 页面 (async function(){ 'use strict'; if( !/\/search/.test(location.pathname) ){ return; } // 等待习题载入 while(!document.querySelector(".fieldtip-right")){ await new Promise(r => {setTimeout(r, 1000);}); } // 插入 单题 复制按钮 let count=0; document.querySelectorAll(".fieldtip-right") .forEach(parentElement=>{ parentElement.insertBefore(createButton(), parentElement.firstElementChild); count++; }); // 复制整题 function createButton(){ let newElement = document.createElement('div'); newElement.innerHTML = '<a href="javascript:void(0)" style="font-family:math" title="油猴脚本,复制当前习题id,打开习题页面,添加到试题蓝"><i class="icon i-orange-down"></i>ID+</a>'; newElement = newElement.firstElementChild; // 功能脚本 newElement.onclick = async function(event){ let fieldset = event.currentTarget.parentElement.parentElement.previousElementSibling; GM_setClipboard("【id】"+fieldset.id+"\n\n"); event.currentTarget.textContent = fieldset.id.left(3)+"···"+fieldset.id.substr(fieldset.id.length-3,3); // 保存信息 let autoAdd2Cart={exId : fieldset.id, expirationDate: Date.now()+5*1000}; await GM_setValue("autoAdd2Cart", autoAdd2Cart); // 点击题干, await new Promise(r => {setTimeout(r, 300);}); fieldset.querySelector("div.pt1").click(); // 跳转页面, 自动添加到试题蓝 } return newElement; } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址