This commit is contained in:
Mirco Wittrien 2019-06-20 10:07:17 +02:00
parent b398b9c527
commit 21dde7fed5
4 changed files with 29 additions and 17 deletions

View File

@ -122,7 +122,7 @@ class ForceImagePreviews {
}
else if (response && response.headers["server"] && response.headers["server"].toLowerCase().indexOf("youtube") > -1 && result.indexOf("yt-user-info") > -1) {
if (!accessory.querySelector(`${BDFDB.dotCN.embedtitlelink}[href="${itemsrc}"]`)) {
result = result.replace(new RegExp("[\\r|\\n|\\t]|[\\s]{2,}", "g"), "");
result = result.replace(/[\r|\n|\t]|[\s]{2,}/g, "");
let width = 400;
let height = Math.round(width*(result.split('<meta itemprop="height" content="')[1].split('"')[0]/result.split('<meta itemprop="width" content="')[1].split('"')[0]));
let embed = BDFDB.htmlToElement(`<div class="FIP-embed ${BDFDB.disCNS.embed + BDFDB.disCN.embedwrapper}" style="max-width: 426px;"><div class="${BDFDB.disCN.embedpill}" style="background-color: rgb(255, 0, 0);"></div><div class="${BDFDB.disCN.embedinner}"><div class="${BDFDB.disCNS.embedcontent + BDFDB.disCN.flex}"><div class="${BDFDB.disCN.embedcontentinner}"><div class=""><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedproviderlink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedprovider + BDFDB.disCNS.size12 + BDFDB.disCN.weightnormal}" href="https://www.youtube.com/" rel="noreferrer noopener" target="_blank">YouTube</a></div><div class="${BDFDB.disCNS.embedauthor + BDFDB.disCNS.flex + BDFDB.disCNS.aligncenter + BDFDB.disCNS.embedmargin + BDFDB.disCN.margintop4}"><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedauthornamelink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedauthorname + BDFDB.disCNS.weightmedium + BDFDB.disCN.size14}" href="https://www.youtube.com${result.split('<div class="yt-user-info"><a href="')[1].split('"')[0]}" rel="noreferrer noopener" target="_blank">${BDFDB.encodeToHTML(result.split('<div class="yt-user-info"><a href="')[1].split('>')[1].split('<')[0])}</a></div><div class="${BDFDB.disCNS.embedmargin + BDFDB.disCN.margintop4}"><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.embedtitlelink + BDFDB.disCNS.embedlink + BDFDB.disCNS.embedtitle + BDFDB.disCNS.size14 + BDFDB.disCN.weightmedium}" href="${itemsrc}" rel="noreferrer noopener" target="_blank">${BDFDB.encodeToHTML(result.split('<meta property="og:title" content="')[1].split('"')[0])}</a></div></div></div><div class="${BDFDB.disCNS.embedvideo + BDFDB.disCNS.embedimage + BDFDB.disCNS.embedmarginlarge + BDFDB.disCN.margintop8}" style="width: ${width}px; height: ${height}px;"><div class="${BDFDB.disCNS.imagewrapper + BDFDB.disCNS.imageclickable + BDFDB.disCN.embedvideoimagecomponent}" style="width: ${width}px; height: ${height}px;"><img alt="" src="${result.split('<link itemprop="thumbnailUrl" href="')[1].split('"')[0]}" style="width: ${width}px; height: ${height}px;"></div><div class="${BDFDB.disCN.embedvideoactions}"><div class="${BDFDB.disCN.embedcentercontent}"><div class="${BDFDB.disCN.iconactionswrapper}"><div tabindex="0" class="${BDFDB.disCNS.iconwrapper + BDFDB.disCN.iconwrapperactive}" role="button"><svg name="Play" class="${BDFDB.disCNS.iconplay + BDFDB.disCN.icon}" width="16" height="16" viewBox="0 0 24 24"><polygon fill="currentColor" points="0 0 0 14 11 7" transform="translate(7 5)"></polygon></svg></div><a class="${BDFDB.disCNS.anchor + BDFDB.disCNS.anchorunderlineonhover + BDFDB.disCNS.iconwrapper + BDFDB.disCN.iconwrapperactive}" href="${itemsrc}" rel="noreferrer noopener" target="_blank"><svg name="OpenExternal" class="${BDFDB.disCNS.iconexternalmargins + BDFDB.disCN.icon}" width="16" height="16" viewBox="0 0 24 24"><path fill="currentColor" transform="translate(3.000000, 4.000000)" d="M16 0H2a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h4v-2H2V4h14v10h-4v2h4c1.1 0 2-.9 2-2V2a2 2 0 0 0-2-2zM9 6l-4 4h3v6h2v-6h3L9 6z"></path></svg></a></div></div></div></div></div></div></div>`);

View File

@ -717,7 +717,7 @@ class PluginRepo {
let bodycopy = body;
if (body.length / body.split("\n").length > 1000) {
/* code is minified -> add newlines */
bodycopy = body.replace(new RegExp("}", "g"), "}\n");
bodycopy = body.replace(/}/g, "}\n");
}
let configreg = /(module\.exports|config)\s*=\s*\{\n*\r*\t*["'`]*info["'`]*\s*:\s*/i.exec(bodycopy);
if (url != "https://raw.githubusercontent.com/mwittrien/BetterDiscordAddons/master/Plugins/PluginRepo/PluginRepo.plugin.js" && configreg) {
@ -743,7 +743,7 @@ class PluginRepo {
let separator = result[1];
result = result[0].replace(new RegExp("\\\\" + separator, "g"), separator).split(separator);
if (result.length > 2) {
result = result.slice(1, -1).join(separator).replace(new RegExp("\\\\n", "g"), "<br>").replace(new RegExp("\\\\", "g"), "");
result = result.slice(1, -1).join(separator).replace(/\\n/g, "<br>").replace(/\\/g, "");
plugin[tag] = tag != "getVersion" ? result.charAt(0).toUpperCase() + result.slice(1) : result;
}
}
@ -805,7 +805,7 @@ class PluginRepo {
if (!framedata) return;
framerunning = true;
let {body, url} = framedata;
let name = body.replace(new RegExp("\\s*\:\\s*", "g"), ":").split('"name":"');
let name = body.replace(/\s*:\s*/g, ":").split('"name":"');
if (name.length > 1) {
name = name[1].split('"')[0];
var processResult = plugin => {

View File

@ -213,7 +213,7 @@ class SendLargeMessages {
}
formatText (text) {
text = text.replace(new RegExp("\t", 'g'), " ");
text = text.replace(/\t/g, " ");
let longwords = text.match(/[\S]{1800,}/gm);
for (let i in longwords) {
let longword = longwords[i];

View File

@ -3,7 +3,7 @@
class ThemeRepo {
getName () {return "ThemeRepo";}
getVersion () {return "1.8.2";}
getVersion () {return "1.8.3";}
getAuthor () {return "DevilBro";}
@ -11,7 +11,7 @@ class ThemeRepo {
initConstructor () {
this.changelog = {
"fixed":[["Special Snowflake","Fixed the fetching of the themes for the person who just started randomizing his github repo"]]
"fixed":[["New META syntax","Fixed the fetching for the new META syntax used by BD"]]
};
this.patchModules = {
@ -841,25 +841,37 @@ class ThemeRepo {
else if (body && body.indexOf("404: Not Found") != 0 && response.statusCode == 200) {
let theme = {};
let text = body;
if (text.split("*//").length > 1 && text.split("\n").length > 1) {
for (let tag of tags) {
let result = text.replace(new RegExp("\\s*\:\\s*", "g"), ":").replace(new RegExp("\\s*\}\\s*", "g"), "}").split('"' + tag + '":"');
result = result.length > 1 ? result[1].split('",')[0].split('"}')[0] : null;
result = result && tag != "version" ? result.charAt(0).toUpperCase() + result.slice(1) : result;
theme[tag] = result;
if ((text.split("*//").length > 1 || text.indexOf("/**") == 0) && text.split("\n").length > 1) {
var hasMETAline = text.replace(/\s/g, "").indexOf("//META{");
if (hasMETAline < 20 && hasMETAline > -1) {
var searchtext = text.replace(/\s*:\s*/g, ":").replace(/\s*}\s*/g, "}");
for (let tag of tags) {
let result = searchtext.split('"' + tag + '":"');
result = result.length > 1 ? result[1].split('",')[0].split('"}')[0] : null;
result = result && tag != "version" ? result.charAt(0).toUpperCase() + result.slice(1) : result;
theme[tag] = result;
}
}
else {
var searchtext = text.replace(/[\r\t| ]*\*\s*/g, "*");
for (let tag of tags) {
let result = searchtext.split('@' + tag + ' ');
result = result.length > 1 ? result[1].split('\n')[0] : null;
result = result && tag != "version" ? result.charAt(0).toUpperCase() + result.slice(1) : result;
theme[tag] = result;
}
}
let valid = true;
for (let tag of tags) {
if (theme[tag] === null) valid = false;
}
for (let tag of tags) if (theme[tag] === null) valid = false;
if (valid) {
theme.css = text.split("\n").slice(1).join("\n").replace(new RegExp("[\\r|\\n|\\t]", "g"), "");
theme.css = hasMETAline < 20 && hasMETAline > -1 ? text.split("\n").slice(1).join("\n").replace(/[\r|\n|\t]/g, "") : text.replace(/[\r|\n|\t]/g, "");
theme.url = url;
theme.requesturl = requesturl;
this.loadedThemes[url] = theme;
var instTheme = window.bdthemes[theme.name];
if (instTheme && instTheme.author.toUpperCase() == theme.author.toUpperCase() && instTheme.version != theme.version) outdated++;
if (!this.cachedThemes.includes(url)) newentries++;
if (!(hasMETAline < 20 && hasMETAline > -1)) console.log(theme);
}
}
}