Update PersonalPins.plugin.js

This commit is contained in:
Mirco Wittrien 2019-02-03 19:02:15 +01:00
parent 16d1222afc
commit 39d7b2d3da
1 changed files with 24 additions and 18 deletions

View File

@ -5,11 +5,15 @@ class PersonalPins {
getDescription () {return "Similar to normal pins. Lets you save messages as notes for yourself.";} getDescription () {return "Similar to normal pins. Lets you save messages as notes for yourself.";}
getVersion () {return "1.7.4";} getVersion () {return "1.7.5";}
getAuthor () {return "DevilBro";} getAuthor () {return "DevilBro";}
initConstructor () { initConstructor () {
this.changelog = {
"improved":[["Copy Button","Pressing the copy button in a note that contains files will now add the filelinks to the copied text"]]
};
this.labels = {}; this.labels = {};
this.patchModules = { this.patchModules = {
@ -453,26 +457,27 @@ class PersonalPins {
}); });
message.querySelector(BDFDB.dotCN.messagespopoutjumpbutton + ".copy").addEventListener("click", e => { message.querySelector(BDFDB.dotCN.messagespopoutjumpbutton + ".copy").addEventListener("click", e => {
let clipboard = require("electron").clipboard; let clipboard = require("electron").clipboard;
if (noteData.content) clipboard.write({text: noteData.content}); if (noteData.content) {
let text = noteData.content;
for (let file of message.querySelectorAll(BDFDB.dotCN.filenamelink)) text += ("\n" + file.href);
clipboard.write({text});
}
else { else {
let image = message.querySelector(BDFDB.dotCNS.imagewrapper + "img"); let image = message.querySelector(BDFDB.dotCNS.imagewrapper + "img");
if (image) { if (image) require("request")({url: image.src, encoding: null}, (error, response, buffer) => {
// stolen from Image2Clipboard if (buffer) {
require("request")({url: image.src, encoding: null}, (error, response, buffer) => { let platform = require("process").platform;
if (buffer) { if (platform === "win32" || platform === "darwin") {
let platform = require("process").platform; clipboard.write({image: require("electron").nativeImage.createFromBuffer(buffer)});
if (platform === "win32" || platform === "darwin") {
clipboard.write({image: require("electron").nativeImage.createFromBuffer(buffer)});
}
else {
let file = require("path").join(require("process").env["HOME"], "personalpinstemp.png");
require("fs").writeFileSync(file, buffer, {encoding: null});
clipboard.write({image: file});
require("fs").unlinkSync(file);
}
} }
}); else {
} let file = require("path").join(require("process").env["HOME"], "personalpinstemp.png");
require("fs").writeFileSync(file, buffer, {encoding: null});
clipboard.write({image: file});
require("fs").unlinkSync(file);
}
}
});
} }
}); });
} }
@ -501,6 +506,7 @@ class PersonalPins {
pins[guild_id] = pins[guild_id] || {} pins[guild_id] = pins[guild_id] || {}
pins[guild_id][channel.id] = pins[guild_id][channel.id] || {} pins[guild_id][channel.id] = pins[guild_id][channel.id] || {}
if (!pins[guild_id][channel.id][message.id + "_" + pos]) { if (!pins[guild_id][channel.id][message.id + "_" + pos]) {
for (let spoiler of messagediv.querySelectorAll(BDFDB.dotCN.spoilerhidden)) spoiler.click();
let channelname = channel.name; let channelname = channel.name;
if (!channelname && channel.recipients.length > 0) { if (!channelname && channel.recipients.length > 0) {
for (let dmuser_id of channel.recipients) { for (let dmuser_id of channel.recipients) {