您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
优化问卷星体验
当前为
// ==UserScript== // @name 问卷星优化 // @namespace http://tampermonkey.net/ // @version 3.0.0 // @description 优化问卷星体验 // @author share121 // @match https://ks.wjx.top/*/*.aspx // @match https://www.wjx.cn/*/*.aspx // @match https://ks.wjx.top/wjx/join/completemobile2.aspx?*activityid=* // @icon https://ks.wjx.top/favicon.ico // @grant none // @license MIT // ==/UserScript== (function () { "use strict"; //let activityId = location.pathname.match(/\/([a-zA-Z0-9]+).aspx/)[1]; function openUserSelect() { document.body.style.userSelect = "auto"; document.body.style.webkitUserSelect = "auto"; } function getBlanks() { return document.querySelectorAll( "span.textCont, input:not([type=hidden]), textarea" ); } function getChoice() { return document.querySelectorAll( "div > div.ui-controlgroup > div:is(.ui-checkbox, .ui-radio)" ); } function fillInTheBlanks(answer) { getBlanks().forEach((e, i) => { if (answer[i]) { if (e.tagName === "SPAN") { e.innerText = answer[i]; } else { e.value = answer[i]; } } }); } function fillInTheChoice(answer) { getChoice().forEach((e, i) => { answer.includes(i) && e.click(); }); } function getActivityIdChoice() { if (localStorage.getItem(`${activityId} choice`)) { return JSON.parse(localStorage.getItem(`${activityId} choice`)); } else { return null; } } function getActivityIdBlanks() { if (localStorage.getItem(`${activityId} input`)) { return JSON.parse(localStorage.getItem(`${activityId} input`)); } else { return null; } } function getBlanksValue() { return JSON.stringify( [...getBlanks()].map((e) => { if (e.tagName === "SPAN") { return e.innerText; } else { return e.value; } }) ); } function getChoiceValue() { let tmp = []; [...getChoice()].forEach( (e, i) => [...e.classList].includes("checked") && tmp.push(i) ); return JSON.stringify(tmp); } function setBlanksLastTime() { let blanks = getActivityIdBlanks(); if (blanks) { fillInTheBlanks(blanks); } } function setChoiceLastTime() { let choice = getActivityIdChoice(); if (choice) { fillInTheChoice(choice); } } function observe(action) { let observe_tmp = new MutationObserver((mutationsList) => { action(mutationsList); }); observe_tmp.observe(document.documentElement, { attributes: true, childList: true, characterData: true, subtree: true, }); return observe_tmp; } function bindingUpdates() { observe(() => { localStorage.setItem(`${activityId} input`, getBlanksValue()); localStorage.setItem(`${activityId} choice`, getChoiceValue()); }); } function newGoBackButton() { if (/activityid=/.test(location.href)) { let goBackButton = document.createElement("a"); goBackButton.href = `/vm/${ location.href.match(/activityid=([a-zA-Z0-9]+?)&/)[1] }.aspx`; goBackButton.innerText = "重做"; goBackButton.style.cssText = "display: block; margin: 0px auto; width: 200px; height: 60px; background-color: rgb(0, 149, 255); color: rgb(255, 255, 255); line-height: 60px; border-radius: 5px; font-size: 20px;"; return goBackButton; } else { return null; } } if (/activityid=/.test(location.href)) { window.addEventListener("load", () => { let goBackButton = newGoBackButton(); if (goBackButton) { document .querySelector("#divdsc") .appendChild(newGoBackButton()); } }); } else { var activityId = location.pathname.match(/\/([a-zA-Z0-9]+).aspx/)[1]; //这里必须用 var ,不要改成 let !!! openUserSelect(); window.addEventListener("load", () => { setChoiceLastTime(); setBlanksLastTime(); bindingUpdates(); }); } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址