stuff
This commit is contained in:
parent
9153b68114
commit
ff05f3ed74
|
@ -1067,7 +1067,7 @@
|
||||||
if (getExport && BDFDB.ModuleUtils.cached[type].export[cachestring]) return BDFDB.ModuleUtils.cached[type].export[cachestring];
|
if (getExport && BDFDB.ModuleUtils.cached[type].export[cachestring]) return BDFDB.ModuleUtils.cached[type].export[cachestring];
|
||||||
else if (!getExport && BDFDB.ModuleUtils.cached[type].module[cachestring]) return BDFDB.ModuleUtils.cached[type].module[cachestring];
|
else if (!getExport && BDFDB.ModuleUtils.cached[type].module[cachestring]) return BDFDB.ModuleUtils.cached[type].module[cachestring];
|
||||||
else {
|
else {
|
||||||
var m = BDFDB.ModuleUtils.find(filter, getExport);
|
let m = BDFDB.ModuleUtils.find(filter, getExport);
|
||||||
if (m) {
|
if (m) {
|
||||||
if (getExport) BDFDB.ModuleUtils.cached[type].export[cachestring] = m;
|
if (getExport) BDFDB.ModuleUtils.cached[type].export[cachestring] = m;
|
||||||
else BDFDB.ModuleUtils.cached[type].module[cachestring] = m;
|
else BDFDB.ModuleUtils.cached[type].module[cachestring] = m;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -6,7 +6,7 @@ var GoogleSearchReplace = (_ => {
|
||||||
return class GoogleSearchReplace {
|
return class GoogleSearchReplace {
|
||||||
getName () {return "GoogleSearchReplace";}
|
getName () {return "GoogleSearchReplace";}
|
||||||
|
|
||||||
getVersion () {return "1.2.4";}
|
getVersion () {return "1.2.6";}
|
||||||
|
|
||||||
getAuthor () {return "DevilBro";}
|
getAuthor () {return "DevilBro";}
|
||||||
|
|
||||||
|
@ -14,13 +14,7 @@ var GoogleSearchReplace = (_ => {
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.changelog = {
|
this.changelog = {
|
||||||
"improved":[["One Engine", "Enabling only one search engine doesn't create a SubMenu anymore"],["New Library Structure & React","Restructured my Library and switched to React rendering instead of DOM manipulation"]]
|
"fixed":[["Context Menu Update","Fixes for the context menu update, yaaaaaay"]]
|
||||||
};
|
|
||||||
|
|
||||||
this.patchedModules = {
|
|
||||||
after: {
|
|
||||||
SearchWithGoogle: "render"
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,41 +118,55 @@ var GoogleSearchReplace = (_ => {
|
||||||
|
|
||||||
// Begin of own functions
|
// Begin of own functions
|
||||||
|
|
||||||
processSearchWithGoogle (e) {
|
onMessageContextMenu (e) {
|
||||||
if (e.instance.props.value) {
|
this.injectItem(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
onNativeContextMenu (e) {
|
||||||
|
this.injectItem(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
injectItem (e) {
|
||||||
|
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["id", "search-google"]]});
|
||||||
|
if (index > -1) {
|
||||||
|
let text = document.getSelection().toString();
|
||||||
let enabledEngines = BDFDB.ObjectUtils.filter(BDFDB.DataUtils.get(this, "engines"), n => n);
|
let enabledEngines = BDFDB.ObjectUtils.filter(BDFDB.DataUtils.get(this, "engines"), n => n);
|
||||||
let enginesWithoutAll = BDFDB.ObjectUtils.filter(enabledEngines, n => n != "_all", true);
|
let enginesWithoutAll = BDFDB.ObjectUtils.filter(enabledEngines, n => n != "_all", true);
|
||||||
let engineKeys = Object.keys(enginesWithoutAll);
|
let engineKeys = Object.keys(enginesWithoutAll);
|
||||||
if (engineKeys.length == 1) return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
|
if (engineKeys.length == 1) return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
||||||
label: this.labels.context_googlesearchreplace_text.replace("...", this.defaults.engines[engineKeys[0]].name),
|
label: this.labels.context_googlesearchreplace_text.replace("...", this.defaults.engines[engineKeys[0]].name),
|
||||||
|
id: BDFDB.ContextMenuUtils.createItemId(this.name, "single-search"),
|
||||||
action: event => {
|
action: event => {
|
||||||
let useChromium = BDFDB.DataUtils.get(this, "settings", "useChromium");
|
let useChromium = BDFDB.DataUtils.get(this, "settings", "useChromium");
|
||||||
if (!event.shiftKey) BDFDB.ContextMenuUtils.close(e.instance);
|
if (!event.shiftKey) BDFDB.ContextMenuUtils.close(e.instance);
|
||||||
BDFDB.DiscordUtils.openLink(this.defaults.engines[engineKeys[0]].url.replace(textUrlReplaceString, encodeURIComponent(e.instance.props.value)), useChromium, event.shiftKey);
|
BDFDB.DiscordUtils.openLink(this.defaults.engines[engineKeys[0]].url.replace(textUrlReplaceString, encodeURIComponent(text)), useChromium, event.shiftKey);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
else {
|
else {
|
||||||
let items = [];
|
let items = [];
|
||||||
for (let key in enabledEngines) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
|
for (let key in enabledEngines) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
||||||
label: this.defaults.engines[key].name,
|
label: this.defaults.engines[key].name,
|
||||||
danger: key == "_all",
|
id: BDFDB.ContextMenuUtils.createItemId(this.name, "search", key),
|
||||||
|
color: key == "_all" ? BDFDB.LibraryComponents.MenuItems.Colors.DANGER : BDFDB.LibraryComponents.MenuItems.Colors.DEFAULT,
|
||||||
action: event => {
|
action: event => {
|
||||||
let useChromium = BDFDB.DataUtils.get(this, "settings", "useChromium");
|
let useChromium = BDFDB.DataUtils.get(this, "settings", "useChromium");
|
||||||
if (!event.shiftKey) BDFDB.ContextMenuUtils.close(e.instance);
|
if (!event.shiftKey) BDFDB.ContextMenuUtils.close(e.instance);
|
||||||
if (key == "_all") {
|
if (key == "_all") {
|
||||||
for (let key2 in enginesWithoutAll) BDFDB.DiscordUtils.openLink(this.defaults.engines[key2].url.replace(textUrlReplaceString, encodeURIComponent(e.instance.props.value)), useChromium, event.shiftKey);
|
for (let key2 in enginesWithoutAll) BDFDB.DiscordUtils.openLink(this.defaults.engines[key2].url.replace(textUrlReplaceString, encodeURIComponent(text)), useChromium, event.shiftKey);
|
||||||
}
|
}
|
||||||
else BDFDB.DiscordUtils.openLink(this.defaults.engines[key].url.replace(textUrlReplaceString, encodeURIComponent(e.instance.props.value)), useChromium, event.shiftKey);
|
else BDFDB.DiscordUtils.openLink(this.defaults.engines[key].url.replace(textUrlReplaceString, encodeURIComponent(text)), useChromium, event.shiftKey);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
if (!items.length) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
|
if (!items.length) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
||||||
label: this.labels.submenu_disabled_text,
|
label: this.labels.submenu_disabled_text,
|
||||||
|
id: BDFDB.ContextMenuUtils.createItemId(this.name, "disabled"),
|
||||||
disabled: true
|
disabled: true
|
||||||
}));
|
}));
|
||||||
return BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Sub, {
|
children.splice(index, 1, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
||||||
label: this.labels.context_googlesearchreplace_text,
|
label: this.labels.context_googlesearchreplace_text,
|
||||||
render: items
|
id: BDFDB.ContextMenuUtils.createItemId(this.name, "submenu-search"),
|
||||||
});
|
children: items
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ var ReverseImageSearch = (_ => {
|
||||||
return class ReverseImageSearch {
|
return class ReverseImageSearch {
|
||||||
getName () {return "ReverseImageSearch";}
|
getName () {return "ReverseImageSearch";}
|
||||||
|
|
||||||
getVersion () {return "3.5.4";}
|
getVersion () {return "3.5.5";}
|
||||||
|
|
||||||
getAuthor () {return "DevilBro";}
|
getAuthor () {return "DevilBro";}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ var ReverseImageSearch = (_ => {
|
||||||
|
|
||||||
constructor () {
|
constructor () {
|
||||||
this.changelog = {
|
this.changelog = {
|
||||||
"fixed":[["Avatar Search", "Fixed a small issue with the user avatar search entry"]]
|
"fixed":[["Context Menu Update","Fixes for the context menu update, yaaaaaay"]]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -125,8 +125,8 @@ var ReverseImageSearch = (_ => {
|
||||||
|
|
||||||
onGuildContextMenu (e) {
|
onGuildContextMenu (e) {
|
||||||
if (e.instance.props.guild && e.instance.props.target) {
|
if (e.instance.props.guild && e.instance.props.target) {
|
||||||
let guildicon = BDFDB.DOMUtils.containsClass(e.instance.props.target, BDFDB.disCN.avataricon) ? e.instance.props.target : e.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.injectItem(e, 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"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ var ReverseImageSearch = (_ => {
|
||||||
}
|
}
|
||||||
|
|
||||||
onNativeContextMenu (e) {
|
onNativeContextMenu (e) {
|
||||||
if (e.instance.props.type == BDFDB.DiscordConstants.ContextMenuTypes.NATIVE_IMAGE && (e.instance.props.href || e.instance.props.src)) {
|
if (e.type == "NativeImageContextMenu" && (e.instance.props.href || e.instance.props.src)) {
|
||||||
this.injectItem(e, e.instance.props.href || e.instance.props.src);
|
this.injectItem(e, e.instance.props.href || e.instance.props.src);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -165,9 +165,10 @@ var ReverseImageSearch = (_ => {
|
||||||
let enabledEngines = BDFDB.ObjectUtils.filter(BDFDB.DataUtils.get(this, "engines"), n => n);
|
let enabledEngines = BDFDB.ObjectUtils.filter(BDFDB.DataUtils.get(this, "engines"), n => n);
|
||||||
let enginesWithoutAll = BDFDB.ObjectUtils.filter(enabledEngines, n => n != "_all", true);
|
let enginesWithoutAll = BDFDB.ObjectUtils.filter(enabledEngines, n => n != "_all", true);
|
||||||
let engineKeys = Object.keys(enginesWithoutAll);
|
let engineKeys = Object.keys(enginesWithoutAll);
|
||||||
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {name:["FluxContainer(MessageDeveloperModeGroup)", "DeveloperModeGroup"]});
|
let [children, index] = BDFDB.ReactUtils.findChildren(e.returnvalue, {props:[["id", "devmode-copy-id"]]});
|
||||||
if (engineKeys.length == 1) children.splice(index > -1 ? index : children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
|
if (engineKeys.length == 1) children.splice(index > -1 ? index : children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
||||||
label: this.labels.context_reverseimagesearch_text.replace("...", this.defaults.engines[engineKeys[0]].name),
|
label: this.labels.context_reverseimagesearch_text.replace("...", this.defaults.engines[engineKeys[0]].name),
|
||||||
|
id: BDFDB.ContextMenuUtils.createItemId(this.name, "single-search"),
|
||||||
action: event => {
|
action: event => {
|
||||||
let useChromium = BDFDB.DataUtils.get(this, "settings", "useChromium");
|
let useChromium = BDFDB.DataUtils.get(this, "settings", "useChromium");
|
||||||
if (!event.shiftKey) BDFDB.ContextMenuUtils.close(e.instance);
|
if (!event.shiftKey) BDFDB.ContextMenuUtils.close(e.instance);
|
||||||
|
@ -176,9 +177,10 @@ var ReverseImageSearch = (_ => {
|
||||||
}));
|
}));
|
||||||
else {
|
else {
|
||||||
let items = [];
|
let items = [];
|
||||||
for (let key in enabledEngines) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
|
for (let key in enabledEngines) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
||||||
label: this.defaults.engines[key].name,
|
label: this.defaults.engines[key].name,
|
||||||
danger: key == "_all",
|
id: BDFDB.ContextMenuUtils.createItemId(this.name, "search", key),
|
||||||
|
color: key == "_all" ? BDFDB.LibraryComponents.MenuItems.Colors.DANGER : BDFDB.LibraryComponents.MenuItems.Colors.DEFAULT,
|
||||||
action: event => {
|
action: event => {
|
||||||
let useChromium = BDFDB.DataUtils.get(this, "settings", "useChromium");
|
let useChromium = BDFDB.DataUtils.get(this, "settings", "useChromium");
|
||||||
if (!event.shiftKey) BDFDB.ContextMenuUtils.close(e.instance);
|
if (!event.shiftKey) BDFDB.ContextMenuUtils.close(e.instance);
|
||||||
|
@ -188,14 +190,16 @@ var ReverseImageSearch = (_ => {
|
||||||
else BDFDB.DiscordUtils.openLink(this.defaults.engines[key].url.replace(imgUrlReplaceString, encodeURIComponent(url)), useChromium, event.shiftKey);
|
else BDFDB.DiscordUtils.openLink(this.defaults.engines[key].url.replace(imgUrlReplaceString, encodeURIComponent(url)), useChromium, event.shiftKey);
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
if (!items.length) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Item, {
|
if (!items.length) items.push(BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
||||||
label: this.labels.submenu_disabled_text,
|
label: this.labels.submenu_disabled_text,
|
||||||
|
id: BDFDB.ContextMenuUtils.createItemId(this.name, "disabled"),
|
||||||
disabled: true
|
disabled: true
|
||||||
}));
|
}));
|
||||||
children.splice(index > -1 ? index : children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Group, {
|
children.splice(index > -1 ? index : children.length, 0, BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuGroup, {
|
||||||
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.ContextMenuItems.Sub, {
|
children: BDFDB.ReactUtils.createElement(BDFDB.LibraryComponents.MenuItems.MenuItem, {
|
||||||
label: this.labels.context_reverseimagesearch_text,
|
label: this.labels.context_reverseimagesearch_text,
|
||||||
render: items
|
id: BDFDB.ContextMenuUtils.createItemId(this.name, "submenu-search"),
|
||||||
|
children: items
|
||||||
})
|
})
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue