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,20 +1,25 @@
 | 
			
		|||
function setupCharCount() {
 | 
			
		||||
    if (document.getElementById("charcounter")) return;
 | 
			
		||||
    if (!document.querySelector("textarea[class*=\"textAreaEnabled-\"]")) return;
 | 
			
		||||
    if (document.body.contains(charcount)) return;
 | 
			
		||||
    if (!text || !document.body.contains(text)) {
 | 
			
		||||
        text = document.querySelector('textarea[class^="textArea-"]');
 | 
			
		||||
    }
 | 
			
		||||
    if (!text) 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);
 | 
			
		||||
    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",
 | 
			
		||||
| 
						 | 
				
			
			@ -23,30 +28,30 @@ exports = {
 | 
			
		|||
    },
 | 
			
		||||
    start: function(){
 | 
			
		||||
        let charcount_mo = new MutationObserver(setupCharCount);
 | 
			
		||||
        charcount_mo.observe(document.querySelector("div[class*=\"app-\"]"), {
 | 
			
		||||
        charcount_mo.observe(document.querySelector(".app.flex-vertical"), {
 | 
			
		||||
            childList: true,
 | 
			
		||||
            subtree: true
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        document.addEventListener("keydown", ev => {
 | 
			
		||||
            if (!document.getElementById("charcounter") || !document.querySelector("textarea[class*=\"textAreaEnabled-\"]")) return;
 | 
			
		||||
            if (!text) return;
 | 
			
		||||
 | 
			
		||||
            setTimeout(()=>{
 | 
			
		||||
                let length = document.querySelector("textarea[class*=\"textAreaEnabled-\"]").value.length;
 | 
			
		||||
                document.getElementById("charcounter").innerHTML = `${length}/2000`;
 | 
			
		||||
            setImmediate(()=>{
 | 
			
		||||
                let length = text.value.length;
 | 
			
		||||
                charcount.innerHTML = `${length}/2000`;
 | 
			
		||||
 | 
			
		||||
                if (length > 1999) {
 | 
			
		||||
                    document.getElementById("charcounter").style.color = "#FF0000";
 | 
			
		||||
                    charcount.style.color = "#FF0000";
 | 
			
		||||
                } else if (length > 1899) {
 | 
			
		||||
                    document.getElementById("charcounter").style.color = "#FF4500";
 | 
			
		||||
                    charcount.style.color = "#FF4500";
 | 
			
		||||
                } else if (length > 1499) {
 | 
			
		||||
                    document.getElementById("charcounter").style.color = "#FFA500";
 | 
			
		||||
                    charcount.style.color = "#FFA500";
 | 
			
		||||
                } else if (length > 999) {
 | 
			
		||||
                    document.getElementById("charcounter").style.color = "#F1C40F";
 | 
			
		||||
                    charcount.style.color = "#F1C40F";
 | 
			
		||||
                } else {
 | 
			
		||||
                    document.getElementById("charcounter").style.color = "#FFFFFF";
 | 
			
		||||
                    charcount.style.color = "#FFFFFF";
 | 
			
		||||
                }
 | 
			
		||||
            }, 50);
 | 
			
		||||
            });
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,20 +1,35 @@
 | 
			
		|||
exports.manifest = {
 | 
			
		||||
    author: "Cynosphere, Jiiks",
 | 
			
		||||
    name: "Double Click Edit",
 | 
			
		||||
    description: "Double click messages to edit them."
 | 
			
		||||
    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")) {
 | 
			
		||||
        console.log(target);
 | 
			
		||||
        if(target && target.className && (target.className.includes("markup") || target.className.includes("hljs") || targe.className.includes("inline"))) {
 | 
			
		||||
            let msg = target;
 | 
			
		||||
            let opt = msg.parentNode.querySelector(".btn-option");
 | 
			
		||||
            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…
	
	Add table
		Add a link
		
	
		Reference in a new issue