mirror of
https://github.com/EndPwnArchive/EndPwn3Plugins.git
synced 2024-08-14 23:57:06 +00:00
bump repo version, update charcount and dblclickedit
This commit is contained in:
parent
e39e5f596d
commit
98524a3c20
3 changed files with 91 additions and 71 deletions
|
@ -1,52 +1,57 @@
|
|||
function setupCharCount() {
|
||||
if (document.getElementById("charcounter")) return;
|
||||
if (!document.querySelector("textarea[class*=\"textAreaEnabled-\"]")) return;
|
||||
|
||||
let charcount = document.createElement("span");
|
||||
charcount.id = "charcounter";
|
||||
charcount.innerHTML = "0/2000";
|
||||
charcount.style.right = "40px";
|
||||
charcount.style.bottom = "4px";
|
||||
charcount.style.opacity = "0.5";
|
||||
charcount.style.position = "absolute";
|
||||
charcount.style.display = "block";
|
||||
charcount.style["font-size"] = "85%";
|
||||
|
||||
document.querySelector("div[class*=\"channelTextAreaEnabled-\"]").appendChild(charcount);
|
||||
}
|
||||
|
||||
exports = {
|
||||
manifest: {
|
||||
author: "Cynosphere",
|
||||
name: "Character Counter",
|
||||
description: "Counts characters in the chatbox."
|
||||
},
|
||||
start: function(){
|
||||
let charcount_mo = new MutationObserver(setupCharCount);
|
||||
charcount_mo.observe(document.querySelector("div[class*=\"app-\"]"), {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", ev => {
|
||||
if (!document.getElementById("charcounter") || !document.querySelector("textarea[class*=\"textAreaEnabled-\"]")) return;
|
||||
|
||||
setTimeout(()=>{
|
||||
let length = document.querySelector("textarea[class*=\"textAreaEnabled-\"]").value.length;
|
||||
document.getElementById("charcounter").innerHTML = `${length}/2000`;
|
||||
|
||||
if (length > 1999) {
|
||||
document.getElementById("charcounter").style.color = "#FF0000";
|
||||
} else if (length > 1899) {
|
||||
document.getElementById("charcounter").style.color = "#FF4500";
|
||||
} else if (length > 1499) {
|
||||
document.getElementById("charcounter").style.color = "#FFA500";
|
||||
} else if (length > 999) {
|
||||
document.getElementById("charcounter").style.color = "#F1C40F";
|
||||
} else {
|
||||
document.getElementById("charcounter").style.color = "#FFFFFF";
|
||||
}
|
||||
}, 50);
|
||||
});
|
||||
}
|
||||
function setupCharCount() {
|
||||
if (document.body.contains(charcount)) return;
|
||||
if (!text || !document.body.contains(text)) {
|
||||
text = document.querySelector('textarea[class^="textArea-"]');
|
||||
}
|
||||
if (!text) return;
|
||||
|
||||
text.parentNode.appendChild(charcount);
|
||||
}
|
||||
|
||||
let charcount = document.createElement("span");
|
||||
charcount.id = "charcounter";
|
||||
charcount.innerHTML = "0/2000";
|
||||
charcount.style.right = "40px";
|
||||
charcount.style.bottom = "4px";
|
||||
charcount.style.opacity = "0.5";
|
||||
charcount.style.position = "absolute";
|
||||
charcount.style.display = "block";
|
||||
charcount.style["font-size"] = "85%";
|
||||
|
||||
let text = null;
|
||||
|
||||
exports = {
|
||||
manifest: {
|
||||
author: "Cynosphere",
|
||||
name: "Character Counter",
|
||||
description: "Counts characters in the chatbox."
|
||||
},
|
||||
start: function(){
|
||||
let charcount_mo = new MutationObserver(setupCharCount);
|
||||
charcount_mo.observe(document.querySelector(".app.flex-vertical"), {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
|
||||
document.addEventListener("keydown", ev => {
|
||||
if (!text) return;
|
||||
|
||||
setImmediate(()=>{
|
||||
let length = text.value.length;
|
||||
charcount.innerHTML = `${length}/2000`;
|
||||
|
||||
if (length > 1999) {
|
||||
charcount.style.color = "#FF0000";
|
||||
} else if (length > 1899) {
|
||||
charcount.style.color = "#FF4500";
|
||||
} else if (length > 1499) {
|
||||
charcount.style.color = "#FFA500";
|
||||
} else if (length > 999) {
|
||||
charcount.style.color = "#F1C40F";
|
||||
} else {
|
||||
charcount.style.color = "#FFFFFF";
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,20 +1,35 @@
|
|||
exports.manifest = {
|
||||
author: "Cynosphere, Jiiks",
|
||||
name: "Double Click Edit",
|
||||
description: "Double click messages to edit them."
|
||||
}
|
||||
exports.start = function(){
|
||||
document.addEventListener("dblclick", ev => {
|
||||
let target = ev.target;
|
||||
if(target && target.className && target.className.includes("markup")) {
|
||||
let msg = target;
|
||||
let opt = 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();
|
||||
}
|
||||
}
|
||||
});
|
||||
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;
|
||||
console.log(target);
|
||||
if(target && target.className && (target.className.includes("markup") || target.className.includes("hljs") || targe.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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
|
@ -16,7 +16,7 @@ exports = {
|
|||
author: "Cynosphere",
|
||||
name: "Plugins Repo",
|
||||
description: "Download plugins.",
|
||||
_version: 2
|
||||
_version: 3
|
||||
},
|
||||
|
||||
getInfo: async function(plugin){
|
||||
|
|
Loading…
Reference in a new issue