NodeSeek 表情包增强

为 NodeSeek 添加更多表情包

安装此脚本?
作者推荐脚本

您可能也喜欢NodeSeek 编辑器增强

安装此脚本
  1. // ==UserScript==
  2. // @name NodeSeek 表情包增强
  3. // @namespace https://www.nodeseek.com/
  4. // @version 0.0.6
  5. // @description 为 NodeSeek 添加更多表情包
  6. // @author TomyJan
  7. // @match *://www.nodeseek.com/*
  8. // @icon https://www.nodeseek.com/static/image/favicon/android-chrome-192x192.png
  9. // @grant none
  10. // @license MPL-2.0 License
  11. // @supportURL https://www.nodeseek.com/post-68803-1
  12. // @homepageURL https://www.nodeseek.com/post-68803-1
  13. // ==/UserScript==
  14.  
  15. /**
  16. *
  17. *
  18. * 当前版本更新日志
  19. * 0.0.6 - 205.02.14 !!!更新前注意备份您的配置!!!
  20. * - 优化 兼容最新的 App 选项卡
  21. */
  22.  
  23. (function () {
  24. 'use strict';
  25.  
  26. // 自定义表情包数据
  27. // 添加其它自定义表情包请参照以下格式
  28. const customEmotionList = {
  29. // bili 表情包来自 https://github.com/lrhtony/BiliEmoji
  30. "2233娘": { "name": "2233娘", "type": "png", "icon": "icon", "items": ["2233娘-大笑", "2233娘-吃惊", "2233娘-大哭", "2233娘-耶", "2233娘-卖萌", "2233娘-疑问", "2233娘-汗", "2233娘-困惑", "2233娘-怒", "2233娘-委屈", "2233娘-郁闷", "2233娘-第一", "2233娘-喝水", "2233娘-吐魂", "2233娘-无言"], "baseUrl": "https://emoji.shojo.cn/bili/src/2233娘/" },
  31. "小电视": {"name": "小电视", "type": "gif", "icon": "icon", "items": ["tvgif-白眼", "tvgif-doge", "tvgif-坏笑", "tvgif-难过", "tvgif-生气", "tvgif-委屈", "tvgif-斜眼笑", "tvgif-呆", "tvgif-发怒", "tvgif-惊吓", "tvgif-呕吐", "tvgif-思考", "tvgif-微笑", "tvgif-疑问", "tvgif-大哭", "tvgif-鼓掌", "tvgif-抠鼻", "tvgif-亲亲", "tvgif-调皮", "tvgif-笑哭", "tvgif-晕", "tvgif-点赞", "tvgif-害羞", "tvgif-睡着", "tvgif-色", "tvgif-吐血", "tvgif-无奈", "tvgif-再见", "tvgif-流汗", "tvgif-偷笑", "tvgif-抓狂", "tvgif-黑人问号", "tvgif-困", "tvgif-打脸", "tvgif-闭嘴", "tvgif-鄙视", "tvgif-腼腆", "tvgif-馋", "tvgif-可爱", "tvgif-发财", "tvgif-生病", "tvgif-流鼻血", "tvgif-尴尬", "tvgif-大佬"], "baseUrl": "https://emoji.shojo.cn/bili/src/tv_小电视_动图/" },
  32. // 贴吧表情包来自 https://github.com/microlong666/Tieba_mobile_emotions
  33. "贴吧": {"name": "贴吧", "type": "png", "items": ["image_emoticon", "image_emoticon2", "image_emoticon3", "image_emoticon4", "image_emoticon5", "image_emoticon6", "image_emoticon7", "image_emoticon8", "image_emoticon9", "image_emoticon10", "image_emoticon11", "image_emoticon12", "image_emoticon13", "image_emoticon14", "image_emoticon15", "image_emoticon16", "image_emoticon17", "image_emoticon18", "image_emoticon19", "image_emoticon20", "image_emoticon21", "image_emoticon22", "image_emoticon23", "image_emoticon24", "image_emoticon25", "image_emoticon26", "image_emoticon27", "image_emoticon28", "image_emoticon29", "image_emoticon30", "image_emoticon31", "image_emoticon32", "image_emoticon33", "image_emoticon34", "image_emoticon35", "image_emoticon36", "image_emoticon37", "image_emoticon38", "image_emoticon39", "image_emoticon40", "image_emoticon41", "image_emoticon42", "image_emoticon43", "image_emoticon44", "image_emoticon45", "image_emoticon46", "image_emoticon47", "image_emoticon48", "image_emoticon49", "image_emoticon50", "image_emoticon62", "image_emoticon63", "image_emoticon64", "image_emoticon65", "image_emoticon66", "image_emoticon67", "image_emoticon68", "image_emoticon69", "image_emoticon70", "image_emoticon71", "image_emoticon72", "image_emoticon73", "image_emoticon74", "image_emoticon75", "image_emoticon76", "image_emoticon77", "image_emoticon78", "image_emoticon79", "image_emoticon80", "image_emoticon81", "image_emoticon82", "image_emoticon83", "image_emoticon84", "image_emoticon85", "image_emoticon86", "image_emoticon87", "image_emoticon88", "image_emoticon89", "image_emoticon90", "image_emoticon91", "image_emoticon92", "image_emoticon93", "image_emoticon94", "image_emoticon95", "image_emoticon96", "image_emoticon97", "image_emoticon98", "image_emoticon99", "image_emoticon100", "image_emoticon101", "image_emoticon102", "image_emoticon103", "image_emoticon104", "image_emoticon105", "image_emoticon106", "image_emoticon107", "image_emoticon108", "image_emoticon109", "image_emoticon110", "image_emoticon111", "image_emoticon112", "image_emoticon113", "image_emoticon114", "image_emoticon115", "image_emoticon116", "image_emoticon117", "image_emoticon118", "image_emoticon119", "image_emoticon120", "image_emoticon121", "image_emoticon122", "image_emoticon123", "image_emoticon124"], "baseUrl": "https://cdn.jsdelivr.net/gh/microlong666/tieba_mobile_emotions/" },
  34. // 小恐龙和花表情包来自 https://github.com/solstice23/argon-theme
  35. "小恐龙": {"name": "小恐龙", "type": "jpg", "items": ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16"], "baseUrl": "https://cdn.jsdelivr.net/gh/solstice23/argon-theme/stickers/dinosaur/"},
  36. "花!": {"name": "花!", "type": "PNG", "items": ["花", "草", "叶", "星", "日", "月", "水", "嘿嘿", "酸", "生日快乐", "海", "菜", "瓦", "�"], "baseUrl": "https://cdn.jsdelivr.net/gh/k4yt3x/flowerhd/PNG/"}
  37. };
  38.  
  39. // 页面加载完毕后初始化自定义表情包
  40. window.addEventListener('load', initCustomEmotions, false);
  41.  
  42. function initCustomEmotions() {
  43. setupEmotionTitles();
  44. setupEmotionTitlesClickHandler();
  45. monitorExpContainerChanges();
  46. }
  47.  
  48. // 设置自定义表情包标题
  49. function setupEmotionTitles() {
  50. const emotionTitleDiv = document.querySelector('.expression');
  51. Object.keys(customEmotionList).forEach(key => {
  52. const newDiv = createEmotionTitle(key);
  53. emotionTitleDiv.insertBefore(newDiv, emotionTitleDiv.lastElementChild);
  54. });
  55. }
  56.  
  57. // 创建表情包标题元素
  58. function createEmotionTitle(key) {
  59. const newDiv = document.createElement('div');
  60. newDiv.id = `custom-emotion-${key}`;
  61. newDiv.classList.add('custom-emotion');
  62. newDiv.innerHTML = ` ${customEmotionList[key].name} `;
  63. newDiv.style.cursor = 'pointer';
  64. addHoverEffect(newDiv);
  65. return newDiv;
  66. }
  67.  
  68. // 添加标题鼠标悬浮效果
  69. function addHoverEffect(element) {
  70. element.addEventListener('mouseenter', () => {
  71. element.style.transform = 'scale(1.1)';
  72. element.style.transition = 'transform 0.3s ease';
  73. });
  74.  
  75. element.addEventListener('mouseleave', () => {
  76. element.style.transform = 'scale(1)';
  77. });
  78. }
  79.  
  80. // 设置自定义表情包标题的点击事件处理
  81. function setupEmotionTitlesClickHandler() {
  82. document.querySelectorAll('.expression .custom-emotion').forEach(item => {
  83. item.addEventListener('click', () => {
  84. handleCustomEmotionClick(item);
  85. });
  86. });
  87. }
  88.  
  89. // 处理点击自定义表情包标题事件
  90. function handleCustomEmotionClick(clickedItem) {
  91. const containerDiv = document.querySelector('.exp-container');
  92.  
  93. // // 判断 containerDiv 的内容里面是不是包含 <!----> , 如果不包含就说明官方表情包打开了
  94. const isOfficial = containerDiv.innerHTML.indexOf('<!---->') === -1;
  95.  
  96.  
  97. const isCurrent = clickedItem.classList.contains('current-group');
  98. const isOpen = containerDiv.classList.contains('open');
  99.  
  100.  
  101.  
  102.  
  103. // 如果容器未打开或当前选中的不是点击的标题或者打开了官方表情包,则更新显示
  104. if (!isOpen || !isCurrent || isOfficial) {
  105. if (isOfficial) { // 打开了官方表情包
  106. document.querySelector('.exp-item.current-group').click();
  107. setTimeout(() => {
  108. if (containerDiv.classList.contains('open')) { // 判断官方表情包是否已经关闭
  109. return; // 关不掉就别干了吧
  110. // TODO: 一个更好的方法避免这俩共存
  111. }
  112. updateEmotionDisplay(clickedItem, containerDiv);
  113. }, 500);
  114. } else
  115. updateEmotionDisplay(clickedItem, containerDiv);
  116. } else { // 否则,清除并关闭
  117. // console.log('clear and close');
  118. containerDiv.classList.remove('open');
  119. clearEmotions();
  120. }
  121. }
  122.  
  123. // 更新表情包显示
  124. function updateEmotionDisplay(clickedItem, containerDiv) {
  125. clearEmotions(); // 清除当前显示的表情包
  126. document.querySelectorAll('.expression .custom-emotion').forEach(item => {
  127. item.classList.remove('current-group');
  128. });
  129.  
  130. clickedItem.classList.add('current-group');
  131. addEmotionsToContainer(clickedItem.id.replace('custom-emotion-', ''), containerDiv);
  132. containerDiv.classList.add('open');
  133. }
  134.  
  135. // 清除表情包显示容器中的内容
  136. function clearEmotions() {
  137. const tempContainer = document.getElementById('temporary-container');
  138. tempContainer?.remove(); // 如果临时容器存在,则移除
  139. }
  140.  
  141. // 向显示容器中添加表情包
  142. function addEmotionsToContainer(packKey, containerDiv) {
  143. const pack = customEmotionList[packKey];
  144. const container = document.createElement('div');
  145. container.id = 'temporary-container';
  146.  
  147. pack.items.forEach(item => {
  148. const img = document.createElement('img');
  149. img.src = `${pack.baseUrl}/${item}.${pack.type}`;
  150. img.alt = item;
  151. img.className = "sticker";
  152. img.style.maxWidth = "90px";
  153. container.appendChild(img);
  154. });
  155.  
  156. // 给表情包图片添加点击事件
  157. container.addEventListener('click', (e) => {
  158. insertToEditor(e.target.alt, e.target.src);
  159. });
  160.  
  161. containerDiv.appendChild(container);
  162. }
  163.  
  164. // 向编辑器中插入图片链接
  165. function insertToEditor(imgName, imgLink) {
  166. const codeMirrorElement = document.querySelector('.CodeMirror');
  167. if (codeMirrorElement) {
  168. const codeMirrorInstance = codeMirrorElement.CodeMirror;
  169. if (codeMirrorInstance) {
  170. const cursor = codeMirrorInstance.getCursor();
  171. codeMirrorInstance.replaceRange(` ![表情包-${imgName}](${imgLink}) `, cursor);
  172. }
  173. }
  174. }
  175.  
  176. // 监视表情包显示容器的变化, 防止同时打开官方和自定义
  177. function monitorExpContainerChanges() {
  178. // 选择要观察变动的节点
  179. const targetNode = document.querySelector('.exp-container');
  180.  
  181. // 创建一个回调函数来接收变动通知
  182. const callback = function (mutationsList, observer) {
  183. // 检查.exp-container的innerHTML是否不包含'<!---->'即打开了官方表情包
  184. if (!targetNode.innerHTML.includes('<!---->')) {
  185. clearEmotions(); // 防止官方和自定义同时存在
  186. // 遍历所有.expression .custom-emotion类的元素并禁用
  187. // const customEmotions = document.querySelectorAll('.expression .custom-emotion');
  188. // customEmotions.forEach(element => {
  189. // element.disabled = true; // 这里假设这些元素是可以被禁用的,比如按钮
  190. // // 如果元素不能直接被禁用,可能需要添加逻辑来处理(比如添加一个类或属性来表示禁用状态)
  191. // });
  192. }
  193. };
  194.  
  195. // 创建MutationObserver实例并传入回调函数
  196. const observer = new MutationObserver(callback);
  197.  
  198. // 使用配置对象指定要观察的变动类型
  199. const config = { childList: true, subtree: true, characterData: true };
  200.  
  201. // 开始观察目标节点
  202. observer.observe(targetNode, config);
  203.  
  204. // 注意:在某个时刻,你可能需要停止观察
  205. // observer.disconnect();
  206. }
  207.  
  208. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址