Quiz-Modus für 50ohm.de per Tampermonkey
Quiz-Modus für 50ohm.de per Tampermonkey
Für die Vorbereitung auf die Klasse-A-Prüfung nutze ich 50ohm.de – eine wirklich gut gemachte Lernplattform des DARC.
Beim Lernen wollte ich aber einen reinen Quiz-Modus: nur die BNetzA-Fragen, ohne Erklärungstexte und Abbildungen drumherum.
Erst lesen und selbst beantworten, dann zum Nachlesen zurückschalten.
Also ein kleines Tampermonkey-Script.
Was es macht
Ein Klick auf den Button oben rechts versteckt alles außer den Fragen mit ihren Antwortmöglichkeiten.
Die Hauptüberschrift bleibt sichtbar, und ab dem „Weiter zum nächsten Abschnitt"-Link am Ende der Seite wird ebenfalls wieder alles normal angezeigt.
Auf Übersichtsseiten ohne Fragen (z. B. Kapitelauswahl) bleibt die Seite unverändert – dort erscheint stattdessen ein kleiner Hinweis, dass nichts zum Ausblenden da ist.
Der Zustand wird im Browser gespeichert: einmal eingeschaltet, bleibt der Quiz-Modus auch beim Wechsel zur nächsten Lektion aktiv.
Einrichtung in Tampermonkey
Falls Tampermonkey noch nicht installiert ist: aus dem Chrome Web Store oder von tampermonkey.net holen. Für Firefox und Edge gibt es entsprechende Addons.
Dann:
- Auf das Tampermonkey-Icon in der Browser-Leiste klicken → „Dashboard".
- Oben auf den
+-Tab klicken – es öffnet sich ein Editor mit einem leeren Userscript-Template. - Das Template komplett löschen und den Code unten einfügen.
- Mit
Strg+Sspeichern – das Script ist direkt aktiv.
Zum Benutzen einfach eine Lernseite auf 50ohm.de öffnen – oben rechts erscheint ein Button. Ein Klick schaltet in den Quiz-Modus, ein zweiter Klick holt die Erklärungen zurück.
Das Userscript
// ==UserScript==
// @name 50ohm.de Quiz-Modus
// @namespace https://50ohm.de/
// @version 0.3.0
// @description Blendet Erklärungen aus und zeigt nur die Prüfungsfragen.
// @author DN9KGB
// @match https://50ohm.de/*.html
// @match https://www.50ohm.de/*.html
// @grant none
// @run-at document-idle
// ==/UserScript==
(function () {
'use strict';
const BTN_ID = 'quiz-mode-toggle';
const NOTICE_ID = 'quiz-mode-notice';
const STYLE_ID = 'quiz-mode-style';
const STORAGE_KEY = 'quiz-mode-enabled';
const QUIZ_CLASS = 'quiz-mode-active';
const HAS_Q_CLASS = 'quiz-has-questions';
function injectStyles() {
if (document.getElementById(STYLE_ID)) return;
const s = document.createElement('style');
s.id = STYLE_ID;
s.textContent = `
#${BTN_ID} {
position: fixed; top: 12px; right: 12px; z-index: 99999;
padding: 8px 14px;
font: 600 14px/1 system-ui, -apple-system, sans-serif;
color: #fff; background: #c00;
border: none; border-radius: 6px;
box-shadow: 0 2px 8px rgba(0,0,0,.25);
cursor: pointer; user-select: none;
}
#${BTN_ID}:hover { filter: brightness(1.1); }
#${BTN_ID}.active { background: #0a7a2a; }
#${NOTICE_ID} {
position: fixed; top: 54px; right: 12px; z-index: 99999;
max-width: 260px; padding: 8px 12px;
font: 500 13px/1.35 system-ui, -apple-system, sans-serif;
color: #333; background: #fff3cd;
border: 1px solid #ffe69c; border-radius: 6px;
box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
body.${QUIZ_CLASS}.${HAS_Q_CLASS} .course > * {
display: none !important;
}
body.${QUIZ_CLASS}.${HAS_Q_CLASS} .course > h1,
body.${QUIZ_CLASS}.${HAS_Q_CLASS} .course > nav,
body.${QUIZ_CLASS}.${HAS_Q_CLASS} .course > .question,
body.${QUIZ_CLASS}.${HAS_Q_CLASS} .course > [data-quiz-tail],
body.${QUIZ_CLASS}.${HAS_Q_CLASS} .course > [data-quiz-tail] ~ * {
display: revert !important;
}
`;
document.head.appendChild(s);
}
function pageHasQuestions() {
return document.querySelector('.course .question') !== null;
}
function tagSectionTail() {
const course = document.querySelector('.course');
if (!course) return false;
course.querySelectorAll('[data-quiz-tail]').forEach(el => {
el.removeAttribute('data-quiz-tail');
});
for (const child of course.children) {
if (child.tagName !== 'DIV') continue;
const text = (child.textContent || '').toLowerCase();
if (text.includes('weiter zum nächsten abschnitt')) {
child.setAttribute('data-quiz-tail', '');
return true;
}
}
return false;
}
function showNotice(text) {
let n = document.getElementById(NOTICE_ID);
if (!n) {
n = document.createElement('div');
n.id = NOTICE_ID;
document.body.appendChild(n);
}
n.textContent = text;
}
function hideNotice() {
const n = document.getElementById(NOTICE_ID);
if (n) n.remove();
}
function createButton() {
if (document.getElementById(BTN_ID)) return;
const btn = document.createElement('button');
btn.id = BTN_ID;
btn.type = 'button';
btn.addEventListener('click', () => {
const next = !document.body.classList.contains(QUIZ_CLASS);
setQuizMode(next);
try { localStorage.setItem(STORAGE_KEY, next ? '1' : '0'); }
catch (_) { /* ignore */ }
});
document.body.appendChild(btn);
updateButton(btn, document.body.classList.contains(QUIZ_CLASS));
}
function updateButton(btn, on) {
btn.textContent = on ? 'Quiz-Modus: an' : 'Quiz-Modus: aus';
btn.classList.toggle('active', on);
}
function setQuizMode(on) {
const hasQ = pageHasQuestions();
document.body.classList.toggle(HAS_Q_CLASS, hasQ);
if (on && hasQ) tagSectionTail();
document.body.classList.toggle(QUIZ_CLASS, on);
const btn = document.getElementById(BTN_ID);
if (btn) updateButton(btn, on);
if (on && !hasQ) showNotice('Keine Fragen auf dieser Seite gefunden.');
else hideNotice();
}
function init() {
injectStyles();
createButton();
let initial = false;
try { initial = localStorage.getItem(STORAGE_KEY) === '1'; }
catch (_) { /* ignore */ }
if (initial) setQuizMode(true);
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', init);
} else {
init();
}
})();
Fazit
Ein kleines Stück Werkzeug, das beim täglichen Lernen einen spürbaren Unterschied macht.
50ohm.de selbst bleibt dabei unverändert – das Script läuft nur lokal im Browser und greift nicht in die Seite ein, wenn der Quiz-Modus aus ist.
73 de DN9KGB