Update PluginRepo.plugin.js
This commit is contained in:
parent
d7c544abf0
commit
e0569528ca
|
@ -3,7 +3,7 @@
|
||||||
class PluginRepo {
|
class PluginRepo {
|
||||||
getName () {return "PluginRepo";}
|
getName () {return "PluginRepo";}
|
||||||
|
|
||||||
getVersion () {return "1.7.4";}
|
getVersion () {return "1.7.5";}
|
||||||
|
|
||||||
getAuthor () {return "DevilBro";}
|
getAuthor () {return "DevilBro";}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class PluginRepo {
|
||||||
|
|
||||||
initConstructor () {
|
initConstructor () {
|
||||||
this.changelog = {
|
this.changelog = {
|
||||||
"fixed":[["BDContextMenu","Fixed compatibility with the newest version of BDContextMenu"]]
|
"fixed":[["Loading Issues","Fixed loading issues with Zerthox's plugins and fixed issues where an unloadable plugin would harshly slow down the loading process"]]
|
||||||
};
|
};
|
||||||
|
|
||||||
this.patchModules = {
|
this.patchModules = {
|
||||||
|
@ -327,7 +327,7 @@ class PluginRepo {
|
||||||
item = item[item.length-1];
|
item = item[item.length-1];
|
||||||
var settingsContextEntry = BDFDB.htmlToElement(this.settingsContextEntryMarkup);
|
var settingsContextEntry = BDFDB.htmlToElement(this.settingsContextEntryMarkup);
|
||||||
settingsContextEntry.addEventListener("click", () => {
|
settingsContextEntry.addEventListener("click", () => {
|
||||||
if (!this.loading.is) instance._reactInternalFiber.return.memoizedProps.closeContextMenu();
|
if (!this.loading.is) BDFDB.closeContextMenu(menu);
|
||||||
this.openPluginRepoModal();
|
this.openPluginRepoModal();
|
||||||
});
|
});
|
||||||
item.parentElement.insertBefore(settingsContextEntry, item.nextElementSibling);
|
item.parentElement.insertBefore(settingsContextEntry, item.nextElementSibling);
|
||||||
|
@ -746,20 +746,55 @@ class PluginRepo {
|
||||||
if (name.length > 1) {
|
if (name.length > 1) {
|
||||||
name = name[1].split('"')[0];
|
name = name[1].split('"')[0];
|
||||||
webview.getWebContents().executeJavaScript(body).then(() => {
|
webview.getWebContents().executeJavaScript(body).then(() => {
|
||||||
webview.getWebContents().executeJavaScript(`
|
webview.getWebContents().executeJavaScript(`
|
||||||
var p = new ` + name + `();
|
try {
|
||||||
var data = {
|
var getString = (obj) => {
|
||||||
"getName":p.getName(),
|
var string = "";
|
||||||
"getAuthor":p.getAuthor(),
|
if (typeof obj == "string") string = obj;
|
||||||
"getVersion":p.getVersion(),
|
else if (obj && obj.props) {
|
||||||
"getDescription":p.getDescription()
|
if (typeof obj.props.children == "string") string = obj.props.children;
|
||||||
};
|
else if (Array.isArray(obj.props.children)) for (let c of obj.props.children) string += typeof c == "string" ? c : getString(c);
|
||||||
Promise.resolve(data);`
|
}
|
||||||
).then((plugin) => {
|
return string;
|
||||||
plugin.url = url;
|
};
|
||||||
this.loadedPlugins[url] = plugin;
|
var WebModulesFind = (filter) => {
|
||||||
var instPlugin = window.bdplugins[plugin.getName] ? window.bdplugins[plugin.getName].plugin : null;
|
const id = "PluginRepo-WebModules";
|
||||||
if (instPlugin && instPlugin.getAuthor().toUpperCase() == plugin.getAuthor.toUpperCase() && instPlugin.getVersion() != plugin.getVersion) outdated++;
|
const req = typeof(global.window.webpackJsonp) == "function" ? global.window.webpackJsonp([], {[id]: (module, exports, req) => exports.default = req}, [id]).default : global.window.webpackJsonp.push([[], {[id]: (module, exports, req) => module.exports = req}, [[id]]]);
|
||||||
|
delete req.m[id];
|
||||||
|
delete req.c[id];
|
||||||
|
for (let m in req.c) {
|
||||||
|
if (req.c.hasOwnProperty(m)) {
|
||||||
|
var module = req.c[m].exports;
|
||||||
|
if (module && module.__esModule && module.default && filter(module.default)) return module.default;
|
||||||
|
if (module && filter(module)) return module;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
var WebModulesFindByProperties = (properties) => {
|
||||||
|
return WebModulesFind(module => properties.every(prop => module[prop] !== undefined));
|
||||||
|
};
|
||||||
|
global.BDV2 = {};
|
||||||
|
global.BDV2.react = WebModulesFindByProperties(['createElement', 'cloneElement']);
|
||||||
|
global.BDV2.reactDom = WebModulesFindByProperties(['render', 'findDOMNode']);
|
||||||
|
var p = new ` + name + `();
|
||||||
|
var data = {
|
||||||
|
"getName":getString(p.getName()),
|
||||||
|
"getAuthor":getString(p.getAuthor()),
|
||||||
|
"getVersion":getString(p.getVersion()),
|
||||||
|
"getDescription":getString(p.getDescription())
|
||||||
|
};
|
||||||
|
Promise.resolve(data);
|
||||||
|
}
|
||||||
|
catch (err) {
|
||||||
|
Promise.resolve(null);
|
||||||
|
}`
|
||||||
|
).then(plugin => {
|
||||||
|
if (plugin) {
|
||||||
|
plugin.url = url;
|
||||||
|
this.loadedPlugins[url] = plugin;
|
||||||
|
var instPlugin = window.bdplugins[plugin.getName] ? window.bdplugins[plugin.getName].plugin : null;
|
||||||
|
if (instPlugin && instPlugin.getAuthor().toUpperCase() == plugin.getAuthor.toUpperCase() && instPlugin.getVersion() != plugin.getVersion) outdated++;
|
||||||
|
}
|
||||||
webview.getWebContents().reload();
|
webview.getWebContents().reload();
|
||||||
webviewrunning = false;
|
webviewrunning = false;
|
||||||
runInWebview();
|
runInWebview();
|
||||||
|
|
Loading…
Reference in New Issue