Panama Red Hotfix 1: removed - and _ from username symbol mask, embedded links in chat now open in new tab, links to imgur posts now embed as .gif's (ie: https://imgur.com/C2okGV6)

This commit is contained in:
rainbownapkin 2022-02-06 02:14:51 +00:00
parent 9455fd8964
commit 8ca4aa4327

View file

@ -14,15 +14,20 @@ function checkMedia(fname){//check if link points ot media
} }
function checkEmbed(word, isEmote){ function checkEmbed(word, isEmote){
let regex = /[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/g;//symbol mask for username let regex = /[!"#$%&'()*+,./:;<=>?@[\]^`{|}~]/g;//symbol mask for username
let tregex = /["#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/g;//symbol mask for tokes let tregex = /["#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/g;//symbol mask for tokes
let stripd = word.replace(regex, '');//stripped word for username detection let stripd = word.replace(regex, '');//stripped word for username detection
let tstripd = word.replace(tregex, '');//stripeed word for !toke command detection let tstripd = word.replace(tregex, '');//stripeed word for !toke command detection
if(word.includes(proto[0]) || word.includes(proto[1])){//check if it starts with a supported proto if(word.includes(proto[0]) || word.includes(proto[1])){//check if it starts with a supported proto
if(checkMedia(word) != 0){//check if media if(checkMedia(word) != 0){//check if media
return '<img src="' + word + '" style="max-height: 13em">';//embed media return '<img src="' + word + '" style="max-height: 13em">';//embed media
}else if(!isEmote){ }else if(!isEmote){//if its a link
return '<a href="' + word + '">' + word + '</a>';//embed link if(word.includes("imgur.com")){
if(word.length > 20 && word.length < 28){
return '<img src="' + word + ".gif" + '" style="max-height: 13em">';//embed media
}
}
return '<a target="_blank" href="' + word + '">' + word + '</a>';//embed link
}else{ }else{
return word; return word;
} }