Luogu QQ 表情显示

一款可以帮助您在洛谷信息中使用QQ表情的脚本

// ==UserScript==
// @name         Luogu QQ 表情显示
// @namespace    http://tampermonkey.net/
// @version      1.3.2
// @description  一款可以帮助您在洛谷信息中使用QQ表情的脚本
// @author       dreaum
// @license      GPL-3.0-or-later
// @match        https://www.luogu.com.cn/*
// @exclude      https://www.luogu.com.cn/record/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    // 感谢Maxmilite提供的表情图址(参考LuoguEmojiSender插件)
    //配合LuoguEmojiSender脚本使用更佳

    //1.0.0 正式发布
    //1.0.1 修复 ScatteredHope 反馈的"cy"表情链接失效
    //1.1.0 增加排除替换页面(新建文章、剪切板、评论等)
    //1.2.0 优化搜索算法,感谢 Maxmilite 的推广
    //1.2.1 增加代码注释并上传greasyfork
    //1.3.0 重构搜索算法,减少遍历节点,使页面更流畅,感谢 ScatteredHope 反馈
    //1.3.1 修复搜索时间过长
    //1.3.2 修复提交记录页面无法加载

    // QQ 表情列表
    const emojiMap = {
        "/ybyb": "https://z3.ax1x.com/2021/05/30/2VUvAH.png",
        "/wosl": "https://z3.ax1x.com/2021/05/30/2VUSyT.png",
        "/hs": "https://z3.ax1x.com/2021/05/30/2VNzlV.png",
        "/psj": "https://z3.ax1x.com/2021/05/30/2VNjWq.png",
        "/na": "https://z3.ax1x.com/2021/05/30/2VNqoj.png",
        "/bx": "https://z3.ax1x.com/2021/05/30/2VNbwQ.png",
        "/qdqd": "https://z3.ax1x.com/2021/05/30/2VNTOS.png",
        "/zy": "https://z3.ax1x.com/2021/05/30/2VNIQf.png",
        "/nqct": "https://z3.ax1x.com/2021/05/30/2VNlR0.png",
        "/nzqk": "https://z3.ax1x.com/2021/05/30/2VNQGq.png",
        "/mjl": "https://z3.ax1x.com/2021/05/30/2VNuIs.png",
        "/gun": "https://z3.ax1x.com/2021/05/30/2VtyUs.png",
        "/cb": "https://z3.ax1x.com/2021/05/30/2Vtagf.png",
        "/my": "https://z3.ax1x.com/2021/05/30/2VtGEd.png",
        "/mwbq": "https://z3.ax1x.com/2021/05/30/2Vtu36.png",
        "/kx": "https://z3.ax1x.com/2021/05/30/2VYvAs.png",
        "/jl": "https://z3.ax1x.com/2021/05/30/2VY5tI.png",
        "/wyx": "https://z3.ax1x.com/2021/05/30/2VY8f0.png",
        "/ww": "https://z3.ax1x.com/2021/05/30/2VYiTA.png",
        "/mdfq": "https://z3.ax1x.com/2021/05/30/2VJQG6.png",
        "/banzz": "https://z3.ax1x.com/2021/05/30/2VJMPx.png",
        "/mgx": "https://z3.ax1x.com/2021/05/30/2VGyU1.png",
        "/aini": "https://xn--9zr.tk/aini",
        "/aiq": "https://xn--9zr.tk/aiq",
        "/am": "https://xn--9zr.tk/am",
        "/azgc": "https://z3.ax1x.com/2021/05/30/2VJqoR.png",
        "/baiy": "https://xn--9zr.tk/baiy",
        "/bangbangt": "https://xn--9zr.tk/bangbangt",
        "/baojin": "https://xn--9zr.tk/baojin",
        "/bb": "https://xn--9zr.tk/bb",
        "/bkx": "https://xn--9zr.tk/bkx",
        "/bl": "https://xn--9zr.tk/bl",
        "/bobo": "https://xn--9zr.tk/bobo",
        "/bp": "https://xn--9zr.tk/bp",
        "/bq": "https://xn--9zr.tk/bq",
        "/bs": "https://xn--9zr.tk/bs",
        "/bt": "https://xn--9zr.tk/bt",
        "/bu": "https://xn--9zr.tk/bu",
        "/bz": "https://xn--9zr.tk/bz",
        "/cengyiceng": "https://xn--9zr.tk/cengyiceng",
        "/cg": "https://z3.ax1x.com/2021/05/30/2VJxSK.png",
        "/ch": "https://xn--9zr.tk/ch",
        "/chi": "https://xn--9zr.tk/chi",
        "/cj": "https://xn--9zr.tk/cj",
        "/cp": "https://xn--9zr.tk/cp",
        "/cs": "https://z3.ax1x.com/2021/05/30/2VJWiq.png",
        "/cy": "https://s21.ax1x.com/2024/05/05/pkAotn1.png",
        "/dan": "https://xn--9zr.tk/dan",
        "/dao": "https://xn--9zr.tk/dao",
        "/db": "https://xn--9zr.tk/db",
        "/dg": "https://xn--9zr.tk/dg",
        "/dgg": "https://xn--9zr.tk/dgg",
        "/dk": "https://xn--9zr.tk/dk",
        "/dl": "https://xn--9zr.tk/dl",
        "/doge": "https://xn--9zr.tk/doge",
        "/dx": "https://xn--9zr.tk/dx",
        "/dy": "https://xn--9zr.tk/dy",
        "/dz": "https://xn--9zr.tk/dz",
        "/ee": "https://xn--9zr.tk/ee",
        "/emm": "https://z3.ax1x.com/2021/05/30/2VJjW6.png",
        "/fad": "https://xn--9zr.tk/fad",
        "/fade": "https://xn--9zr.tk/fade",
        "/fan": "https://xn--9zr.tk/fan",
        "/fd": "https://xn--9zr.tk/fd",
        "/fendou": "https://xn--9zr.tk/fendou",
        "/fj": "https://xn--9zr.tk/fj",
        "/fn": "https://xn--9zr.tk/fn",
        "/fw": "https://xn--9zr.tk/fw",
        "/gg": "https://xn--9zr.tk/gg",
        "/gy": "https://xn--9zr.tk/gy",
        "/gz": "https://xn--9zr.tk/gz",
        "/hanx": "https://xn--9zr.tk/hanx",
        "/haob": "https://xn--9zr.tk/haob",
        "/hb": "https://xn--9zr.tk/hb",
        "/hc": "https://xn--9zr.tk/hc",
        "/hd": "https://xn--9zr.tk/hd",
        "/hec": "https://xn--9zr.tk/hec",
        "/hhd": "https://z3.ax1x.com/2021/05/30/2VYpOe.png",
        "/hn": "https://xn--9zr.tk/hn",
        "/hp": "https://xn--9zr.tk/hp",
        "/hq": "https://xn--9zr.tk/hq",
        "/hsh": "https://xn--9zr.tk/hsh",
        "/ht": "https://xn--9zr.tk/ht",
        "/huaix": "https://xn--9zr.tk/huaix",
        "/hx": "https://xn--9zr.tk/hx",
        "/jd": "https://xn--9zr.tk/jd",
        "/jh": "https://xn--9zr.tk/jh",
        "/jiaybb": "https://xn--9zr.tk/jiaybb",
        "/jiaybs": "https://xn--9zr.tk/jiaybs",
        "/jie": "https://xn--9zr.tk/jie",
        "/jk": "https://xn--9zr.tk/jk",
        "/jw": "https://xn--9zr.tk/jw",
        "/jx": "https://xn--9zr.tk/jx",
        "/jy": "https://xn--9zr.tk/jy",
        "/ka": "https://xn--9zr.tk/ka",
        "/kb": "https://xn--9zr.tk/kb",
        "/kel": "https://xn--9zr.tk/kel",
        "/kf": "https://xn--9zr.tk/kf",
        "/kg": "https://xn--9zr.tk/kg",
        "/kk": "https://xn--9zr.tk/kk",
        "/kl": "https://xn--9zr.tk/kl",
        "/kt": "https://xn--9zr.tk/kt",
        "/kuk": "https://xn--9zr.tk/kuk",
        "/kun": "https://xn--9zr.tk/kun",
        "/kzht": "https://xn--9zr.tk/kzht",
        "/lb": "https://xn--9zr.tk/lb",
        "/lengh": "https://xn--9zr.tk/lengh",
        "/lh": "https://xn--9zr.tk/lh",
        "/ll": "https://xn--9zr.tk/ll",
        "/lm": "https://xn--9zr.tk/lm",
        "/lq": "https://xn--9zr.tk/lq",
        "/lw": "https://xn--9zr.tk/lw",
        "/lyj": "https://z3.ax1x.com/2021/05/30/2VJhWV.png",
        "/meigui": "https://xn--9zr.tk/mg",
        "/mm": "https://xn--9zr.tk/mm",
        "/ng": "https://xn--9zr.tk/ng",
        "/nkt": "https://z3.ax1x.com/2021/05/30/2VJrQS.png",
        "/oh": "https://xn--9zr.tk/oh",
        "/oy": "https://z3.ax1x.com/2021/05/30/2VJ4zT.png",
        "/pch": "https://xn--9zr.tk/pch",
        "/pj": "https://xn--9zr.tk/pj",
        "/pp": "https://xn--9zr.tk/pp",
        "/pt": "https://xn--9zr.tk/pt",
        "/px": "https://xn--9zr.tk/px",
        "/qd": "https://xn--9zr.tk/qd",
        "/qiang": "https://xn--9zr.tk/qiang",
        "/qiao": "https://xn--9zr.tk/qiao",
        "/qq": "https://xn--9zr.tk/qq",
        "/qt": "https://xn--9zr.tk/qt",
        "/ruo": "https://xn--9zr.tk/ruo",
        "/sa": "https://xn--9zr.tk/sa",
        "/se": "https://xn--9zr.tk/se",
        "/sh": "https://xn--9zr.tk/sh",
        "/shd": "https://xn--9zr.tk/shd",
        "/shl": "https://xn--9zr.tk/shl",
        "/shuai": "https://xn--9zr.tk/shuai",
        "/shui": "https://xn--9zr.tk/shui",
        "/shxi": "https://xn--9zr.tk/shxi",
        "/sr": "https://xn--9zr.tk/sr",
        "/tiao": "https://xn--9zr.tk/tiao",
        "/tl": "https://xn--9zr.tk/tl",
        "/tnl": "https://xn--9zr.tk/tnl",
        "/tp": "https://xn--9zr.tk/tp",
        "/ts": "https://xn--9zr.tk/ts",
        "/tsh": "https://xn--9zr.tk/tsh",
        "/tt": "https://z3.ax1x.com/2021/05/30/2VJIQU.png",
        "/tuu": "https://xn--9zr.tk/tuu",
        "/tx": "https://xn--9zr.tk/tx",
        "/taiyang": "https://xn--9zr.tk/ty",
        "/tyt": "https://xn--9zr.tk/tyt",
        "/wbk": "https://xn--9zr.tk/wbk",
        "/whl": "https://z3.ax1x.com/2021/05/30/2VJHeJ.png",
        "/wl": "https://xn--9zr.tk/wl",
        "/wn": "https://xn--9zr.tk/wn",
        "/wq": "https://xn--9zr.tk/wq",
        "/ws": "https://xn--9zr.tk/ws",
        "/wul": "https://z3.ax1x.com/2021/05/30/2VJfJ0.png",
        "/wx": "https://xn--9zr.tk/wx",
        "/wzm": "https://xn--9zr.tk/wzm",
        "/xhx": "https://xn--9zr.tk/xhx",
        "/xia": "https://xn--9zr.tk/xia",
        "/xig": "https://xn--9zr.tk/xig",
        "/xin": "https://xn--9zr.tk/xin",
        "/xjj": "https://xn--9zr.tk/xjj",
        "/xk": "https://xn--9zr.tk/xk",
        "/xs": "https://xn--9zr.tk/xs",
        "/xu": "https://xn--9zr.tk/xu",
        "/xw": "https://xn--9zr.tk/xw",
        "/xy": "https://xn--9zr.tk/xy",
        "/xyx": "https://xn--9zr.tk/xyx",
        "/yao": "https://xn--9zr.tk/yao",
        "/yhh": "https://xn--9zr.tk/yhh",
        "/yiw": "https://xn--9zr.tk/yiw",
        "/yl": "https://xn--9zr.tk/yl",
        "/youl": "https://xn--9zr.tk/youl",
        "/youtj": "https://xn--9zr.tk/youtj",
        "/yt": "https://xn--9zr.tk/yt",
        "/yun": "https://xn--9zr.tk/yun",
        "/yx": "https://xn--9zr.tk/yx",
        "/zhd": "https://xn--9zr.tk/zhd",
        "/zhem": "https://xn--9zr.tk/zhem",
        "/zhh": "https://xn--9zr.tk/zhh",
        "/zhm": "https://xn--9zr.tk/zhm",
        "/zhq": "https://xn--9zr.tk/zhq",
        "/zj": "https://xn--9zr.tk/zj",
        "/zk": "https://xn--9zr.tk/zk",
        "/zq": "https://xn--9zr.tk/zq",
        "/zt": "https://xn--9zr.tk/zt",
        "/zuotj": "https://xn--9zr.tk/zuotj",
        "/maj-1!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-1.png",
        "/maj-2!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-2.png",
        "/maj-3!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-3.png",
        "/maj-4!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-4.png",
        "/maj-5!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-5.png",
        "/maj-6!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-6.png",
        "/maj-7!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-7.png",
        "/maj-8!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-8.png",
        "/maj-9!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-9.png",
        "/maj-10!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-10.png",
        "/maj-11!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-11.png",
        "/maj-12!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-12.png",
        "/maj-13!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-13.png",
        "/maj-14!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-14.png",
        "/maj-15!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-15.png",
        "/maj-16!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-16.png",
        "/maj-17!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-17.png",
        "/maj-18!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-18.png",
        "/maj-19!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-19.png",
        "/maj-20!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-20.png",
        "/maj-21!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-21.png",
        "/maj-22!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-22.png",
        "/maj-23!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-23.png",
        "/maj-24!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-24.png",
        "/maj-25!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-25.png",
        "/maj-26!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-26.png",
        "/maj-27!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-27.png",
        "/maj-28!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-28.png",
        "/maj-29!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-29.png",
        "/maj-30!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-30.png",
        "/maj-31!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-31.png",
        "/maj-32!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-32.png",
        "/maj-33!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-33.png",
        "/maj-34!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-34.png",
        "/maj-35!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-35.png",
        "/maj-36!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-36.png",
        "/maj-37!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-37.png",
        "/maj-38!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-38.png",
        "/maj-39!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-39.png",
        "/maj-40!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-40.png",
        "/maj-41!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-41.png",
        "/maj-42!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-42.png",
        "/maj-43!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-43.png",
        "/maj-44!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-44.png",
        "/maj-45!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-45.png",
        "/maj-46!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-46.png",
        "/maj-47!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-47.png",
        "/maj-48!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-48.png",
        "/maj-49!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-49.png",
        "/maj-50!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-50.png",
        "/maj-51!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-51.png",
        "/maj-52!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-52.png",
        "/maj-53!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-53.png",
        "/maj-54!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-54.png",
        "/maj-55!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-55.png",
        "/maj-56!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-56.png",
        "/maj-57!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-57.png",
        "/maj-58!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-58.png",
        "/maj-59!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-59.png",
        "/maj-60!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-60.png",
        "/maj-61!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-61.png",
        "/maj-62!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-62.png",
        "/maj-63!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-63.png",
        "/maj-64!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-64.png",
        "/maj-65!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-65.png",
        "/maj-66!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-66.png",
        "/maj-67!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-67.png",
        "/maj-68!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-68.png",
        "/maj-69!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-69.png",
        "/maj-70!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-70.png",
        "/maj-71!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-71.png",
        "/maj-72!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-72.png",
        "/maj-73!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-73.png",
        "/maj-74!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-74.png",
        "/maj-75!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-75.png",
        "/maj-76!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-76.png",
        "/maj-77!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-77.png",
        "/maj-78!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-78.png",
        "/maj-79!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-79.png",
        "/maj-80!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-80.png",
        "/maj-81!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-81.png",
        "/maj-82!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-82.png",
        "/maj-83!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-83.png",
        "/maj-84!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-84.png",
        "/maj-85!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-85.png",
        "/maj-86!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-86.png",
        "/maj-87!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-87.png",
        "/maj-88!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-88.png",
        "/maj-89!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-89.png",
        "/maj-90!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-90.png",
        "/maj-91!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-91.png",
        "/maj-92!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-92.png",
        "/maj-93!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-93.png",
        "/maj-94!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-94.png",
        "/maj-95!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-95.png",
        "/maj-96!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-96.png",
        "/maj-97!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-97.png",
        "/maj-98!": "https://cdn.jsdelivr.net/gh/BoringHacker/cdn/emojis/majsoul/maj-98.png"
    };

    // 要搜索的 class 列表
    const searchClasses = ['message', 'am-comment-bd', 'content'];

    // 替换 QQ 表情
    function replaceQQEmojis(element) {
        if (!element) return;

        // 创建遍历器
        const walker = document.createTreeWalker(element, NodeFilter.SHOW_ELEMENT, {
            acceptNode: function(node) {
                // 只搜索指定 class 的节点
                if (node.classList && searchClasses.some(className => node.classList.contains(className))) {
                    return NodeFilter.FILTER_ACCEPT;
                }
                return NodeFilter.FILTER_SKIP;
            }
        }, false);

        let node;
        while (node = walker.nextNode()) {
            // 排除包含 "https://" 或 "http://" 的文本
            if (!node.innerHTML.includes('https://') && !node.innerHTML.includes('http://')) {
                // 遍历表情列表
                Object.keys(emojiMap).forEach(key => {
                    const regex = new RegExp(key, 'g');
                    node.innerHTML = node.innerHTML.replace(regex, `<img src="${emojiMap[key]}" alt="${key}">`);
                });
            }
        }
    }

    // 初始页面替换
    replaceQQEmojis(document.body);

    // 监听 DOM 变化,实时替换表情
    const observer = new MutationObserver(mutations => {
        mutations.forEach(mutation => {
            if (mutation.type === 'childList') {
                mutation.addedNodes.forEach(node => {
                    if (node.nodeType === Node.ELEMENT_NODE) {
                        replaceQQEmojis(node);
                    }
                });
            }
        });
    });

    // 开始观察 DOM 变化
    observer.observe(document.body, { childList: true, subtree: true });
})();