您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
HiPDA emoji support
// ==UserScript== // @name hipda-emoji // @namespace https://github.com/maltoze/tampermonkey-scripts // @version 0.2.1 // @description HiPDA emoji support // @author maltoze // @match https://www.hi-pda.com/forum/* // @match https://www.4d4y.com/forum/* // @grant none // @license MIT // ==/UserScript== (function () { 'use strict'; const needDecodeEntity = '&'; Array.from(document.getElementsByClassName('t_msgfont')).forEach((elem) => { if (elem.innerHTML.includes(needDecodeEntity)) { elem.innerHTML = elem.innerHTML.replaceAll(needDecodeEntity, '&'); } }); const fastPostSmiliesElem = document.querySelector('#fastpostsmilies'); const cmdBeforeElem = document.querySelector('#e_cmd_custom1_rm'); if (!fastPostSmiliesElem && !cmdBeforeElem) { return; } function insertEmojiTrigger(elem, style) { elem.insertAdjacentHTML( 'afterend', `<a id="emoji-trigger" style="text-indent: 0; cursor: pointer; ${style}">😀</a>`, ); } fastPostSmiliesElem && insertEmojiTrigger( fastPostSmiliesElem, 'background: none; text-decoration: none', ); cmdBeforeElem && insertEmojiTrigger(cmdBeforeElem, 'text-align: center'); const emojiSize = 24; function loadEmojiButton() { const emojiScript = document.createElement('script'); emojiScript.type = 'module'; emojiScript.text = ` import { EmojiButton } from 'https://cdn.jsdelivr.net/npm/@joeattardi/[email protected]/dist/index.min.js'; const picker = new EmojiButton({ style: 'twemoji', twemojiOptions: { base: 'https://cdn.jsdelivr.net/gh/twitter/[email protected]/assets/', }, }); const trigger = document.querySelector('#emoji-trigger'); const fastPostElem = document.querySelector('#fastpostmessage'); const postBoxIframe = document.querySelector('#postbox #e_iframe'); const postBoxBodyElem = postBoxIframe && postBoxIframe.contentWindow.document.querySelector('body'); picker.on('emoji', (selection) => { const imgUrl = selection.url; if (fastPostElem) { const emojiStr = '[img=${emojiSize},${emojiSize}]' + imgUrl + '[/img]'; const fastPostValue = fastPostElem.value; fastPostElem.value = ''.concat( fastPostValue.slice(0, fastPostElem.selectionStart), emojiStr, fastPostValue.slice(fastPostElem.selectionEnd), ); } if (postBoxBodyElem) { postBoxBodyElem.innerHTML += '<img width="${emojiSize}" height="${emojiSize}" src=' + imgUrl + ' />'; } }); trigger.addEventListener('click', () => picker.togglePicker(trigger)); `; document.body.appendChild(emojiScript); } loadEmojiButton(); })();