mirror of
https://github.com/EndPwnArchive/EndPwn3Plugins.git
synced 2024-08-14 23:57:06 +00:00
34 lines
No EOL
1.5 KiB
JavaScript
34 lines
No EOL
1.5 KiB
JavaScript
exports.manifest = {
|
|
author: "Cynosphere, Jiiks",
|
|
name: "Double Click Edit",
|
|
description: "Double click messages to edit them. Hold ctrl while double clicking to copy message contents."
|
|
}
|
|
exports.start = function(){
|
|
document.addEventListener("dblclick", ev => {
|
|
let target = ev.target;
|
|
if(target && target.className && (target.className.includes("markup") || target.className.includes("hljs") || target.className.includes("inline"))) {
|
|
let msg = target;
|
|
if(!ev.ctrlKey){
|
|
let opt = msg.parentNode.parentNode.className.includes("markup") ? msg.parentNode.parentNode.parentNode.querySelector(".btn-option") : msg.parentNode.querySelector(".btn-option");
|
|
opt.click();
|
|
let options = document.querySelectorAll(".option-popout .btn-item");
|
|
for(i in options){
|
|
let o = options[i];
|
|
if(o.innerHTML == "Edit") o.click();
|
|
}
|
|
}else{
|
|
var range = document.createRange();
|
|
range.selectNode(msg);
|
|
window.getSelection().addRange(range);
|
|
try {
|
|
for(var i=0;i<5;i++){
|
|
document.execCommand('copy');
|
|
}
|
|
} catch (err) {
|
|
console.log(err);
|
|
}
|
|
window.getSelection().removeRange(range);
|
|
}
|
|
}
|
|
});
|
|
} |