plugins
This commit is contained in:
parent
953e2a976c
commit
3c6828d825
|
@ -3,7 +3,7 @@
|
||||||
class GoogleSearchReplace {
|
class GoogleSearchReplace {
|
||||||
getName () {return "GoogleSearchReplace";}
|
getName () {return "GoogleSearchReplace";}
|
||||||
|
|
||||||
getVersion () {return "1.1.9";}
|
getVersion () {return "1.2.0";}
|
||||||
|
|
||||||
getAuthor () {return "DevilBro";}
|
getAuthor () {return "DevilBro";}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class GoogleSearchReplace {
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.changelog = {
|
this.changelog = {
|
||||||
"fixed":[["Light Theme Update","Fixed bugs for the Light Theme Update, which broke 99% of my plugins"]]
|
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,19 +42,24 @@ class GoogleSearchReplace {
|
||||||
getSettingsPanel () {
|
getSettingsPanel () {
|
||||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||||
let engines = BDFDB.DataUtils.get(this, "engines");
|
let engines = BDFDB.DataUtils.get(this, "engines");
|
||||||
let settingshtml = `<div class="${this.name}-settings BDFDB-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.titlesize18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="BDFDB-settings-inner">`;
|
let settingsitems = [], inneritems = [];
|
||||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">Search Engines:</h3></div><div class="BDFDB-settings-inner-list">`;
|
|
||||||
for (let key in engines) {
|
for (let key in engines) inneritems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.engines[key].name}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="engines ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${engines[key] ? " checked" : ""}></div></div>`;
|
className: BDFDB.disCN.marginbottom8,
|
||||||
}
|
type: "Switch",
|
||||||
settingshtml += `</div>`;
|
plugin: this,
|
||||||
settingshtml += `</div></div>`;
|
keys: ["engines", key],
|
||||||
|
label: this.defaults.engines[key].name,
|
||||||
let settingspanel = BDFDB.DOMUtils.create(settingshtml);
|
value: engines[key]
|
||||||
|
}));
|
||||||
BDFDB.initElements(settingspanel, this);
|
settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
|
||||||
|
title: "Search Engines:",
|
||||||
return settingspanel;
|
first: settingsitems.length == 0,
|
||||||
|
last: true,
|
||||||
|
children: inneritems
|
||||||
|
}));
|
||||||
|
|
||||||
|
return BDFDB.PluginUtils.createSettingsPanel(this, settingsitems);
|
||||||
}
|
}
|
||||||
|
|
||||||
//legacy
|
//legacy
|
||||||
|
@ -100,27 +105,26 @@ class GoogleSearchReplace {
|
||||||
|
|
||||||
// begin of own functions
|
// begin of own functions
|
||||||
|
|
||||||
onNativeContextMenu (instance, menu, returnvalue) {
|
onNativeContextMenu (e) {
|
||||||
if (instance.props && instance.props.type == "NATIVE_TEXT" && instance.props.value && !menu.querySelector(`${this.name}-contextMenuSubItem`)) {
|
if (e.instance.props && e.instance.props.type == "NATIVE_TEXT" && e.instance.props.value) this.injectItem(e, e.instance.props.value);
|
||||||
this.appendItem(menu, returnvalue, instance.props.value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
onMessageContextMenu (instance, menu, returnvalue) {
|
onMessageContextMenu (e) {
|
||||||
if (instance.props && instance.props.message && instance.props.channel && instance.props.target && !menu.querySelector(`${this.name}-contextMenuSubItem`)) {
|
if (e.instance.props && e.instance.props.message && e.instance.props.channel && e.instance.props.target) {
|
||||||
let text = document.getSelection().toString();
|
let text = document.getSelection().toString();
|
||||||
if (text) this.appendItem(menu, returnvalue, text);
|
if (text) this.injectItem(e, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
appendItem (menu, returnvalue, text) {
|
injectItem (e, text) {
|
||||||
let engines = BDFDB.DataUtils.get(this, "engines");
|
let engines = BDFDB.DataUtils.get(this, "engines");
|
||||||
let items = [];
|
let items = [];
|
||||||
for (let key in engines) if (engines[key]) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
for (let key in engines) if (engines[key]) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItem, {
|
||||||
label: this.defaults.engines[key].name,
|
label: this.defaults.engines[key].name,
|
||||||
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-engine-contextMenuItem`,
|
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-engine-contextMenuItem`,
|
||||||
|
danger: key == "_all",
|
||||||
action: e => {
|
action: e => {
|
||||||
if (!e.shiftKey) BDFDB.ContextMenuUtils.close(menu);
|
if (!e.shiftKey) BDFDB.ContextMenuUtils.close(e.instance);
|
||||||
if (key == "_all") {
|
if (key == "_all") {
|
||||||
for (let key2 in engines) if (key2 != "_all" && engines[key2]) window.open(this.defaults.engines[key2].url.replace(this.textUrlReplaceString, encodeURIComponent(text)), "_blank");
|
for (let key2 in engines) if (key2 != "_all" && engines[key2]) window.open(this.defaults.engines[key2].url.replace(this.textUrlReplaceString, encodeURIComponent(text)), "_blank");
|
||||||
}
|
}
|
||||||
|
@ -132,7 +136,7 @@ class GoogleSearchReplace {
|
||||||
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-disabled-contextMenuItem`,
|
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-disabled-contextMenuItem`,
|
||||||
disabled: true
|
disabled: true
|
||||||
}));
|
}));
|
||||||
let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {name:"SearchWithGoogle"});
|
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:"SearchWithGoogle"});
|
||||||
const item = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
|
const item = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuSubItem, {
|
||||||
label: this.labels.context_googlesearchreplace_text,
|
label: this.labels.context_googlesearchreplace_text,
|
||||||
className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-search-contextMenuSubItem`,
|
className: `BDFDB-contextMenuSubItem ${this.name}-contextMenuSubItem ${this.name}-search-contextMenuSubItem`,
|
||||||
|
|
|
@ -118,7 +118,6 @@ class RepoControls {
|
||||||
this.stopping = true;
|
this.stopping = true;
|
||||||
|
|
||||||
BDFDB.ModuleUtils.forceAllUpdates(this);
|
BDFDB.ModuleUtils.forceAllUpdates(this);
|
||||||
//BDFDB.DOMUtils.removeClassFromDOM("repocontrols-added");
|
|
||||||
|
|
||||||
BDFDB.PluginUtils.clear(this);
|
BDFDB.PluginUtils.clear(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class RevealAllSpoilersOption {
|
class RevealAllSpoilersOption {
|
||||||
getName () {return "RevealAllSpoilersOption";}
|
getName () {return "RevealAllSpoilersOption";}
|
||||||
|
|
||||||
getVersion () {return "1.0.1";}
|
getVersion () {return "1.0.2";}
|
||||||
|
|
||||||
getAuthor () {return "DevilBro";}
|
getAuthor () {return "DevilBro";}
|
||||||
|
|
||||||
|
@ -11,11 +11,7 @@ class RevealAllSpoilersOption {
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.changelog = {
|
this.changelog = {
|
||||||
"fixed":[["Light Theme Update","Fixed bugs for the Light Theme Update, which broke 99% of my plugins"]]
|
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
|
||||||
};
|
|
||||||
|
|
||||||
this.patchModules = {
|
|
||||||
"StandardSidebarView":"componentWillUnmount"
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,11 +59,11 @@ class RevealAllSpoilersOption {
|
||||||
|
|
||||||
// begin of own functions
|
// begin of own functions
|
||||||
|
|
||||||
onMessageContextMenu (instance, menu, returnvalue) {
|
onMessageContextMenu (e) {
|
||||||
if (instance.props && instance.props.message && instance.props.target && !menu.querySelector(`${this.name}-contextMenuItem`)) {
|
if (e.instance.props && e.instance.props.message && e.instance.props.target) {
|
||||||
let messagediv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagegroup + "> [aria-disabled]", instance.props.target);
|
let messagediv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagegroup + "> [aria-disabled]", e.instance.props.target) || BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagegroup + "> * > [aria-disabled]", e.instance.props.target);
|
||||||
if (!messagediv || !messagediv.querySelector(BDFDB.dotCN.spoilerhidden)) return;
|
if (!messagediv || !messagediv.querySelector(BDFDB.dotCN.spoilerhidden)) return;
|
||||||
let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
|
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
|
||||||
const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
|
const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
|
||||||
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
|
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
|
||||||
children: [
|
children: [
|
||||||
|
@ -76,7 +72,7 @@ class RevealAllSpoilersOption {
|
||||||
hint: BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("__Reveal_Spoilers") : null,
|
hint: BDFDB.BDUtils.isPluginEnabled("MessageUtilities") ? BDFDB.BDUtils.getPlugin("MessageUtilities").getActiveShortcutString("__Reveal_Spoilers") : null,
|
||||||
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-reveal-contextMenuItem`,
|
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-reveal-contextMenuItem`,
|
||||||
action: e => {
|
action: e => {
|
||||||
BDFDB.ContextMenuUtils.close(menu);
|
BDFDB.ContextMenuUtils.close(e.instance);
|
||||||
this.revealAllSpoilers(messagediv);
|
this.revealAllSpoilers(messagediv);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -88,7 +84,7 @@ class RevealAllSpoilersOption {
|
||||||
}
|
}
|
||||||
|
|
||||||
revealAllSpoilers (target) {
|
revealAllSpoilers (target) {
|
||||||
let messagediv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagegroup + "> [aria-disabled]", target);
|
let messagediv = BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagegroup + "> [aria-disabled]", target) || BDFDB.DOMUtils.getParent(BDFDB.dotCN.messagegroup + "> * > [aria-disabled]", target);
|
||||||
if (!messagediv) return;
|
if (!messagediv) return;
|
||||||
for (let spoiler of messagediv.querySelectorAll(BDFDB.dotCN.spoilerhidden)) spoiler.click();
|
for (let spoiler of messagediv.querySelectorAll(BDFDB.dotCN.spoilerhidden)) spoiler.click();
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class ReverseImageSearch {
|
class ReverseImageSearch {
|
||||||
getName () {return "ReverseImageSearch";}
|
getName () {return "ReverseImageSearch";}
|
||||||
|
|
||||||
getVersion () {return "3.4.6";}
|
getVersion () {return "3.4.7";}
|
||||||
|
|
||||||
getAuthor () {return "DevilBro";}
|
getAuthor () {return "DevilBro";}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class ReverseImageSearch {
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.changelog = {
|
this.changelog = {
|
||||||
"added":[["New Options","Right clicking a user avatar/server icon/custom emoji now also adds a context menu entry to reverse image search the image, can be disabled"]]
|
"improved":[["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,26 +42,34 @@ class ReverseImageSearch {
|
||||||
|
|
||||||
getSettingsPanel () {
|
getSettingsPanel () {
|
||||||
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
if (!global.BDFDB || typeof BDFDB != "object" || !BDFDB.loaded || !this.started) return;
|
||||||
let settings = BDFDB.DataUtils.get(this, "settings");
|
let settings = BDFDB.DataUtils.get(this, "engines");
|
||||||
let engines = BDFDB.DataUtils.get(this, "engines");
|
let engines = BDFDB.DataUtils.get(this, "engines");
|
||||||
let settingshtml = `<div class="${this.name}-settings BDFDB-settings"><div class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.titlesize18 + BDFDB.disCNS.height24 + BDFDB.disCNS.weightnormal + BDFDB.disCN.marginbottom8}">${this.name}</div><div class="BDFDB-settings-inner">`;
|
let settingsitems = [], inneritems = [];
|
||||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">Add a contextmenu entry when right clicking</h3></div><div class="BDFDB-settings-inner-list">`;
|
|
||||||
for (let key in settings) {
|
for (let key in settings) settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.settings[key].description}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="settings ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${settings[key] ? " checked" : ""}></div></div>`;
|
className: BDFDB.disCN.marginbottom8,
|
||||||
}
|
type: "Switch",
|
||||||
settingshtml += `</div>`;
|
plugin: this,
|
||||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 0 0 auto;">Search Engines:</h3></div><div class="BDFDB-settings-inner-list">`;
|
keys: ["settings", key],
|
||||||
for (let key in engines) {
|
label: this.defaults.settings[key].description,
|
||||||
settingshtml += `<div class="${BDFDB.disCNS.flex + BDFDB.disCNS.horizontal + BDFDB.disCNS.justifystart + BDFDB.disCNS.aligncenter + BDFDB.disCNS.nowrap + BDFDB.disCN.marginbottom8}" style="flex: 1 1 auto;"><h3 class="${BDFDB.disCNS.titledefault + BDFDB.disCNS.marginreset + BDFDB.disCNS.weightmedium + BDFDB.disCNS.titlesize16 + BDFDB.disCNS.height24 + BDFDB.disCN.flexchild}" style="flex: 1 1 auto;">${this.defaults.engines[key].name}</h3><div class="${BDFDB.disCNS.flexchild + BDFDB.disCNS.switchenabled + BDFDB.disCNS.switch + BDFDB.disCNS.switchvalue + BDFDB.disCNS.switchsizedefault + BDFDB.disCNS.switchsize + BDFDB.disCN.switchthemedefault}" style="flex: 0 0 auto;"><input type="checkbox" value="engines ${key}" class="${BDFDB.disCNS.switchinnerenabled + BDFDB.disCN.switchinner} settings-switch"${engines[key] ? " checked" : ""}></div></div>`;
|
value: settings[key]
|
||||||
}
|
}));
|
||||||
settingshtml += `</div>`;
|
for (let key in engines) inneritems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsSaveItem, {
|
||||||
settingshtml += `</div></div>`;
|
className: BDFDB.disCN.marginbottom8,
|
||||||
|
type: "Switch",
|
||||||
let settingspanel = BDFDB.DOMUtils.create(settingshtml);
|
plugin: this,
|
||||||
|
keys: ["engines", key],
|
||||||
BDFDB.initElements(settingspanel, this);
|
label: this.defaults.engines[key].name,
|
||||||
|
value: engines[key]
|
||||||
return settingspanel;
|
}));
|
||||||
|
settingsitems.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.SettingsPanelInner, {
|
||||||
|
title: "Search Engines:",
|
||||||
|
first: settingsitems.length == 0,
|
||||||
|
last: true,
|
||||||
|
children: inneritems
|
||||||
|
}));
|
||||||
|
|
||||||
|
return BDFDB.PluginUtils.createSettingsPanel(this, settingsitems);
|
||||||
}
|
}
|
||||||
|
|
||||||
//legacy
|
//legacy
|
||||||
|
@ -107,41 +115,33 @@ class ReverseImageSearch {
|
||||||
|
|
||||||
// begin of own functions
|
// begin of own functions
|
||||||
|
|
||||||
onGuildContextMenu (instance, menu, returnvalue) {
|
onGuildContextMenu (e) {
|
||||||
if (instance.props && instance.props.guild && instance.props.target) {
|
if (e.instance.props && e.instance.props.guild && e.instance.props.target) {
|
||||||
let guildicon = BDFDB.DOMUtils.containsClass(instance.props.target, BDFDB.disCN.avataricon) ? instance.props.target : instance.props.target.querySelector(BDFDB.dotCN.guildicon);
|
let guildicon = BDFDB.DOMUtils.containsClass(e.instance.props.target, BDFDB.disCN.avataricon) ? e.instance.props.target : e.instance.props.target.querySelector(BDFDB.dotCN.guildicon);
|
||||||
if (guildicon && BDFDB.DataUtils.get(this, "settings", "addGuildIconEntry")) this.appendItem(menu, returnvalue, guildicon.tagName == "IMG" ? guildicon.getAttribute("src") : guildicon.style.getPropertyValue("background-image"));
|
if (guildicon && BDFDB.DataUtils.get(this, "settings", "addGuildIconEntry")) this.injectItem(e, guildicon.tagName == "IMG" ? guildicon.getAttribute("src") : guildicon.style.getPropertyValue("background-image"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onUserContextMenu (instance, menu, returnvalue) {
|
onUserContextMenu (e) {
|
||||||
if (instance.props && instance.props.user && instance.props.target) {
|
if (e.instance.props && e.instance.props.user && e.instance.props.target) {
|
||||||
let avatar = BDFDB.DOMUtils.containsClass(instance.props.target, BDFDB.disCN.avataricon) ? instance.props.target : instance.props.target.querySelector(BDFDB.dotCN.avatar);
|
let avatar = BDFDB.DOMUtils.containsClass(e.instance.props.target, BDFDB.disCN.avataricon) ? e.instance.props.target : e.instance.props.target.querySelector(BDFDB.dotCN.avatar);
|
||||||
if (avatar && BDFDB.DataUtils.get(this, "settings", "addUserAvatarEntry")) this.appendItem(menu, returnvalue, avatar.tagName == "IMG" ? avatar.getAttribute("src") : avatar.style.getPropertyValue("background-image"));
|
if (avatar && BDFDB.DataUtils.get(this, "settings", "addUserAvatarEntry")) this.injectItem(e, avatar.tagName == "IMG" ? avatar.getAttribute("src") : avatar.style.getPropertyValue("background-image"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onNativeContextMenu (instance, menu, returnvalue) {
|
onNativeContextMenu (e) {
|
||||||
if (instance.props && instance.props.type == "NATIVE_IMAGE" && (instance.props.href || instance.props.src) && !menu.querySelector(`${this.name}-contextMenuSubItem`)) {
|
if (e.instance.props && e.instance.props.type == "NATIVE_IMAGE" && (e.instance.props.href || e.instance.props.src)) this.injectItem(e, e.instance.props.href || e.instance.props.src);
|
||||||
this.appendItem(menu, returnvalue, instance.props.href || instance.props.src);
|
}
|
||||||
|
|
||||||
|
onMessageContextMenu (e) {
|
||||||
|
if (e.instance.props && e.instance.props.message && e.instance.props.channel && e.instance.props.target) {
|
||||||
|
if (e.instance.props.attachment) this.injectItem(e, e.instance.props.attachment.url);
|
||||||
|
else if (e.instance.props.target.tagName == "A" && e.instance.props.message.embeds && e.instance.props.message.embeds[0] && e.instance.props.message.embeds[0].type == "image") this.injectItem(e, e.instance.props.target.href);
|
||||||
|
else if (e.instance.props.target.tagName == "IMG" && BDFDB.DOMUtils.containsClass(e.instance.props.target, "emoji", "emote", false) && BDFDB.DataUtils.get(this, "settings", "addEmojiEntry")) this.injectItem(e, e.instance.props.target.src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMessageContextMenu (instance, menu, returnvalue) {
|
injectItem (e, url) {
|
||||||
if (instance.props && instance.props.message && instance.props.channel && instance.props.target && !menu.querySelector(".reverseimagesearch-item")) {
|
|
||||||
if (instance.props.attachment) {
|
|
||||||
this.appendItem(menu, returnvalue, instance.props.attachment.url);
|
|
||||||
}
|
|
||||||
if (instance.props.target.tagName == "A" && instance.props.message.embeds && instance.props.message.embeds[0] && instance.props.message.embeds[0].type == "image") {
|
|
||||||
this.appendItem(menu, returnvalue, instance.props.target.href);
|
|
||||||
}
|
|
||||||
if (instance.props.target.tagName == "IMG" && BDFDB.DOMUtils.containsClass(instance.props.target, "emoji", "emote", false) && BDFDB.DataUtils.get(this, "settings", "addEmojiEntry")) {
|
|
||||||
this.appendItem(menu, returnvalue, instance.props.target.src);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
appendItem (menu, returnvalue, url) {
|
|
||||||
if (url && url.indexOf("discordapp.com/assets/") == -1 && !url.endsWith(".mp4")) {
|
if (url && url.indexOf("discordapp.com/assets/") == -1 && !url.endsWith(".mp4")) {
|
||||||
url = url.replace(/^url\(|\)$|"|'/g, "").replace(/\?size\=\d+$/, "?size=4096");
|
url = url.replace(/^url\(|\)$|"|'/g, "").replace(/\?size\=\d+$/, "?size=4096");
|
||||||
if (url.indexOf("https://images-ext-1.discordapp.net/external/") > -1) {
|
if (url.indexOf("https://images-ext-1.discordapp.net/external/") > -1) {
|
||||||
|
@ -155,7 +155,7 @@ class ReverseImageSearch {
|
||||||
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-engine-contextMenuItem`,
|
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-engine-contextMenuItem`,
|
||||||
danger: key == "_all",
|
danger: key == "_all",
|
||||||
action: e => {
|
action: e => {
|
||||||
if (!e.shiftKey) BDFDB.ContextMenuUtils.close(menu);
|
if (!e.shiftKey) BDFDB.ContextMenuUtils.close(e.instance);
|
||||||
if (key == "_all") {
|
if (key == "_all") {
|
||||||
for (let key2 in engines) if (key2 != "_all" && engines[key2]) window.open(this.defaults.engines[key2].url.replace(this.imgUrlReplaceString, encodeURIComponent(url)), "_blank");
|
for (let key2 in engines) if (key2 != "_all" && engines[key2]) window.open(this.defaults.engines[key2].url.replace(this.imgUrlReplaceString, encodeURIComponent(url)), "_blank");
|
||||||
}
|
}
|
||||||
|
@ -167,7 +167,7 @@ class ReverseImageSearch {
|
||||||
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-disabled-contextMenuItem`,
|
className: `BDFDB-contextMenuItem ${this.name}-contextMenuItem ${this.name}-disabled-contextMenuItem`,
|
||||||
disabled: true
|
disabled: true
|
||||||
}));
|
}));
|
||||||
let [children, index] = BDFDB.ReactUtils.findChildren(returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
|
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
|
||||||
const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
|
const itemgroup = BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItemGroup, {
|
||||||
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
|
className: `BDFDB-contextMenuItemGroup ${this.name}-contextMenuItemGroup`,
|
||||||
children: [
|
children: [
|
||||||
|
|
Loading…
Reference in New Issue