From 0d81028a3c697dd581c3fb2c5c3b6ffca372f5b7 Mon Sep 17 00:00:00 2001 From: Alexei Stukov Date: Tue, 7 Aug 2018 08:32:14 +0300 Subject: [PATCH] Working again --- Plugins/dblClickEdit.plugin.js | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/Plugins/dblClickEdit.plugin.js b/Plugins/dblClickEdit.plugin.js index 835d40f..e4b6377 100644 --- a/Plugins/dblClickEdit.plugin.js +++ b/Plugins/dblClickEdit.plugin.js @@ -2,35 +2,29 @@ var dblClickEdit = function () {}; +dblClickEdit.prototype.handler = function(e) { + const message = e.target.closest('[class^=messageCozy]'); + if (!message) return; + const btn = message.querySelector('[class^=buttonContainer] [class^=button-]'); + if (!btn) return; + btn.click(); + for (let btn of [...document.querySelectorAll(`[role=menu] [type=button]`)]) { if (btn.innerText && btn.innerText.includes('Edit')) btn.click(); } +}; + dblClickEdit.prototype.onMessage = function () { }; dblClickEdit.prototype.onSwitch = function () { }; dblClickEdit.prototype.start = function () { - $(document).on("dblclick.dce", function(e) { - var target = $(e.target); - if(target.parents(".message-1PNnaP").length > 0) { - var msg = target.parents(".message-1PNnaP").first(); - var opt = msg.find(".button-3Jq0g9"); - opt.click(); - - $.each($(".popout-3sVMXz .button-38aScr"), (index, value) => { - var option = $(value); - if(option.text() === "Edit") { - option.click(); - } - }); - - } - }); + document.addEventListener('dblclick', this.handler); }; dblClickEdit.prototype.load = function () {}; dblClickEdit.prototype.unload = function () { - $(document).off("dblclick.dce"); + document.removeEventListener('dblclick', this.handler); }; dblClickEdit.prototype.stop = function () { - $(document).off("dblclick.dce"); + document.removeEventListener('dblclick', this.handler); }; dblClickEdit.prototype.getSettingsPanel = function () { return "";