mirror of
https://github.com/elder-plinius/P4RS3LT0NGV3.git
synced 2026-05-11 12:07:14 +02:00
200 lines
8.1 KiB
JavaScript
200 lines
8.1 KiB
JavaScript
// Text transformation functions
|
||
const transforms = {
|
||
// Basic transforms
|
||
upside_down: {
|
||
name: 'Upside Down',
|
||
map: {
|
||
'a': 'ɐ', 'b': 'q', 'c': 'ɔ', 'd': 'p', 'e': 'ǝ', 'f': 'ɟ', 'g': 'ƃ', 'h': 'ɥ', 'i': 'ᴉ',
|
||
'j': 'ɾ', 'k': 'ʞ', 'l': 'l', 'm': 'ɯ', 'n': 'u', 'o': 'o', 'p': 'd', 'q': 'b', 'r': 'ɹ',
|
||
's': 's', 't': 'ʇ', 'u': 'n', 'v': 'ʌ', 'w': 'ʍ', 'x': 'x', 'y': 'ʎ', 'z': 'z',
|
||
'A': '∀', 'B': 'B', 'C': 'Ɔ', 'D': 'D', 'E': 'Ǝ', 'F': 'Ⅎ', 'G': 'פ', 'H': 'H', 'I': 'I',
|
||
'J': 'ſ', 'K': 'K', 'L': '˥', 'M': 'W', 'N': 'N', 'O': 'O', 'P': 'Ԁ', 'Q': 'Q', 'R': 'R',
|
||
'S': 'S', 'T': '┴', 'U': '∩', 'V': 'Λ', 'W': 'M', 'X': 'X', 'Y': '⅄', 'Z': 'Z',
|
||
'0': '0', '1': 'Ɩ', '2': 'ᄅ', '3': 'Ɛ', '4': 'ㄣ', '5': 'ϛ', '6': '9', '7': 'ㄥ',
|
||
'8': '8', '9': '6', '.': '˙', ',': "'", '?': '¿', '!': '¡', '"': ',,', "'": ',',
|
||
'(': ')', ')': '(', '[': ']', ']': '[', '{': '}', '}': '{', '<': '>', '>': '<',
|
||
'&': '⅋', '_': '‾'
|
||
},
|
||
// Create reverse map for decoding
|
||
reverseMap: function() {
|
||
const revMap = {};
|
||
for (const [key, value] of Object.entries(this.map)) {
|
||
revMap[value] = key;
|
||
}
|
||
return revMap;
|
||
},
|
||
func: function(text) {
|
||
return [...text].map(c => this.map[c] || c).reverse().join('');
|
||
},
|
||
preview: function(text) {
|
||
return this.func(text);
|
||
},
|
||
reverse: function(text) {
|
||
const revMap = this.reverseMap();
|
||
return [...text].map(c => revMap[c] || c).reverse().join('');
|
||
}
|
||
},
|
||
|
||
elder_futhark: {
|
||
name: 'Elder Futhark',
|
||
map: {
|
||
'a': 'ᚨ', 'b': 'ᛒ', 'c': 'ᛲ', 'd': 'ᛞ', 'e': 'ᛖ', 'f': 'ᚠ', 'g': 'ᚷ', 'h': 'ᚺ', 'i': 'ᛁ',
|
||
'j': 'ᛃ', 'k': 'ᛲ', 'l': 'ᛚ', 'm': 'ᛗ', 'n': 'ᚾ', 'o': 'ᛟ', 'p': 'ᛈ', 'q': 'ᛲᛩ', 'r': 'ᚱ',
|
||
's': 'ᛋ', 't': 'ᛏ', 'u': 'ᚢ', 'v': 'ᛩ', 'w': 'ᛩ', 'x': 'ᛲᛋ', 'y': 'ᛁ', 'z': 'ᛉ'
|
||
},
|
||
func: function(text) {
|
||
return [...text.toLowerCase()].map(c => this.map[c] || c).join('');
|
||
},
|
||
preview: function(text) {
|
||
return this.func(text);
|
||
}
|
||
},
|
||
|
||
vaporwave: {
|
||
name: 'Vaporwave',
|
||
func: function(text) {
|
||
return [...text].join(' ');
|
||
},
|
||
preview: function(text) {
|
||
return this.func(text);
|
||
}
|
||
},
|
||
|
||
zalgo: {
|
||
name: 'Zalgo',
|
||
marks: [
|
||
'\u0300', '\u0301', '\u0302', '\u0303', '\u0304', '\u0305', '\u0306', '\u0307', '\u0308',
|
||
'\u0309', '\u030A', '\u030B', '\u030C', '\u030D', '\u030E', '\u030F', '\u0310', '\u0311',
|
||
'\u0312', '\u0313', '\u0314', '\u0315', '\u031A', '\u031B', '\u033D', '\u033E', '\u033F'
|
||
],
|
||
func: function(text) {
|
||
return [...text].map(c => {
|
||
let result = c;
|
||
for (let i = 0; i < Math.floor(Math.random() * 3) + 1; i++) {
|
||
result += this.marks[Math.floor(Math.random() * this.marks.length)];
|
||
}
|
||
return result;
|
||
}).join('');
|
||
},
|
||
preview: function(text) {
|
||
return this.func(text);
|
||
}
|
||
},
|
||
|
||
small_caps: {
|
||
name: 'Small Caps',
|
||
map: {
|
||
'a': 'ᴀ', 'b': 'ʙ', 'c': 'ᴄ', 'd': 'ᴅ', 'e': 'ᴇ', 'f': 'ꜰ', 'g': 'ɢ', 'h': 'ʜ', 'i': 'ɪ',
|
||
'j': 'ᴊ', 'k': 'ᴋ', 'l': 'ʟ', 'm': 'ᴍ', 'n': 'ɴ', 'o': 'ᴏ', 'p': 'ᴘ', 'q': 'ǫ', 'r': 'ʀ',
|
||
's': 's', 't': 'ᴛ', 'u': 'ᴜ', 'v': 'ᴠ', 'w': 'ᴡ', 'x': 'x', 'y': 'ʏ', 'z': 'ᴢ'
|
||
},
|
||
func: function(text) {
|
||
return [...text.toLowerCase()].map(c => this.map[c] || c).join('');
|
||
},
|
||
preview: function(text) {
|
||
return this.func(text);
|
||
}
|
||
},
|
||
|
||
braille: {
|
||
name: 'Braille',
|
||
map: {
|
||
'a': '⠁', 'b': '⠃', 'c': '⠉', 'd': '⠙', 'e': '⠑', 'f': '⠋', 'g': '⠛', 'h': '⠓', 'i': '⠊',
|
||
'j': '⠚', 'k': '⠅', 'l': '⠇', 'm': '⠍', 'n': '⠝', 'o': '⠕', 'p': '⠏', 'q': '⠟', 'r': '⠗',
|
||
's': '⠎', 't': '⠞', 'u': '⠥', 'v': '⠧', 'w': '⠺', 'x': '⠭', 'y': '⠽', 'z': '⠵',
|
||
'0': '⠼⠚', '1': '⠼⠁', '2': '⠼⠃', '3': '⠼⠉', '4': '⠼⠙', '5': '⠼⠑',
|
||
'6': '⠼⠋', '7': '⠼⠛', '8': '⠼⠓', '9': '⠼⠊'
|
||
},
|
||
func: function(text) {
|
||
return [...text.toLowerCase()].map(c => this.map[c] || c).join('');
|
||
},
|
||
preview: function(text) {
|
||
return this.func(text);
|
||
}
|
||
},
|
||
|
||
bubble: {
|
||
name: 'Bubble',
|
||
map: {
|
||
'a': 'ⓐ', 'b': 'ⓑ', 'c': 'ⓒ', 'd': 'ⓓ', 'e': 'ⓔ', 'f': 'ⓕ', 'g': 'ⓖ', 'h': 'ⓗ', 'i': 'ⓘ',
|
||
'j': 'ⓙ', 'k': 'ⓚ', 'l': 'ⓛ', 'm': 'ⓜ', 'n': 'ⓝ', 'o': 'ⓞ', 'p': 'ⓟ', 'q': 'ⓠ', 'r': 'ⓡ',
|
||
's': 'ⓢ', 't': 'ⓣ', 'u': 'ⓤ', 'v': 'ⓥ', 'w': 'ⓦ', 'x': 'ⓧ', 'y': 'ⓨ', 'z': 'ⓩ',
|
||
'A': 'Ⓐ', 'B': 'Ⓑ', 'C': 'Ⓒ', 'D': 'Ⓓ', 'E': 'Ⓔ', 'F': 'Ⓕ', 'G': 'Ⓖ', 'H': 'Ⓗ', 'I': 'Ⓘ',
|
||
'J': 'Ⓙ', 'K': 'Ⓚ', 'L': 'Ⓛ', 'M': 'Ⓜ', 'N': 'Ⓝ', 'O': 'Ⓞ', 'P': 'Ⓟ', 'Q': 'Ⓠ', 'R': 'Ⓡ',
|
||
'S': 'Ⓢ', 'T': 'Ⓣ', 'U': 'Ⓤ', 'V': 'Ⓥ', 'W': 'Ⓦ', 'X': 'Ⓧ', 'Y': 'Ⓨ', 'Z': 'Ⓩ'
|
||
},
|
||
func: function(text) {
|
||
return [...text].map(c => this.map[c] || c).join('');
|
||
},
|
||
preview: function(text) {
|
||
return this.func(text);
|
||
}
|
||
},
|
||
|
||
morse: {
|
||
name: 'Morse Code',
|
||
map: {
|
||
'a': '.-', 'b': '-...', 'c': '-.-.', 'd': '-..', 'e': '.', 'f': '..-.',
|
||
'g': '--.', 'h': '....', 'i': '..', 'j': '.---', 'k': '-.-', 'l': '.-..',
|
||
'm': '--', 'n': '-.', 'o': '---', 'p': '.--.', 'q': '--.-', 'r': '.-.',
|
||
's': '...', 't': '-', 'u': '..-', 'v': '...-', 'w': '.--', 'x': '-..-',
|
||
'y': '-.--', 'z': '--..', '0': '-----', '1': '.----', '2': '..---',
|
||
'3': '...--', '4': '....-', '5': '.....', '6': '-....', '7': '--...',
|
||
'8': '---..', '9': '----.'
|
||
},
|
||
// Create reverse map for decoding
|
||
reverseMap: function() {
|
||
const revMap = {};
|
||
for (const [key, value] of Object.entries(this.map)) {
|
||
revMap[value] = key;
|
||
}
|
||
return revMap;
|
||
},
|
||
func: function(text, decode = false) {
|
||
if (decode) {
|
||
// Decode mode
|
||
const revMap = this.reverseMap();
|
||
return text.split(/\s+/).map(c => revMap[c] || c).join('');
|
||
} else {
|
||
// Encode mode
|
||
return [...text.toLowerCase()].map(c => this.map[c] || c).join(' ');
|
||
}
|
||
},
|
||
preview: function(text) {
|
||
return this.func(text);
|
||
},
|
||
reverse: function(text) {
|
||
return this.func(text, true);
|
||
}
|
||
},
|
||
|
||
binary: {
|
||
name: 'Binary',
|
||
func: function(text) {
|
||
return [...text].map(c => c.charCodeAt(0).toString(2).padStart(8, '0')).join(' ');
|
||
},
|
||
preview: function(text) {
|
||
return this.func(text);
|
||
},
|
||
reverse: function(text) {
|
||
// Remove spaces and ensure we have valid binary
|
||
const binText = text.replace(/\s+/g, '');
|
||
let result = '';
|
||
|
||
// Process 8 bits at a time
|
||
for (let i = 0; i < binText.length; i += 8) {
|
||
const byte = binText.substr(i, 8);
|
||
if (byte.length === 8) {
|
||
result += String.fromCharCode(parseInt(byte, 2));
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
}
|
||
// Note: other transforms don't have reverse functions because they're not easily reversible
|
||
// The universal decoder will only try to reverse transforms that have a reverse function
|
||
};
|
||
|
||
// Export transforms for use in app.js
|
||
window.transforms = transforms;
|