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.3
// @description  press button to convert alphabet to mini characters on caffe
// @author       #kawaiirz
// @match        http://caffe.senpai-agar.online/lwga/
// @run-at       document-end
// ==/UserScript==

(function t() {
    var target = document.getElementsByClassName('chat_input_area')[0];
    if (!target) {
        console.log(0);
        setTimeout(t, 1000);
        return;
    }

    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 = target.appendChild(document.createElement('div'));
    btn.setAttribute("id", 'kawaiibtn');
    btn.innerText = 'ᴀ';
    btn.style.fontSize = 'small';
    btn.style.color = 'black';
    btn.style.backgroundColor = 'whitesmoke';
    btn.style.cursor = 'pointer';
    btn.style.borderTop = 'solid 1px black';
    btn.style.zIndex = 1;
    btn.style.position = 'absolute';
    btn.style.padding = '2px 8px 3px 7px';

    var conf = {
        attributes: true
    }

    const observer = new MutationObserver (function(record) {
		observer.disconnect();
		if(target.style.display == 'none') {
            btn.style.display = 'none';
        } else {
            btn.style.display = '';
        }
		observer.observe(target, conf);
	});
	observer.observe(target, conf);
    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;
                    } else {
                        afterStrs[i] = beforeStrs[i];
                    }
                }
            }
            chatBox.value = afterStrs.join('');
        }
    }, false);
})();