|
let getEmojiLink = function(emoji) { |
|
return emoji.querySelector("img").src.replace(/size=[0-9]+/, "size=48"); |
|
}; |
|
let addEmojiCopy = function() { |
|
document.querySelectorAll("[id^=emoji-picker-grid-]").forEach((emoji) => { |
|
if (disabledEmoji = emoji.querySelector("[class*=emojiItemDisabled]")) { |
|
emoji.onclick = function() { |
|
document.querySelector("[class*=emojiButton]").click(); |
|
const textbox = document.querySelector("[role=textbox]"); |
|
textbox.dispatchEvent(new InputEvent("beforeinput", {data: getEmojiLink(emoji), inputType: "insertText"})); |
|
textbox.dispatchEvent(new FocusEvent("focusin")); |
|
} |
|
disabledEmoji.classList.forEach(function(className) { |
|
if (className.startsWith("emojiItemDisabled")) {disabledEmoji.classList.remove(className);} |
|
}); |
|
} |
|
emoji.onmouseup = function(event) { |
|
if (event.which === 3) { |
|
navigator.clipboard.writeText(getEmojiLink(emoji)); |
|
} |
|
}; |
|
}); |
|
}; |
|
let getStickerLink = function(sticker) { |
|
return sticker.querySelector("img").src.replace(/size=[0-9]+/, "size=160"); |
|
}; |
|
let addStickerCopy = function() { |
|
document.querySelectorAll("[id^=sticker-picker-grid-]").forEach((sticker) => { |
|
if (disabledSticker = sticker.querySelector("[class*=stickerUnsendable]")) { |
|
sticker.onclick = function() { |
|
document.querySelector("[class*=emojiButton]").click(); |
|
document.querySelector("[class*=emojiButton]").click(); |
|
const textbox = document.querySelector("[role=textbox]"); |
|
textbox.dispatchEvent(new InputEvent("beforeinput", {data: getStickerLink(sticker), inputType: "insertText"})); |
|
textbox.dispatchEvent(new FocusEvent("focusin")); |
|
} |
|
disabledSticker.classList.forEach(function(className) { |
|
if (className.startsWith("stickerUnsendable")) {disabledSticker.classList.remove(className);} |
|
}); |
|
} |
|
sticker.onmouseup = function(event) { |
|
if (event.which === 3) { |
|
navigator.clipboard.writeText(getStickerLink(sticker)); |
|
} |
|
}; |
|
}); |
|
}; |
|
document.onclick = function() { |
|
try { |
|
addEmojiCopy(); |
|
document.querySelector("[data-ref-id^=emoji-picker-grid]").querySelector("[class^=scroller]").onscroll = addEmojiCopy; |
|
const emojiPicker = document.querySelector("#emoji-picker-tab-panel"); |
|
emojiPicker.onmousemove = addEmojiCopy; |
|
emojiPicker.onkeyup = addEmojiCopy; |
|
} catch (err) {} |
|
setTimeout(function() { |
|
try { |
|
addStickerCopy(); |
|
document.querySelector("[data-ref-id^=sticker-picker-grid]").querySelector("[class^=scroller]").onscroll = addStickerCopy; |
|
const stickerPicker = document.querySelector("#sticker-picker-tab-panel"); |
|
stickerPicker.onmousemove = addStickerCopy; |
|
stickerPicker.onkeyup = addStickerCopy; |
|
} catch (err) {} |
|
}, 200); |
|
}; |