[已更新] 我做了个LinuxDo表情包选择器

更新:脚本复活啦,始皇把CSP关了,好耶!

如果你有什么好看的表情包可以发我,我更新到脚本内

image

// ==UserScript==
// @name        Linux.DO 表情包选择器
// @namespace   SMNET
// @description 在Linux.Do插入表情包
// @match     https://linux.do/t/topic/*
// @author       SMNET Studio
// @version     2.1
// @grant       none
// ==/UserScript==

var styles = `
.emojiPicker {
  position: absolute;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-height: 300px;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.8);
  padding: 10px;
  border-radius: 5px;
}

.emojiPicker img {
  cursor: pointer;
  width: 50px;
  height: 50px;
}
`;

var styleSheet = document.createElement("style");
styleSheet.type = "text/css";
styleSheet.innerText = styles;
document.head.appendChild(styleSheet);

const emojiSet = [
    { packet: 1, name: '求求你啦', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=001'},
    { packet: 1, name: '布吉岛诶', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=002'},
    { packet: 1, name: '愉悦', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=003'},
    { packet: 1, name: '啊嘿', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=004'},
    { packet: 1, name: '一起吃瓜', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=005'},
    { packet: 1, name: '心心', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=006'},
    { packet: 1, name: '嘻嘻嘻', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=007'},
    { packet: 1, name: '思考中', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=008'},
    { packet: 1, name: '请多关照', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=009'},
    { packet: 1, name: '少蹬鼻子上脸', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=010'},
    { packet: 1, name: '空调已开启', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=011'},
    { packet: 1, name: '喂 在吗', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=012'},
    { packet: 1, name: '荣幸至极', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=013'},
    { packet: 1, name: '还没好', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=014'},
    { packet: 1, name: '稍等片刻', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=015'},
    { packet: 1, name: '啊啦', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=016'},
    { packet: 1, name: '摸鱼', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=017'},
    { packet: 1, name: '肚肚饿饿', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=018'},
    { packet: 1, name: '凝视', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=019'},
    { packet: 1, name: '心塞', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=020'},
    { packet: 1, name: '哟', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=021'},
    { packet: 1, name: '不吉', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=022'},
    { packet: 1, name: '哎呀呀', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=023'},
    { packet: 1, name: '喵', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=024'},
    { packet: 1, name: '这是秘密', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=025'},
    { packet: 1, name: '好成熟', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=026'},
    { packet: 1, name: '闪亮', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=027'},
    { packet: 1, name: '围观', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=028'},
    { packet: 1, name: '谢谢', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=029'},
    { packet: 1, name: '震惊', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=030'},
    { packet: 1, name: '差不多得了', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=031'},
    { packet: 1, name: '真差劲', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=032'},
    { packet: 1, name: '针不戳', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=033'},
    { packet: 1, name: '诶呀', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=034'},
    { packet: 1, name: '好棒啊', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=035'},
    { packet: 1, name: '很棒', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=036'},
    { packet: 1, name: '不可以', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=037'},
    { packet: 1, name: '有事吗', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=038'},
    { packet: 1, name: 'GOOD', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=039'},
    { packet: 1, name: '羊', url: 'https://static.flss.world/api/image.php?gif-packet=1&no=040'},
    { packet: 2, name: '到家咯', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=01'},
    { packet: 2, name: '哇伊', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=02'},
    { packet: 2, name: '好不讲理', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=03'},
    { packet: 2, name: '对不起啦', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=04'},
    { packet: 2, name: '?', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=05'},
    { packet: 2, name: '哥强吧', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=06'},
    { packet: 2, name: '迷茫', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=07'},
    { packet: 2, name: '生气', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=08'},
    { packet: 2, name: '快去睡觉', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=09'},
    { packet: 2, name: '我睡了', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=10'},
    { packet: 2, name: '早啊', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=11'},
    { packet: 2, name: '呜嘤嘤', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=12'},
    { packet: 2, name: '喵', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=13'},
    { packet: 2, name: '好可爱', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=14'},
    { packet: 2, name: '呜嘿嘿', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=15'},
    { packet: 2, name: 'Zzz', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=16'},
    { packet: 2, name: '赞', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=17'},
    { packet: 2, name: '再见啦', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=18'},
    { packet: 2, name: '保密', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=19'},
    { packet: 2, name: '交给我吧', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=20'},
    { packet: 2, name: '哦吼', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=21'},
    { packet: 2, name: 'AWSL', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=22'},
    { packet: 2, name: '可不是嘛', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=23'},
    { packet: 2, name: '你这大懒蛋', url: 'https://static.flss.world/api/image.php?gif-packet=2&no=24'},
];

setInterval(() => {
    var editor = document.querySelector('.d-editor-button-bar');
    if (!document.querySelector('.emoji-picker-button') && editor){
        var emojiButton = document.createElement('button');
        emojiButton.classList.add('btn', 'no-text', 'btn-icon', 'emoji', 'emoji-picker-button');
        emojiButton.title = "插入表情包";
        emojiButton.innerHTML = "<svg class='fa d-icon d-icon-far-smile svg-icon svg-string' xmlns='http://www.w3.org/2000/svg'><use href='#far-smile'></use></svg>";
        editor.appendChild(emojiButton);
        emojiButton.addEventListener('click', function () {
            var emojiPicker = document.createElement('div');
            emojiPicker.className = 'emojiPicker';
            emojiPicker.innerHTML = emojiSet.map(emo =>
          `<img src="${emo.url}" alt="${emo.name}" onclick="insertEmoji(event)"/>`).join('');
            emojiPicker.style.position = 'absolute';
            emojiPicker.style.background = '#FFF';
            emojiPicker.style.border = '1px solid #ddd';
            emojiPicker.style.padding = '10px';
            if (document.body.contains(document.querySelector('.emojiPicker'))) {
                document.querySelector('.emojiPicker').remove();
            } else {
                emojiButton.after(emojiPicker);
            }
            emojiPicker.addEventListener('click', function (e) {
                if (e.target.tagName === 'IMG') {
                    var textArea = document.querySelector('.d-editor-input');
                      if (!textArea) {
                        alert("找不到输入框");
                        return;
                      }
                  var emojiMarkdown = `![${e.target.alt}|116x100](${e.target.src})`;

                  // 在光标位置插入表情包
                  var startPos = textArea.selectionStart;
                  var endPos = textArea.selectionEnd;
                  textArea.value = textArea.value.substring(0, startPos)
                  + emojiMarkdown
                  + textArea.value.substring(endPos, textArea.value.length);
                  // 触发输入事件
                  var event = new Event('input', {
                      bubbles: true,
                      cancelable: true,
                  });
                  textArea.dispatchEvent(event);
                  // 隐藏选择器
                  emojiPicker.remove();
                }
            });
        });
    }
}, 100);
116 Likes

8 Likes


大佬二十四小时在线吗 :joy:

5 Likes

被你发现了

9 Likes

看不过简陋的聊天室,所以出手了吗

7 Likes

常规话题软件开发

woc
你没睡
我也没睡

8 Likes

另外多亏我给这缩限之后当签名
不然始皇迟早嘎我
太大了

8 Likes


度日如小时

7 Likes

是这样的

7 Likes

好家伙,看不惯草台班子,自己出手了是吧 :rofl:

9 Likes

是这样的

7 Likes

6 Likes

爪机版chrome就不跟你们凑热闹了(
窝是成熟的猫猫 猫猫会自己发原图

7 Likes

好好好

8 Likes

7 Likes

牛呀

6 Likes

压力来到了站长这边:laughing:

5 Likes

大佬牛:cow:

7 Likes

:+1: :+1: :+1:

5 Likes