本帖最后由 折木 于 2024-10-12 22:27 编辑
功能演示
写这个脚本的动机是论坛的自带表情太少了且不支持传统emjio,用电脑输入颜文字也比较花时间,所以我干脆写了个脚本把常用的颜文字整合在一起方便回帖时选择。
脚本介绍
安装完脚本后按下CTRL+Q即可唤起选择框,再次按下即可关闭选择框
可以自行在下面代码中添加或修改自己常用的颜文字
- const emojis = [ '(´▽`ʃ❤ƪ)','ヾ ˙Ⱉ˙ฅ', '(╬•̀皿•́)', 'ᕙ(`▽´)ᕗ', ' ⚆_⚆?',
- 'ど⁰꒨⁰う♡', '(≧▽≦)', 'ƪ(˘⌣˘)ʃ', 'o(*////▽////*)q', '( ̄ε ̄)',
- '(^ω^)', '( ̄︶ ̄)', '(ˉ﹃ˉ)','⌓‿⌓', '(´• ω •)', '˳⚆ɞ⚆˳',
- '_(:з)∠)_', '⊙﹏⊙∥', '┗|`O′|┛ 嗷~~', '૮₍❀ᴗ͈ . ᴗ͈ ₎ა','(〃` 3′〃)',
- '(*/ω\*)','≧ ﹏ ≦','ಠ_ಠ','ψ(`∇´)ψ'];
复制代码
当前脚本仅支持正常回帖以及楼中楼回复
若快捷键冲突可自行修改脚本中所使用的快捷键
if (event.ctrlKey && event.key === 'q')
代码
@Name ;@Match ;@icon ;
- // ==UserScript==
- // @name Emoji Selector
- // @namespace http://tampermonkey.net/
- // @version 2024-10-09
- // @description Select emojis with Ctrl+Q
- // @author 折木
- // @match https://www.gamemale.com/thread*
- // @match https://www.gamemale.com/forum.php?*
- // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAA2BJREFUWEfFl1nITVEUx39f4cmUIUMpJBkiM5klQ8pUpi8SIfNQEk94MYUHY+YXHiTKnDGkZJ5lSF5kTkg8SLH/Wlv7nu+ce+7t3tu363S75+zhv9b6r/9au4xKHmWVfD75AqgN9Ae6Ag2AhmbAe+ADcMt9vwx8zdWwXAEMBBYAQ4HbwHngrT06q7E9g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ฅ', '(╬•̀皿•́)', 'ᕙ(`▽´)ᕗ', ' ⚆_⚆?',
- 'ど⁰꒨⁰う♡', '(≧▽≦)', 'ƪ(˘⌣˘)ʃ', 'o(*////▽////*)q', '( ̄ε ̄)',
- '(^ω^)', '( ̄︶ ̄)', '(ˉ﹃ˉ)','⌓‿⌓', '(´• ω •)', '˳⚆ɞ⚆˳',
- '_(:з)∠)_', '⊙﹏⊙∥', '┗|`O′|┛ 嗷~~', '૮₍❀ᴗ͈ . ᴗ͈ ₎ა','(〃` 3′〃)',
- '(*/ω\*)','≧ ﹏ ≦','ಠ_ಠ','ψ(`∇´)ψ']; // Add more emojis as needed
- let isSelectorOpen = false;
- function insertEmoji(emoji) {
- const textareas = document.querySelectorAll('textarea');
- textareas.forEach(textarea => {
- const startPos = textarea.selectionStart;
- const endPos = textarea.selectionEnd;
- const text = textarea.value;
- const newText = text.substring(0, startPos) + emoji + text.substring(endPos, text.length);
- textarea.value = newText;
- });
- }
- function createEmojiSelector() {
- const selector = document.createElement('div');
- selector.id = 'emojiSelector'; // Unique ID for the selector element
- selector.style.position = 'fixed';
- selector.style.top = '65%';
- selector.style.left = '60%';
- selector.style.transform = 'translate(-50%, -50%)';
- selector.style.backgroundColor = 'rgba(255, 255, 255, 0.4)';
- selector.style.backdropFilter = 'blur(10px) opacity(0.9)';
- selector.style.padding = '20px';
- selector.style.border = '1px solid #ccc';
- selector.style.boxShadow = '0 2px 5px rgba(0,0,0,0.2)';
- selector.style.borderRadius = '10px';
- selector.style.zIndex = '9999';
- emojis.forEach(emoji => {
- const button = document.createElement('button');
- button.textContent = emoji;
- button.style.fontSize = '20px';
- button.style.margin = '5px';
- button.style.background = 'transparent';
- button.style.color = '#90cf5b';
- button.style.border = '2px solid #027efb';
- button.style.borderRadius = '0';
- button.style.boxShadow = '2px 2px 5px rgba(0,0,0,0.2)';
- button.addEventListener('click', () => {
- insertEmoji(emoji);
- });
- selector.appendChild(button);
- });
- document.body.appendChild(selector);
- }
- document.addEventListener('keydown', (event) => {
- if (event.ctrlKey && event.key === 'q') {
- if (!isSelectorOpen) {
- createEmojiSelector();
- isSelectorOpen = true;
- } else {
- const selector = document.getElementById('emojiSelector');
- if (selector) {
- selector.remove();
- isSelectorOpen = false;
- }
- }
- }
- });
- })();
复制代码
这是萌新10级后第一次爆金币 还请大家点点 免费的评分 啦(´▽`ʃ❤ƪ)
|