Коментар към A question about b站直播表情下载 от (Изтрит потребител 1522427) беше докладван 05.10.2025 за Спам
因为新版页面DOM结构中已经移除了` .follow-ctnr `元素,导致`document.getElementsByClassName("follow-ctnr")[0]`返回`undefined`,导致按钮无法插入。
所以只需改写`makeButton()`,让按钮独立固定在页面上,下面代码请自行替换(结合ChatGPT)
```
function makeButton() {
// 检查是否已存在,防止重复创建
if (document.getElementById("bili-emote-download-btn")) return;
const btn = document.createElement("button");
btn.id = "bili-emote-download-btn";
btn.textContent = "下载表情包";
btn.onclick = downloadEmoticons;
// 按钮样式
Object.assign(btn.style, {
position: "fixed",
bottom: "20px",
right: "20px",
zIndex: "99999",
backgroundColor: "#00A1D6",
color: "white",
border: "none",
borderRadius: "8px",
padding: "10px 16px",
fontSize: "14px",
cursor: "pointer",
boxShadow: "0 2px 6px rgba(0,0,0,0.3)",
});
// hover 效果
btn.addEventListener("mouseenter", () => (btn.style.backgroundColor = "#00B5E5"));
btn.addEventListener("mouseleave", () => (btn.style.backgroundColor = "#00A1D6"));
document.body.appendChild(btn);
}
// 监听页面加载(避免SPA延迟)
(function () {
"use strict";
const observer = new MutationObserver(() => {
if (document.body) {
makeButton();
observer.disconnect();
}
});
observer.observe(document.documentElement, { childList: true, subtree: true });
})();
```
Този доклад е одобрен от модератор.
Blatant comment spam
