Skip to content

Instantly share code, notes, and snippets.

@haileylgbt
Forked from falconscript/discordfonts.js
Last active December 31, 2017 07:54
Show Gist options
  • Save haileylgbt/cbba5794532201df201c6fbf1d6c439a to your computer and use it in GitHub Desktop.
Save haileylgbt/cbba5794532201df201c6fbf1d6c439a to your computer and use it in GitHub Desktop.
Some custom fonts for discord
// FalconScript - DISCORD FONTS
// These are just whatever. Pretty funny though
// Open Chrome Console (CTRL+Shift+i), then paste entire script and hit enter.
// Afterwards, type messages into a textbox. Hit the \ or | key to convert it to the new font!
var FONTS = {
"LIT": {SPACE_REPLACEMENT: '🔥', ALTERNATE_BOLD: true, BLACKLIGHTING: true },
"CLAP_EMPHASIS": {SPACE_REPLACEMENT: '👏', ALTERNATE_BOLD: false, BLACKLIGHTING: false },
"FLASHY_WORDS": { SPACE_REPLACEMENT: '✨', ALTERNATE_BOLD: true, BLACKLIGHTING: false }
};
window.ISSHIFTDOWN = false;
document.onkeydown = function (e) { if (e.keyCode == 16) { window.ISSHIFTDOWN = true; }};
document.onkeyup = function (e) { if (e.keyCode == 16) { window.ISSHIFTDOWN = false; }};
window.isCtrlDown = false;
document.onkeydown = function (e) { if (e.keyCode == 17) { window.isCtrlDown = true; }};
document.onkeyup = function (e) { if (e.keyCode == 17) { window.isCtrlDown = false; }};
function flashify (curText, FONT) {
var val = '', count = 0;
for (var i = 0; i < curText.length; i++) {
if (curText[i] == '*') {
continue;
} else if (curText[i] == ' ') {
val += curText[i];
} else {
if (FONT.BLACKLIGHTING) {
val += '`' + curText[i] + '`' + (FONT.ALTERNATE_BOLD ? '**' : '');
} else {
val += curText[i] + (FONT.ALTERNATE_BOLD ? '**' : '');
}
count++;
}
}
if (count % 2 == 1 && count > 2 && FONT.ALTERNATE_BOLD) {
var splits = val.split('**');
splits[splits.length - 2] += splits.pop();
val = splits.join('**');
}
val = val.replace(/\ /g, FONT.SPACE_REPLACEMENT);
//e.preventDefault(); e.stopPropagation(); // don't do, skips discord listeners
return val;
}
function flashifyAllTextareas() {
var els = document.getElementsByTagName('textarea');
for (var i in els) {
els[i].onkeydown = function (e) {
console.log(e.keyCode);
if ([8, 37, 38, 39, 40].indexOf(e.keyCode) != -1) return;
if (!window.ISSHIFTDOWN && e.keyCode == 220) {
this.value = flashify(this.value, FONTS["FLASHY_WORDS"]);
} else if (window.ISSHIFTDOWN && e.keyCode == 220) {
this.value = flashify(this.value, FONTS["LIT"]);
} else if (window.isCtrlDown && e.keyCode == 220) {
this.value = flashify(this.value, FONTS["CLAP_EMPHASIS"]);
}
};
}
}
// set to run every second to ensure new textareas get the listeners.
// yeah I know a delegate would be bette
setInterval(flashifyAllTextareas, 1000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment