stuff
This commit is contained in:
parent
1a099d4bc9
commit
96ccb11106
|
@ -1034,16 +1034,16 @@ module.exports = (_ => {
|
|||
}
|
||||
|
||||
copyFile (url) {
|
||||
BDFDB.LibraryRequires.request(url, {encoding: null}, (error, response, buffer) => {
|
||||
BDFDB.LibraryRequires.request(url, {encoding: null}, (error, response, body) => {
|
||||
let type = this.isValid(url, "video") ? BDFDB.LanguageUtils.LanguageStrings.VIDEO : BDFDB.LanguageUtils.LanguageStrings.IMAGE;
|
||||
if (error) BDFDB.NotificationUtils.toast(this.labels.toast_copy_failed.replace("{{var0}}", type), {type: "danger"});
|
||||
else if (buffer) {
|
||||
else if (body) {
|
||||
if (BDFDB.LibraryRequires.process.platform === "win32" || BDFDB.LibraryRequires.process.platform === "darwin") {
|
||||
BDFDB.LibraryRequires.electron.clipboard.write({image: BDFDB.LibraryRequires.electron.nativeImage.createFromBuffer(buffer)});
|
||||
BDFDB.LibraryRequires.electron.clipboard.write({image: BDFDB.LibraryRequires.electron.nativeImage.createFromBuffer(body)});
|
||||
}
|
||||
else {
|
||||
let file = BDFDB.LibraryRequires.path.join(BDFDB.LibraryRequires.process.env.HOME, "imageutilstempimg.png");
|
||||
BDFDB.LibraryRequires.fs.writeFileSync(file, buffer, {encoding: null});
|
||||
BDFDB.LibraryRequires.fs.writeFileSync(file, body, {encoding: null});
|
||||
BDFDB.LibraryRequires.electron.clipboard.write({image: file});
|
||||
BDFDB.LibraryRequires.fs.unlinkSync(file);
|
||||
}
|
||||
|
|
|
@ -194,14 +194,14 @@ module.exports = (_ => {
|
|||
BDFDB.LibraryRequires.electron.clipboard.write({text});
|
||||
}
|
||||
else if (message.attachments.length == 1 && message.attachments[0].url) {
|
||||
BDFDB.LibraryRequires.request({url: message.attachments[0].url, encoding: null}, (error, response, buffer) => {
|
||||
if (buffer) {
|
||||
BDFDB.LibraryRequires.request(message.attachments[0].url, {encoding: null}, (error, response, body) => {
|
||||
if (body) {
|
||||
if (BDFDB.LibraryRequires.process.platform === "win32" || BDFDB.LibraryRequires.process.platform === "darwin") {
|
||||
BDFDB.LibraryRequires.electron.clipboard.write({image: BDFDB.LibraryRequires.electron.nativeImage.createFromBuffer(buffer)});
|
||||
BDFDB.LibraryRequires.electron.clipboard.write({image: BDFDB.LibraryRequires.electron.nativeImage.createFromBuffer(body)});
|
||||
}
|
||||
else {
|
||||
let file = BDFDB.LibraryRequires.path.join(BDFDB.LibraryRequires.process.env["HOME"], "personalpinstemp.png");
|
||||
BDFDB.LibraryRequires.fs.writeFileSync(file, buffer, {encoding: null});
|
||||
BDFDB.LibraryRequires.fs.writeFileSync(file, body, {encoding: null});
|
||||
BDFDB.LibraryRequires.electron.clipboard.write({image: file});
|
||||
BDFDB.LibraryRequires.fs.unlinkSync(file);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @name PluginRepo
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 2.2.0
|
||||
* @version 2.2.1
|
||||
* @description Allows you to download all Plugins from BD's Website within Discord
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -17,16 +17,12 @@ module.exports = (_ => {
|
|||
"info": {
|
||||
"name": "PluginRepo",
|
||||
"author": "DevilBro",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"description": "Allows you to download all Plugins from BD's Website within Discord"
|
||||
},
|
||||
"changeLog": {
|
||||
"progress": {
|
||||
"New Style and Website Store": "The Repo now directly reflects the Plugins hosted on <a>https://betterdiscord.app/</a> and uses a new Card Style"
|
||||
},
|
||||
"improved": {
|
||||
"Search String Cache": "Saves the Search Query for the Plugins Repo until the Settings Window was closed",
|
||||
"Thumbnails": "Converted Thumbnail Gifs to PNGs to reduce the stress, GIFs play when you hover over the Thumbnail"
|
||||
"Thumbnail Conversion": "Moved Thumbnail Conversion to Card Component to reduce stress on BD Website"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -140,14 +136,13 @@ module.exports = (_ => {
|
|||
let plugins = grabbedPlugins.map(plugin => {
|
||||
const installedPlugin = _this.getInstalledPlugin(plugin);
|
||||
const state = installedPlugin ? (plugin.version && BDFDB.NumberUtils.compareVersions(plugin.version, _this.getString(installedPlugin.version)) ? pluginStates.OUTDATED : pluginStates.INSTALLED) : pluginStates.DOWNLOADABLE;
|
||||
return {
|
||||
...plugin,
|
||||
return Object.assign(plugin, {
|
||||
search: [plugin.name, plugin.version, plugin.author, plugin.description, plugin.tags].flat(10).filter(n => typeof n == "string").join(" ").toUpperCase(),
|
||||
description: plugin.description || "No Description found",
|
||||
fav: favorites.includes(plugin.id) && 1,
|
||||
new: state == pluginStates.DOWNLOADABLE && !cachedPlugins.includes(plugin.id) && 1,
|
||||
state: state
|
||||
};
|
||||
});
|
||||
});
|
||||
if (!this.props.updated) plugins = plugins.filter(plugin => plugin.state != pluginStates.INSTALLED);
|
||||
if (!this.props.outdated) plugins = plugins.filter(plugin => plugin.state != pluginStates.OUTDATED);
|
||||
|
@ -249,6 +244,32 @@ module.exports = (_ => {
|
|||
|
||||
const RepoCardComponent = class PluginCard extends BdApi.React.Component {
|
||||
render() {
|
||||
if (this.props.data.thumbnailUrl && !this.props.data.thumbnailChecked) {
|
||||
if (!window.Buffer) this.props.data.thumbnailChecked = true;
|
||||
else BDFDB.LibraryRequires.request(this.props.data.thumbnailUrl, {encoding: null}, (error, response, body) => {
|
||||
this.props.data.thumbnailChecked = true;
|
||||
if (response && response.headers["content-type"] && response.headers["content-type"] == "image/gif") {
|
||||
const throwAwayImg = new Image(), instance = this;
|
||||
throwAwayImg.onload = function() {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.getContext("2d").drawImage(throwAwayImg, 0, 0, canvas.width = this.width, canvas.height = this.height);
|
||||
try {
|
||||
const oldUrl = instance.props.data.thumbnailUrl;
|
||||
instance.props.data.thumbnailUrl = canvas.toDataURL("image/png");
|
||||
instance.props.data.thumbnailGifUrl = oldUrl;
|
||||
BDFDB.ReactUtils.forceUpdate(instance);
|
||||
} catch(err) {
|
||||
BDFDB.ReactUtils.forceUpdate(instance);
|
||||
}
|
||||
};
|
||||
throwAwayImg.onerror = function() {
|
||||
BDFDB.ReactUtils.forceUpdate(instance);
|
||||
};
|
||||
throwAwayImg.src = "data:" + response.headers["content-type"] + ";base64," + (new Buffer(body).toString("base64"));
|
||||
}
|
||||
else BDFDB.ReactUtils.forceUpdate(this);
|
||||
});
|
||||
}
|
||||
return BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.discoverycard,
|
||||
children: [
|
||||
|
@ -258,7 +279,7 @@ module.exports = (_ => {
|
|||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.discoverycardcoverwrapper,
|
||||
children: [
|
||||
this.props.data.thumbnailUrl && BDFDB.ReactUtils.createElement("img", {
|
||||
this.props.data.thumbnailUrl && this.props.data.thumbnailChecked && BDFDB.ReactUtils.createElement("img", {
|
||||
className: BDFDB.disCN.discoverycardcover,
|
||||
src: this.props.data.thumbnailUrl,
|
||||
onMouseEnter: this.props.data.thumbnailGifUrl && (e => e.target.src = this.props.data.thumbnailGifUrl),
|
||||
|
@ -760,21 +781,6 @@ module.exports = (_ => {
|
|||
checksRunning++;
|
||||
plugin.rawSourceUrl = plugin.latestSourceUrl.replace("https://github.com/", "https://raw.githubusercontent.com/").replace(/\/blob\/(.{32,})/i, "/$1");
|
||||
plugin.thumbnailUrl = plugin.thumbnailUrl ? (plugin.thumbnailUrl.startsWith("https://") ? plugin.thumbnailUrl : `https://betterdiscord.app${plugin.thumbnailUrl}`) : "";
|
||||
if (plugin.thumbnailUrl) BDFDB.LibraryRequires.request({url: plugin.thumbnailUrl, encoding: null}, (error, response, body) => {
|
||||
if (response && response.headers["content-type"] && response.headers["content-type"] == "image/gif") {
|
||||
let throwAwayImg = new Image();
|
||||
throwAwayImg.onload = function() {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.getContext("2d").drawImage(throwAwayImg, 0, 0, canvas.width = this.width, canvas.height = this.height);
|
||||
try {
|
||||
const oldUrl = plugin.thumbnailUrl;
|
||||
plugin.thumbnailUrl = canvas.toDataURL("image/png");
|
||||
plugin.thumbnailGifUrl = oldUrl;
|
||||
} catch(err) {}
|
||||
};
|
||||
throwAwayImg.src = "data:" + response.headers["content-type"] + ";base64," + (new Buffer(body).toString("base64"));
|
||||
}
|
||||
});
|
||||
BDFDB.LibraryRequires.request(plugin.rawSourceUrl, (error, response, body) => {
|
||||
if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) {
|
||||
plugin.name = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar((/@name\s+([^\s^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || plugin.name || "");
|
||||
|
|
|
@ -263,10 +263,7 @@ module.exports = (_ => {
|
|||
BDFDB.TimeUtils.clear(this._previewInterval);
|
||||
}
|
||||
checkImage(base64OrUrl, callback) {
|
||||
if (base64OrUrl.indexOf("https://") == 0 || base64OrUrl.indexOf("http://") == 0) BDFDB.LibraryRequires.request({
|
||||
url: base64OrUrl.trim(),
|
||||
encoding: null
|
||||
}, (error, response, body) => {
|
||||
if (base64OrUrl.indexOf("https://") == 0 || base64OrUrl.indexOf("http://") == 0) BDFDB.LibraryRequires.request(base64OrUrl.trim(), {encoding: null}, (error, response, body) => {
|
||||
if (response && response.headers["content-type"] && response.headers["content-type"].indexOf("image") != -1 && response.headers["content-type"] != "image/gif") {
|
||||
this.resizeImage("data:" + response.headers["content-type"] + ";base64," + (new Buffer(body).toString("base64")), callback);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* @name ThemeRepo
|
||||
* @author DevilBro
|
||||
* @authorId 278543574059057154
|
||||
* @version 2.2.0
|
||||
* @version 2.2.1
|
||||
* @description Allows you to download all Themes from BD's Website within Discord
|
||||
* @invite Jx3TjNS
|
||||
* @donate https://www.paypal.me/MircoWittrien
|
||||
|
@ -17,16 +17,12 @@ module.exports = (_ => {
|
|||
"info": {
|
||||
"name": "ThemeRepo",
|
||||
"author": "DevilBro",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"description": "Allows you to download all Themes from BD's Website within Discord"
|
||||
},
|
||||
"changeLog": {
|
||||
"progress": {
|
||||
"New Style and Website Store": "The Repo now directly reflects the Themes hosted on <a>https://betterdiscord.app/</a> and uses a new Card Style"
|
||||
},
|
||||
"improved": {
|
||||
"Search String Cache": "Saves the Search Query for the Themes Repo until the Settings Window was closed",
|
||||
"Thumbnails": "Converted Thumbnail Gifs to PNGs to reduce the stress, GIFs play when you hover over the Thumbnail"
|
||||
"Thumbnail Conversion": "Moved Thumbnail Conversion to Card Component to reduce stress on BD Website"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -142,14 +138,13 @@ module.exports = (_ => {
|
|||
let themes = grabbedThemes.map(theme => {
|
||||
const installedTheme = _this.getInstalledTheme(theme);
|
||||
const state = installedTheme ? (theme.version && BDFDB.NumberUtils.compareVersions(theme.version, _this.getString(installedTheme.version)) ? themeStates.OUTDATED : themeStates.INSTALLED) : themeStates.DOWNLOADABLE;
|
||||
return {
|
||||
...theme,
|
||||
return Object.assign(theme, {
|
||||
search: [theme.name, theme.version, theme.author, theme.description, theme.tags].flat(10).filter(n => typeof n == "string").join(" ").toUpperCase(),
|
||||
description: theme.description || "No Description found",
|
||||
fav: favorites.includes(theme.id) && 1,
|
||||
new: state == themeStates.DOWNLOADABLE && !cachedThemes.includes(theme.id) && 1,
|
||||
state: state
|
||||
};
|
||||
});
|
||||
});
|
||||
if (!this.props.updated) themes = themes.filter(theme => theme.state != themeStates.INSTALLED);
|
||||
if (!this.props.outdated) themes = themes.filter(theme => theme.state != themeStates.OUTDATED);
|
||||
|
@ -654,6 +649,32 @@ module.exports = (_ => {
|
|||
|
||||
const RepoCardComponent = class ThemeCard extends BdApi.React.Component {
|
||||
render() {
|
||||
if (this.props.data.thumbnailUrl && !this.props.data.thumbnailChecked) {
|
||||
if (!window.Buffer) this.props.data.thumbnailChecked = true;
|
||||
else BDFDB.LibraryRequires.request(this.props.data.thumbnailUrl, {encoding: null}, (error, response, body) => {
|
||||
this.props.data.thumbnailChecked = true;
|
||||
if (response && response.headers["content-type"] && response.headers["content-type"] == "image/gif") {
|
||||
const throwAwayImg = new Image(), instance = this;
|
||||
throwAwayImg.onload = function() {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.getContext("2d").drawImage(throwAwayImg, 0, 0, canvas.width = this.width, canvas.height = this.height);
|
||||
try {
|
||||
const oldUrl = instance.props.data.thumbnailUrl;
|
||||
instance.props.data.thumbnailUrl = canvas.toDataURL("image/png");
|
||||
instance.props.data.thumbnailGifUrl = oldUrl;
|
||||
BDFDB.ReactUtils.forceUpdate(instance);
|
||||
} catch(err) {
|
||||
BDFDB.ReactUtils.forceUpdate(instance);
|
||||
}
|
||||
};
|
||||
throwAwayImg.onerror = function() {
|
||||
BDFDB.ReactUtils.forceUpdate(instance);
|
||||
};
|
||||
throwAwayImg.src = "data:" + response.headers["content-type"] + ";base64," + (new Buffer(body).toString("base64"));
|
||||
}
|
||||
else BDFDB.ReactUtils.forceUpdate(this);
|
||||
});
|
||||
}
|
||||
return BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.discoverycard,
|
||||
children: [
|
||||
|
@ -663,7 +684,7 @@ module.exports = (_ => {
|
|||
BDFDB.ReactUtils.createElement("div", {
|
||||
className: BDFDB.disCN.discoverycardcoverwrapper,
|
||||
children: [
|
||||
this.props.data.thumbnailUrl && BDFDB.ReactUtils.createElement("img", {
|
||||
this.props.data.thumbnailUrl && this.props.data.thumbnailChecked && BDFDB.ReactUtils.createElement("img", {
|
||||
className: BDFDB.disCN.discoverycardcover,
|
||||
src: this.props.data.thumbnailUrl,
|
||||
onMouseEnter: this.props.data.thumbnailGifUrl && (e => e.target.src = this.props.data.thumbnailGifUrl),
|
||||
|
@ -1294,21 +1315,6 @@ module.exports = (_ => {
|
|||
checksRunning++;
|
||||
theme.rawSourceUrl = theme.latestSourceUrl.replace("https://github.com/", "https://raw.githubusercontent.com/").replace(/\/blob\/(.{32,})/i, "/$1");
|
||||
theme.thumbnailUrl = theme.thumbnailUrl ? (theme.thumbnailUrl.startsWith("https://") ? theme.thumbnailUrl : `https://betterdiscord.app${theme.thumbnailUrl}`) : "";
|
||||
if (theme.thumbnailUrl) BDFDB.LibraryRequires.request({url: theme.thumbnailUrl, encoding: null}, (error, response, body) => {
|
||||
if (response && response.headers["content-type"] && response.headers["content-type"] == "image/gif") {
|
||||
let throwAwayImg = new Image();
|
||||
throwAwayImg.onload = function() {
|
||||
const canvas = document.createElement("canvas");
|
||||
canvas.getContext("2d").drawImage(throwAwayImg, 0, 0, canvas.width = this.width, canvas.height = this.height);
|
||||
try {
|
||||
const oldUrl = theme.thumbnailUrl;
|
||||
theme.thumbnailUrl = canvas.toDataURL("image/png");
|
||||
theme.thumbnailGifUrl = oldUrl;
|
||||
} catch(err) {}
|
||||
};
|
||||
throwAwayImg.src = "data:" + response.headers["content-type"] + ";base64," + (new Buffer(body).toString("base64"));
|
||||
}
|
||||
});
|
||||
BDFDB.LibraryRequires.request(theme.rawSourceUrl, (error, response, body) => {
|
||||
if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) {
|
||||
theme.name = BDFDB.LibraryModules.StringUtils.upperCaseFirstChar((/@name\s+([^\s^\t^\r^\n]+)|\/\/\**META.*["']name["']\s*:\s*["'](.+?)["']/i.exec(body) || []).filter(n => n)[1] || theme.name || "");
|
||||
|
|
Loading…
Reference in New Issue