One-Line Goal
On the Chaoxing self-test question page: hide all distracting elements first, then "Print → Save as PDF" the clean version directly.
Below is a step-by-step guide + ready-to-copy scripts. The entire workflow only uses the browser console — no plugins needed, and it's fully reversible (just refresh to restore the original page).
1. Open the Self-Test Question Page
Create a self-test and submit it → go to the self-test detail page, making sure all questions and answers are fully visible.

Detail Page
2. Paste the "Cleanup Script" into the Console
- Press F12 (or
Ctrl + Shift + I) to open DevTools, then switch to the Console tab. - Copy and paste the entire script below.
- Optional: For the first run, use highlight mode — change the last line
clean(false)toclean(true)and press Enter. All nodes about to be removed will be outlined in red. - Optional: After visually confirming nothing is wrong, type
clean(false)in the console and press Enter to actually remove them.

Console Page
/*********** Chaoxing Self-Test - Cleanup Script ***********/
const XPATH = `
(//*[starts-with(@id,'question')]/div/div/div[2]/div[1]/span[position()=1]|
//*[starts-with(@id,'question')]/div/div/div[1]/a[position()=1]|
//*[starts-with(@id,'question')]/div/div/div[2]/div[4]|
//*[starts-with(@id,'qbstuAnswer')]/dt[position()=1]|
//*[starts-with(@id,'qbstuAnswer')]//dl[1]/dt[position()=1]|
//*[@id='rightHeight']|
/html/body/div[1])
`.replace(/\s+/g, '');
function clean(highlight = false) {
const snap = document.evaluate(
XPATH, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null
);
for (let i = snap.snapshotLength - 1; i >= 0; i--) {
const n = snap.snapshotItem(i);
if (!n) continue;
highlight ? n.style.outline = '2px solid red' : n.remove();
}
console.log(`🎯 ${snap.snapshotLength} nodes ` + (highlight ? 'highlighted' : 'removed'));
}
clean(false); // ← true to preview, false to remove
/****************************************************************/
Removed Content
- Bookmark button
<a>- Correct/incorrect indicator
div[4]- My answer
<dt>span[1]- Entire right sidebar
#rightHeight- Top banner
/html/body/div[1]
3. Inject "Print-Only" CSS (Optional, for Better Layout)
If you want the PDF to look more like a formal exam paper, inject an additional print-only style:
void function () {
const style = document.createElement('style');
style.textContent = `
@media print {
body { font-size: 14px !important; line-height: 1.6; }
/* Prevent a single question from being split across two pages */
[id^="question"], [id^="qbstuAnswer"] { page-break-inside: avoid; }
/* Extra safety: hide all buttons, inputs, and JS links */
button, input, select, a[href*="javascript"] { display: none !important; }
}
`;
document.head.appendChild(style);
console.log('✅ Print styles injected');
}();
4. Export as PDF
Ctrl + P(or⌘ + Pon Mac).- Set the destination printer to "Save as PDF".
- Layout: Portrait; Margins: Default or Minimum; disable headers and footers.
- Preview looks good → Save, and you'll get a clean self-test PDF.

Export PDF
Summary
- One-click cleanup script — instantly declutters the page
- Optional Print CSS — more professional print layout
- Browser Save as PDF — zero plugins, zero dependencies
A clean, well-formatted self-test PDF is ready in no time! Happy studying 📚✨