MediaWiki:Gadget-MyCoolGadget.js: Unterschied zwischen den Versionen
Erscheinungsbild
Saya (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
Saya (Diskussion | Beiträge) Keine Bearbeitungszusammenfassung |
||
| Zeile 1: | Zeile 1: | ||
mw.loader.using(['mediawiki.util']).then(function () { | mw.loader.using(['mediawiki.util']).then(function () { | ||
document.querySelectorAll('pre').forEach(function (block) { | document.querySelectorAll('pre, .mw-highlight pre').forEach(function (block) { | ||
var button = document.createElement('button'); | var button = document.createElement('button'); | ||
button.textContent = 'Kopieren'; | button.textContent = 'Kopieren'; | ||
button.style. | button.style.float = 'right'; | ||
button.style.margin = '4px'; | |||
button.style.cursor = 'pointer'; | button.style.cursor = 'pointer'; | ||
button.addEventListener('click', function () { | button.addEventListener('click', function () { | ||
navigator.clipboard.writeText(block.innerText).then(function () { | navigator.clipboard.writeText(block.innerText).then(function () { | ||
button.textContent = '✓ | button.textContent = '✓'; | ||
setTimeout(function () { | setTimeout(function () { | ||
button.textContent = 'Kopieren'; | button.textContent = 'Kopieren'; | ||
| Zeile 18: | Zeile 18: | ||
}); | }); | ||
block.style.position = 'relative'; | |||
block.parentNode.insertBefore(button, block); | block.parentNode.insertBefore(button, block); | ||
}); | }); | ||
}); | }); | ||
Version vom 13. Februar 2026, 22:23 Uhr
mw.loader.using(['mediawiki.util']).then(function () {
document.querySelectorAll('pre, .mw-highlight pre').forEach(function (block) {
var button = document.createElement('button');
button.textContent = 'Kopieren';
button.style.float = 'right';
button.style.margin = '4px';
button.style.cursor = 'pointer';
button.addEventListener('click', function () {
navigator.clipboard.writeText(block.innerText).then(function () {
button.textContent = '✓';
setTimeout(function () {
button.textContent = 'Kopieren';
}, 2000);
});
});
block.style.position = 'relative';
block.parentNode.insertBefore(button, block);
});
});