Blurs all text after the first "(" in Quizlet multiple choice options, so you can add explanations or hints without giving away the answer. Press ";" to toggle blur for visible choices and review your notes after choosing.
当前为
// ==UserScript==
// @name Quizlet MCQ Explanation Blur (toggle with ;)
// @namespace http://tampermonkey.net/
// @version 1.6
// @description Blurs all text after the first "(" in Quizlet multiple choice options, so you can add explanations or hints without giving away the answer. Press ";" to toggle blur for visible choices and review your notes after choosing.
// @author OpenAI
// @match *://*.quizlet.com/*
// @grant none
// ==/UserScript==
(function () {
'use strict';
const optionIds = ['option-1','option-2','option-3','option-4'];
const selector = optionIds.map(id => `[data-testid="${id}"]`).join(',');
const BLUR_CLASS = 'qz-blur-parentheses';
// CSS for blurring
if (!document.getElementById('qz-blur-style')) {
const style = document.createElement('style');
style.id = 'qz-blur-style';
style.textContent = `
.${BLUR_CLASS} {
filter: blur(4px) !important;
user-select: none !important;
}
`;
document.head.appendChild(style);
}
function blurAfterFirstParen(el) {
if (el.dataset.parenthesesBlurred) return;
el.dataset.parenthesesBlurred = 'true';
for (const node of Array.from(el.childNodes)) {
if (node.nodeType === Node.TEXT_NODE && node.textContent.includes('(')) {
const text = node.textContent;
const idx = text.indexOf('(');
if (idx !== -1) {
const frag = document.createDocumentFragment();
if (idx > 0) {
frag.appendChild(document.createTextNode(text.slice(0, idx)));
}
const span = document.createElement('span');
span.textContent = text.slice(idx);
span.classList.add(BLUR_CLASS);
frag.appendChild(span);
el.replaceChild(frag, node);
}
} else if (node.nodeType === Node.ELEMENT_NODE) {
blurAfterFirstParen(node);
}
}
}
function main() {
document.querySelectorAll(selector).forEach(blurAfterFirstParen);
}
setInterval(main, 500);
// Semicolon (;) key toggles blur
window.addEventListener('keydown', function(e) {
if (e.key === ';' && !e.ctrlKey && !e.altKey && !e.metaKey && !e.shiftKey) {
e.preventDefault();
document.querySelectorAll(`.${BLUR_CLASS}, span[data-qz-blur-unblurred="true"]`).forEach(span => {
if (span.classList.contains(BLUR_CLASS)) {
span.classList.remove(BLUR_CLASS);
span.dataset.qzBlurUnblurred = 'true';
} else {
span.classList.add(BLUR_CLASS);
delete span.dataset.qzBlurUnblurred;
}
});
}
});
})();