간혹 URL을 타이핑해서 옮겨야할 때가 있는데 주소 문자열에 숫자1, 영어 대문자I, 영어 소문자l, 영어 대문자 O, 숫자 0 등이 무작위로 섞여 있어서 헷갈릴 때가 있다. 0,1,O는 상대적으로 괜찮은데 l과 I가 가장 문제. 물론 폰트 지정이 가능한 에디터를 열고 해당 문자열 구분이 쉬운 폰트로 바꿔서 확인할 수도 있으나 더 간단한 방법을 찾고 싶었다. 챗GPT에게 물어봤고 시키는대로(…) 북마크바에 새 북마크 만들기를 한 후에 아래 코드를 URL을 넣은 북마클릿을 생성했다. 문자열을 복사한 후 해당 북마크릿을 열고 붙여넣으니 알아보기 쉬운 폰트와 색깔로 구별되게 해줬다.
javascript:(function(){
var text = prompt('확인할 텍스트를 붙여넣으세요:');
if (!text) return;
var popup = window.open('', '', 'width=600,height=400');
var html = '<html><head><style>';
html += 'body{font-family:monospace;font-size:20px;white-space:pre-wrap;padding:20px;}';
html += 'span.num{color:red;} span.upper{color:blue;} span.lower{color:black;}';
html += '</style></head><body>';
for (var i=0; i<text.length; i++) {
var ch = text[i];
if (/[0-9]/.test(ch)) {
html += '<span class="num">' + ch + '</span>';
} else if (/[A-Z]/.test(ch)) {
html += '<span class="upper">' + ch + '</span>';
} else if (/[a-z]/.test(ch)) {
html += '<span class="lower">' + ch + '</span>';
} else {
html += ch;
}
}
html += '</body></html>';
popup.document.write(html);
popup.document.close();
})();
