Teilen-Button, Klartext-Hinweis und README aktualisiert (WLAN-Passwort im Link sichtbar)

This commit is contained in:
Markus Busche
2025-07-08 11:59:35 +02:00
parent 9c5d022604
commit 5478d943e5
3 changed files with 63 additions and 2 deletions

View File

@@ -11,6 +11,8 @@ Dieses Projekt basiert auf dem Code von https://qr.alster.space/. Er wurde um ve
- Anpassbare Größen und Farben - Anpassbare Größen und Farben
- Verschiedene Fehlerkorrektur-Level - Verschiedene Fehlerkorrektur-Level
- Download-Funktion - Download-Funktion
- Teilen-Funktion (Link mit aktuellen Einstellungen kopieren)
- Hinweis bei WiFi: Passwort im Link im Klartext
- Responsive Design - Responsive Design
- WiFi QR-Code Unterstützung mit eigener UI - WiFi QR-Code Unterstützung mit eigener UI
- Dynamische Klartext-Anzeige - Dynamische Klartext-Anzeige
@@ -90,6 +92,8 @@ http://localhost:8080/?ssid=MeinWLAN&password=MeinPasswort123
http://localhost:8080/?ssid=OffenesWLAN http://localhost:8080/?ssid=OffenesWLAN
``` ```
**Achtung:** Das WLAN-Passwort ist im Link im Klartext sichtbar!
## WiFi QR-Code Format ## WiFi QR-Code Format
Die App generiert automatisch QR-Codes im Standard-WiFi-Format: Die App generiert automatisch QR-Codes im Standard-WiFi-Format:
@@ -127,6 +131,12 @@ Das Smartphone erkennt automatisch, dass es sich um WiFi-Daten handelt und biete
- WiFi-Passwort ohne SSID wird als Fehler angezeigt - WiFi-Passwort ohne SSID wird als Fehler angezeigt
- Leere Eingaben werden entsprechend behandelt - Leere Eingaben werden entsprechend behandelt
### Teilen-Funktion
Mit dem Button "Teilen" kann ein Link mit allen aktuellen Einstellungen (inkl. WiFi-Daten) in die Zwischenablage kopiert werden. Dieser Link kann weitergegeben werden und öffnet die App direkt mit den gewählten Einstellungen.
**Achtung:** Wenn ein WLAN-Passwort eingegeben ist, wird dieses im Link im Klartext übertragen!
## Sicherheit & Content Security Policy (CSP) ## Sicherheit & Content Security Policy (CSP)
Die Anwendung ist gegen XSS-Angriffe abgesichert: Die Anwendung ist gegen XSS-Angriffe abgesichert:

File diff suppressed because one or more lines are too long

47
main.js
View File

@@ -16,6 +16,8 @@ document.addEventListener('DOMContentLoaded', function() {
const infoPanel = document.getElementById('info-panel'); const infoPanel = document.getElementById('info-panel');
const infoClose = document.getElementById('info-close'); const infoClose = document.getElementById('info-close');
const titleElement = document.getElementById('title'); const titleElement = document.getElementById('title');
const shareBtn = document.getElementById('share');
const shareHint = document.getElementById('share-hint');
// Title Easter egg // Title Easter egg
let titleClickCount = 0; let titleClickCount = 0;
@@ -292,4 +294,49 @@ document.addEventListener('DOMContentLoaded', function() {
// Update clear button visibility // Update clear button visibility
toggleClearButton(); toggleClearButton();
} }
function updateShareHint() {
const wifiPassword = wifiPasswordInput.value.trim();
if (wifiPassword) {
shareHint.style.display = 'block';
} else {
shareHint.style.display = 'none';
}
}
wifiPasswordInput.addEventListener('input', updateShareHint);
wifiSsidInput.addEventListener('input', updateShareHint);
textInput.addEventListener('input', updateShareHint);
// Initial anzeigen, falls Passwort schon gesetzt
updateShareHint();
shareBtn.addEventListener('click', function() {
const params = new URLSearchParams();
const text = textInput.value.trim();
const wifiSsid = wifiSsidInput.value.trim();
const wifiPassword = wifiPasswordInput.value.trim();
const size = sizeSelect.value;
const errorCorrection = errorCorrectionSelect.value;
const fgColor = foregroundColor.value;
const bgColor = backgroundColor.value;
// Entscheide, was kodiert werden soll
if (wifiSsid) params.set('ssid', wifiSsid);
if (wifiPassword) params.set('password', wifiPassword);
if (!wifiSsid && !wifiPassword && text) params.set('text', text);
if (size !== '256') params.set('size', size);
if (errorCorrection !== 'M') params.set('errorCorrection', errorCorrection);
if (fgColor !== '#000000') params.set('foreground', fgColor);
if (bgColor !== '#ffffff') params.set('background', bgColor);
const url = window.location.origin + window.location.pathname + '?' + params.toString();
// In Zwischenablage kopieren
navigator.clipboard.writeText(url).then(() => {
const original = shareBtn.textContent;
shareBtn.textContent = 'Link kopiert!';
setTimeout(() => { shareBtn.textContent = original; }, 2000);
}, () => {
alert('Konnte Link nicht kopieren.');
});
});
}); });