简介
当前L站默认的 Emoji 是 Apple Emoji,不过 discourse 内置了 6 种 Emoji 风格(Twitter Emoji和 EmojiOne 效果一样),始皇在后台应该是可以直接修改的,不过也可以自行通过替换路径的方式来解锁更多的风格
种 Emoji 风格
注意:部分风格可能存在字符不全的问题
-
Twitter(个人比较喜欢这种扁平风,也为脚本默认风格)
-
Apple(L站默认风格)
-
Facebook
-
Google
-
Google Classic
-
Win10
油猴脚本
-
单一替换(脚本默认风格:Twitter,想替换的其他风格的话修改 24 行中的
twitter
即可,比如 将twitter
→google
)// ==UserScript== // @name replaceEmojiStyle // @namespace http://tampermonkey.net/ // @version 0.1 // @description replaceEmojiStyle // @author You // @match https://linux.do/* // @grant none // ==/UserScript== (function() { 'use strict'; function replaceEmojiStyle() { const imgs = document.querySelectorAll('img'); imgs.forEach(updateImageSrc); } function updateImageSrc(img) { const applePath = 'images/emoji/apple'; if (img.src.includes(applePath)) { // facebook_messenger,google,google_classic,twitter,win10,emoji_one img.src = img.src.replace(applePath, 'images/emoji/twitter'); } } function processMutations(mutations) { mutations.forEach(mutation => { mutation.addedNodes.forEach(node => { if (node.nodeType === 1) { if (node.tagName === 'IMG') { updateImageSrc(node); } else if (node.querySelectorAll) { node.querySelectorAll('img').forEach(updateImageSrc); } } }); if (mutation.type === 'attributes' && mutation.target.tagName === 'IMG') { updateImageSrc(mutation.target); } }); } window.addEventListener('load', replaceEmojiStyle); const observer = new MutationObserver(processMutations); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['src'] }); })();
-
随机替换(可能有 Bug,没怎么测试)
// ==UserScript== // @name replaceEmojiStyle // @namespace http://tampermonkey.net/ // @version 0.1 // @description replaceEmojiStyle // @author You // @match https://linux.do/* // @grant none // ==/UserScript== (function() { 'use strict'; const emojiStyles = ['apple', 'twitter', 'google', 'win10', 'google_classic', 'facebook_messenger']; const selectedStyle = emojiStyles[Math.floor(Math.random() * emojiStyles.length)]; const processedUrls = new Set(); const applePath = 'images/emoji/apple'; function updateImageSrc(img) { if (img.src.includes(applePath) && !processedUrls.has(img.src)) { img.src = img.src.replace(applePath, `images/emoji/${selectedStyle}`); processedUrls.add(img.src); } } function replaceEmojiStyle() { document.querySelectorAll('img').forEach(updateImageSrc); } function debounce(func, wait) { let timeout; return function executedFunction(...args) { const later = () => { clearTimeout(timeout); func(...args); }; clearTimeout(timeout); timeout = setTimeout(later, wait); }; } const debouncedReplaceEmoji = debounce(replaceEmojiStyle, 100); function processMutations(mutations) { let shouldReplace = false; mutations.forEach(mutation => { if (mutation.type === 'childList') { mutation.addedNodes.forEach(node => { if (node.nodeType === 1 && (node.tagName === 'IMG' || node.querySelector('img'))) { shouldReplace = true; } }); } else if (mutation.type === 'attributes' && mutation.target.tagName === 'IMG') { shouldReplace = true; } }); if (shouldReplace) { debouncedReplaceEmoji(); } } window.addEventListener('load', replaceEmojiStyle); const observer = new MutationObserver(processMutations); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['src'] }); })();