BetterDiscordApp-v1/Plugins/dblClickEdit.plugin.js

49 lines
1.7 KiB
JavaScript
Raw Normal View History

2016-04-06 01:46:22 +02:00
//META{"name":"dblClickEdit"}*//
var dblClickEdit = function () {};
2018-08-07 07:32:14 +02:00
dblClickEdit.prototype.handler = function(e) {
2018-08-07 08:47:59 +02:00
const message = e.target.closest('[class^=messageCozy]') || e.target.closest('[class^=messageCompact]');
2018-08-07 07:32:14 +02:00
if (!message) return;
const btn = message.querySelector('[class^=buttonContainer] [class^=button-]');
if (!btn) return;
btn.click();
2018-08-07 08:47:59 +02:00
const popup = document.querySelector('[class^=container][role=menu]');
if (!popup) return;
const rii = popup[Object.keys(popup).find(k => k.startsWith('__reactInternal'))];
if (!rii || !rii.memoizedProps || !rii.memoizedProps.children || !rii.memoizedProps.children[1] || !rii.memoizedProps.children[1].props || !rii.memoizedProps.children[1].props.onClick) return;
rii.memoizedProps.children[1].props.onClick();
2018-08-07 07:32:14 +02:00
};
2016-04-06 01:46:22 +02:00
dblClickEdit.prototype.onMessage = function () {
};
dblClickEdit.prototype.onSwitch = function () {
};
dblClickEdit.prototype.start = function () {
2018-08-07 07:32:14 +02:00
document.addEventListener('dblclick', this.handler);
2016-04-06 01:46:22 +02:00
};
dblClickEdit.prototype.load = function () {};
dblClickEdit.prototype.unload = function () {
2018-08-07 07:32:14 +02:00
document.removeEventListener('dblclick', this.handler);
2016-04-06 01:46:22 +02:00
};
dblClickEdit.prototype.stop = function () {
2018-08-07 07:32:14 +02:00
document.removeEventListener('dblclick', this.handler);
2016-04-06 01:46:22 +02:00
};
dblClickEdit.prototype.getSettingsPanel = function () {
return "";
};
dblClickEdit.prototype.getName = function () {
return "Double click edit";
};
dblClickEdit.prototype.getDescription = function () {
return "Double click messages to edit them";
};
dblClickEdit.prototype.getVersion = function () {
2018-08-07 08:47:59 +02:00
return "0.2.1";
2016-04-06 01:46:22 +02:00
};
dblClickEdit.prototype.getAuthor = function () {
return "Jiiks";
2018-04-23 21:42:20 +02:00
};