软考系统架构师真题隐藏答案,添加显示答案按钮
// ==UserScript==
// @name 软考系统架构师真题隐藏答案,添加显示答案按钮
// @namespace https://blog.csdn.net/
// @version 1.1.0
// @description CSND 软考系统架构师真题 答题助手。进入页面自动隐藏答案,增加显示隐藏答案按钮。
// @author ccr
// @match https://blog.csdn.net/Last_Impression/article/details/*
// @grant none
// @run-at document-end
// ==/UserScript==
(function () {
'use strict';
// Your code here...
setTimeout(function () {
let blockquoteSubjects = document.querySelectorAll('blockquote');
console.log('blockquoteSubjects', blockquoteSubjects)
for (let i = 0; i < blockquoteSubjects.length; i++) {
let subject = blockquoteSubjects[i];
let showBut = document.createElement("a");
showBut.innerText = "显示答案";
showBut.onclick = function () {
console.log(subject)
let styleVisibilitV = subject.nextElementSibling.style.visibility;
if (styleVisibilitV === 'hidden') {
subject.nextElementSibling.style.visibility = 'visible'
showBut.innerText = "隐藏答案";
} else if (styleVisibilitV === 'visible') {
subject.nextElementSibling.style.visibility = 'hidden'
showBut.innerText = "显示答案";
}
};
let strong = subject.querySelector('strong');
if (strong) {
strong.parentElement.insertBefore(showBut, strong.nextSibling)
} else {
subject.appendChild(showBut)
}
subject.nextElementSibling.style.visibility = 'hidden'
}
}, 500)
})();