Update ForceImagePreviews.plugin.js

This commit is contained in:
Mirco Wittrien 2020-03-17 08:58:51 +01:00
parent ace88b5d40
commit 44ea3df218
1 changed files with 9 additions and 3 deletions

View File

@ -4,7 +4,7 @@ var ForceImagePreviews = (_ => {
return class ForceImagePreviews {
getName () {return "ForceImagePreviews";}
getVersion () {return "1.1.7";}
getVersion () {return "1.1.8";}
getAuthor () {return "DevilBro";}
@ -12,7 +12,7 @@ var ForceImagePreviews = (_ => {
constructor () {
this.changelog = {
"fixed":[["Imgur","No longer double emebds imgur images"]]
"fixed":[["Imgur","No longer double emebds imgur images"], ["Youtube","No longer double embeds some special youtube links like 'youtu.be'"]]
};
this.patchedModules = {
@ -142,7 +142,13 @@ var ForceImagePreviews = (_ => {
}
isEmbedded (embeds, link) {
for (let embed of embeds) if (embed.url == link || embed.image && embed.image.url == link) return true;
if (link.indexOf("youtube.") > -1 || link.indexOf("youtu.be") > -1) {
let videoId = link.split("watch?v=")[1] || link.split("?")[0].split("/").pop();
if (videoId) for (let embed of embeds) if (embed.url == link || embed.video && embed.url.indexOf(videoId) > -1) return true;
}
else {
for (let embed of embeds) if (embed.url == link || embed.image && embed.image.url == link) return true;
}
return false;
}
}