Greasy Fork

kawaiimoji

press button to convert alphabet to mini characters on caffe

目前为 2020-09-27 提交的版本。查看 最新版本

// ==UserScript==
// @name         kawaiimoji
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  press button to convert alphabet to mini characters on caffe
// @author       #kawaiirz
// @match        http://caffe.senpai-agar.online/*/
// ==/UserScript==

(function() {
    var alphabets = ['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'],
        minimoji = ['ᴀ','ʙ','ᴄ','ᴅ','ᴇ','ғ','ɢ','ʜ','ɪ','ᴊ','ᴋ','ʟ','ᴍ','ɴ','ᴏ','ᴘ','ǫ','ʀ','s','ᴛ','ᴜ','ᴠ','ᴡ','x','ʏ','ᴢ'];

    var btn = document.body.appendChild(document.createElement('div'));
    btn.setAttribute("id", 'kawaiibtn');
    btn.innerText = 'ᴀ';
    btn.style.fontSize = 'small';
    btn.style.backgroundColor = 'whitesmoke';
    btn.style.cursor = 'pointer';
    btn.style.border = 'solid 1px black';
    btn.style.zIndex = 1;
    btn.style.position = 'absolute';
    btn.style.top = '30px';
    btn.style.right = '6px';
    btn.style.padding = '2px 8px 3px 7px';
    btn.addEventListener('click', function(){
        var afterStrs = [],
            chatBox = document.getElementById('chat_input_text_box');
        if (chatBox) {
            var chatBoxStrs = chatBox.value,
                beforeStrs = chatBoxStrs.split('');
            for (i=0; i<beforeStrs.length; i++) {
                for (ii=0; ii<alphabets.length; ii++) {
                    if (beforeStrs[i] == alphabets[ii]) {
                        afterStrs[i] = minimoji[ii];
                        break;
                    }
                }
            }
            chatBox.value = afterStrs.join('');
        }
    }, false);
})();