Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <body>
- Colours: <input type="text" value="c6ea395d" id="colorIn">
- <br>
- Text: <input type="text" value="text" id="textIn">
- <br>
- Random? <input type="checkbox" id="random"><br>
- Bold <input type="checkbox" id="bold"><br>
- Italic <input type="checkbox" id="italic"><br>
- Underline <input type="checkbox" id="under"><br>
- Strikethrough <input type="checkbox" id="strike"><br>
- <button onclick="makePretty()"> make fabulous</button>
- <br><br>
- <input type="text" value="" id="copy" >
- <br>
- <p>Click the button below to copy to clipboard</p>
- <button style=" background-color:#777777;font-size:30px;" id="preview" onclick="copy()"> Preview </button>
- <br><br>
- Presets:
- <br>
- <button onclick="getElementById('colorIn').value ='c6ea395d';getElementById('random').checked = false;">Rainbow</button>
- <button onclick="getElementById('colorIn').value ='1234567890abcdef';getElementById('random').checked = true;">All Colours</button>
- <br>
- <br>
- <div style="background-color:#777777;">
- <div style="color:#000000;"> 0 = Black </div>
- <div style="color:#0000aa;"> 1 = Dark Blue </div>
- <div style="color:#00aa00;"> 2 = Dark Green </div>
- <div style="color:#00aaaa;"> 3 = Aqua </div>
- <div style="color:#aa0000;"> 4 = Dark Red </div>
- <div style="color:#aa00aa;"> 5 = Purple </div>
- <div style="color:#aaaa00;"> 6 = Orange </div>
- <div style="color:#aaaaaa;"> 7 = Light Grey </div>
- <div style="color:#555555;"> 8 = Dark Grey </div>
- <div style="color:#5555ff;"> 9 = Blue </div>
- <div style="color:#55ff55;"> a = Light Green </div>
- <div style="color:#55ffff;"> b = Light Blue </div>
- <div style="color:#ff5555;"> c = Light Red </div>
- <div style="color:#ff55ff;"> d = Pink </div>
- <div style="color:#ffff55;"> e = Yellow </div>
- <div style="color:#000000;"> f = White </div>
- </div>
- <br>
- <script>
- var copyText;
- var mcColors = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];
- var htmlColors = ["000000","0000aa","00aa00","00aaaa","aa0000","aa00aa","aaaa00","aaaaaa","555555","5555ff","55ff55","55ffff","ff5555","ff55ff","ffff55","ffffff"];
- //colour code part
- function makePretty() {
- var textIn = document.getElementById("textIn").value;
- var text = [...textIn];
- var colorIn = document.getElementById("colorIn").value;
- var colors = [...colorIn];
- var textOut = "§" + text.join("§");
- var thisColor;
- var lastColor;
- var loopNum = 0;
- var formatting = "<formatting style='";
- //spaces don't need colour codes smdh
- while (textOut.includes("§ ")) {
- textOut = textOut.replace("§ ", " ");
- }
- while (textOut.includes("§")) {
- if (document.getElementById("random").checked) {
- thisColor = "&" + colors[Math.floor(Math.random() * colors.length)];
- } else {
- thisColor = "&" + colors[loopNum-colors.length*Math.floor(loopNum/colors.length)];
- loopNum++
- }
- if (document.getElementById("bold").checked) {
- thisColor = thisColor.concat("&l");
- }
- if (document.getElementById("italic").checked) {
- thisColor = thisColor.concat("&o");
- }
- if (document.getElementById("under").checked) {
- thisColor = thisColor.concat("&n");
- }
- if (document.getElementById("strike").checked) {
- thisColor = thisColor.concat("&m");
- }
- //remove duplicate colours
- if (thisColor == lastColor) {
- textOut = textOut.replace("§", "");
- } else {
- textOut = textOut.replace("§", thisColor);
- }
- lastColor = thisColor;
- }
- if (document.getElementById("bold").checked) {
- formatting = formatting.concat("font-weight: bold;");
- }
- if (document.getElementById("italic").checked) {
- formatting = formatting.concat("font-style: italic;");
- }
- formatting = formatting.concat("text-decoration:");
- if (document.getElementById("under").checked) {
- formatting = formatting.concat(" underline");
- }
- if (document.getElementById("strike").checked) {
- formatting = formatting.concat(" line-through");
- }
- formatting = formatting.concat(";'>");
- previewText = textOut;
- document.getElementById("copy").value = textOut;
- //preview part
- loopNum = 0;
- previewText = previewText.replace(/&l/g, "");
- previewText = previewText.replace(/&m/g, "");
- previewText = previewText.replace(/&n/g, "");
- previewText = previewText.replace(/&o/g, "");
- matchColor = previewText.match(/(?<=\&)(.)/g);
- previewText = previewText.replace("&"+ matchColor[loopNum], "<yeet style='color:#"+(htmlColors[mcColors.indexOf(matchColor[loopNum])])+"'>");
- while (previewText.includes("&")) {
- console.log(loopNum);
- console.log(matchColor[loopNum]);
- previewText = previewText.replace("&"+ matchColor[loopNum], "</yeet><yeet style='color:#"+(htmlColors[mcColors.indexOf(matchColor[loopNum])])+"'>");
- loopNum++;
- }
- document.getElementById("preview").innerHTML = formatting + previewText + "</yeet> </formatting>";
- }
- function copy() {
- console.log("does this work?");
- var copyText = document.getElementById("copy");
- copyText.select();
- copyText.setSelectionRange(0, 99999);
- document.execCommand("copy");
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment