您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Wrap spoilers in Codeforces tutorial in spoiler blocks
当前为
// ==UserScript== // @name Codeforces_spoiler_tutorial // @version 0.0.0 // @description Wrap spoilers in Codeforces tutorial in spoiler blocks // @match https://codeforces.com/blog/entry/* // @match http://codeforces.com/blog/entry/* // @run-at document-start // @namespace https://gf.qytechs.cn/users/410786 // ==/UserScript== function wrappedInSpoiler(node){ while(node!==null){ if(node.classList && node.classList.contains("spoiler")) return true; node=node.parentNode; } return false; } function wrapInSpoiler(nodes, spoilerTitle){ if(!Array.isArray(nodes)) nodes=[nodes] if(nodes.length==0) return const spoilerElement=document.createElement("div") spoilerElement.classList.add("spoiler") spoilerElement.innerHTML='<b class="spoiler-title"></b><div class="spoiler-content" style="display: none;"></div>' spoilerElement.firstElementChild.innerText=spoilerTitle nodes[0].insertAdjacentElement('beforebegin', spoilerElement); nodes.forEach(function(node){ spoilerElement.lastElementChild.appendChild(node) // "If the given child is a reference to an existing node in the document, appendChild() moves it from its current position to the new position" }) } new MutationObserver(function(mutationList, observer){ mutationList.forEach(function(mutation){ mutation.addedNodes.forEach(function(node){ if(node.classList!==undefined && node.classList.contains("problemTutorial")){ if(!wrappedInSpoiler(node)){ var spoilerTitle='Tutorial' const problemcode=node.getAttribute("problemcode") if(problemcode) spoilerTitle+=' - '+problemcode wrapInSpoiler(node, spoilerTitle) } } }) //observer.disconnect() //console.log(mutation) }) }).observe(document, { childList: true, subtree: true });
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址