🔓 解锁 LINUX DO 全新的 Emoji 风格 !

:closed_book: 简介

当前L站默认的 Emoji 是 Apple Emoji,不过 discourse 内置了 6 种 Emoji 风格(Twitter Emoji和 EmojiOne 效果一样),始皇在后台应该是可以直接修改的,不过也可以自行通过替换路径的方式来解锁更多的风格 :yum:

image

:six: 种 Emoji 风格

注意:部分风格可能存在字符不全的问题

  1. Twitter(个人比较喜欢这种扁平风,也为脚本默认风格)

  2. Apple(L站默认风格)

  3. Facebook

  4. Google

  5. Google Classic

  6. Win10

:hammer_and_wrench: 油猴脚本

  • 单一替换(脚本默认风格:Twitter,想替换的其他风格的话修改 24 行中的 twitter 即可,比如 将 twittergoogle

    // ==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'] });
    })();
    
11 个赞

我天有这么多版本吗?我很好奇谁才是第一个发明emoji的

3 个赞

感谢分享,论坛因你而精彩!:sunglasses:

3 个赞

好耶好耶 看着不错

2 个赞

好好好,感谢佬分享

2 个赞

感谢分享 先用了,是我食用方式有误吗

3 个赞

感谢佬分享!!!

试了一下,这里首字母改小写就好了 :grinning:
image

2 个赞

6666,有点厉害

2 个赞

大佬无处不在无所不能

2 个赞

好顺的数字 :innocent:
image

1 个赞

好有流氓软件感觉的数字

2 个赞

抱歉,疏忽了,已经改好了

感谢指正 :heart:

1 个赞

贴吧的表情能用么

:tieba_025: :tieba_025: :tieba_025:你是说的这个?这个已经内置了
image

1 个赞

马克他来了,芜芜

可是别人看不到啊

这个是替换论坛内置的 Emoji

可以试试这位佬友的脚本


那得始皇出手了 :melting_face:

:tieba_001: :tieba_003:感谢感谢 之前不知道

好实用,mark了