initial commit
This commit is contained in:
132
html/index.html
Normal file
132
html/index.html
Normal file
@@ -0,0 +1,132 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<meta name="author" content="Victor Giers">
|
||||
<meta charset="utf-8" />
|
||||
<link rel="icon" type="image/x-icon" href="icon.ico">
|
||||
<title>Obfuskator (JS-Version)</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: sans-serif;
|
||||
margin: 20px;
|
||||
}
|
||||
textarea {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
min-height: 300px;
|
||||
}
|
||||
button {
|
||||
margin-right: 10px;
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Obfuskator</h1>
|
||||
|
||||
<!-- Textbereich für mehrzeilige Eingaben -->
|
||||
<textarea id="textInput" placeholder="Hier deinen Text eingeben..."></textarea>
|
||||
|
||||
<br />
|
||||
|
||||
<!-- Buttons -->
|
||||
<button id="obfuskateBtn">Obfuskate</button>
|
||||
<button id="copyBtn">Copy to Clipboard</button>
|
||||
<button id="infoBtn">Info</button>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* Mischt (zufällig) alle Buchstaben zwischen dem ersten und letzten Buchstaben eines Wortes.
|
||||
* Erster und letzter Buchstabe bleiben an ihrem Platz.
|
||||
*/
|
||||
function shuffleMiddle(word) {
|
||||
if (word.length <= 2) {
|
||||
return word; // Bei 1 oder 2 Buchstaben kein Mischen nötig
|
||||
}
|
||||
const firstChar = word[0];
|
||||
const lastChar = word[word.length - 1];
|
||||
// Mittlerer Teil als Array
|
||||
let middle = word.slice(1, -1).split('');
|
||||
|
||||
// Fisher-Yates-Shuffle
|
||||
for (let i = middle.length - 1; i > 0; i--) {
|
||||
const j = Math.floor(Math.random() * (i + 1));
|
||||
[middle[i], middle[j]] = [middle[j], middle[i]];
|
||||
}
|
||||
|
||||
// Zusammenbauen
|
||||
return firstChar + middle.join('') + lastChar;
|
||||
}
|
||||
|
||||
/**
|
||||
* Diese Funktion durchsucht einen Text nach "Wörtern" (inkl. Umlaute),
|
||||
* prüft, ob sie komplett groß sind oder ob sie mit einem Großbuchstaben beginnen,
|
||||
* und obfuskiert sie entsprechend.
|
||||
*/
|
||||
function obfuskateText(text) {
|
||||
// \p{L} erfasst Unicode-Buchstaben. 'u'-Flag erforderlich.
|
||||
// \b = Wortgrenzen; so matchen wir nur reine Buchstaben-Wörter.
|
||||
const regex = /\b[\p{L}]+\b/gu;
|
||||
|
||||
return text.replace(regex, (match) => {
|
||||
// Vollständig groß?
|
||||
if (match === match.toUpperCase()) {
|
||||
// FULL-CAPS: Mischen + kleinschreiben
|
||||
return shuffleMiddle(match).toLowerCase();
|
||||
}
|
||||
// Nur erster Buchstabe groß?
|
||||
else if (match[0] === match[0].toUpperCase()) {
|
||||
// Mischen, Groß-/Kleinschreibung der Zeichen bleibt erhalten
|
||||
return shuffleMiddle(match);
|
||||
}
|
||||
// Nicht betroffen
|
||||
else {
|
||||
return match;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Warten, bis das DOM geladen ist
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const textArea = document.getElementById('textInput');
|
||||
const btnObfuskate = document.getElementById('obfuskateBtn');
|
||||
const btnCopy = document.getElementById('copyBtn');
|
||||
const btnInfo = document.getElementById('infoBtn');
|
||||
|
||||
// "Obfuskate"-Button
|
||||
btnObfuskate.addEventListener('click', () => {
|
||||
const currentText = textArea.value;
|
||||
const obfuskated = obfuskateText(currentText);
|
||||
textArea.value = obfuskated;
|
||||
});
|
||||
|
||||
// "Copy to Clipboard"-Button
|
||||
btnCopy.addEventListener('click', () => {
|
||||
const currentText = textArea.value;
|
||||
// Moderne Browser-API
|
||||
navigator.clipboard.writeText(currentText)
|
||||
.then(() => {
|
||||
alert("Text wurde in die Zwischenablage kopiert!");
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error("Fehler beim Kopieren:", err);
|
||||
});
|
||||
});
|
||||
|
||||
// "Info"-Button
|
||||
btnInfo.addEventListener('click', () => {
|
||||
alert(
|
||||
"Dieses Tool obfuskiert den Inhalt im Textfeld:\n\n" +
|
||||
"- Vollständig großgeschriebene Wörter (z.B. TEST) werden " +
|
||||
"gemischt und dann in Kleinschreibung umgewandelt.\n" +
|
||||
"- Wörter, die mit einem Großbuchstaben beginnen (z.B. Hallo), " +
|
||||
"werden nur in der Mitte durchmischt, Groß- und Kleinschreibung bleibt erhalten.\n\n" +
|
||||
"Du kannst den veränderten Text danach kopieren und woanders einfügen."
|
||||
);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user