Only check body if body actually exists, apply conversions to Rich Presence
This commit is contained in:
parent
afcc9a4e2d
commit
9ea5be1777
1 changed files with 12 additions and 5 deletions
|
@ -110,9 +110,12 @@ function converter(html) {
|
||||||
|
|
||||||
replacers.ALL_KEYWORDS = "{" + Object.keys(replacers).join("}{") + "} "
|
replacers.ALL_KEYWORDS = "{" + Object.keys(replacers).join("}{") + "} "
|
||||||
|
|
||||||
var bodyHTML = htmlMinifier.minify(html.substring(html.indexOf("<body>") + 6, html.lastIndexOf("</body>")))
|
if (html.includes("<body>")) {
|
||||||
|
var bodyHTML = htmlMinifier.minify(html.substring(html.indexOf("<body>") + 6, html.lastIndexOf("</body>")))
|
||||||
var parsedHTML = himalaya.parse(bodyHTML)
|
var parsedHTML = himalaya.parse(bodyHTML)
|
||||||
|
} else {
|
||||||
|
var parsedHTML = himalaya.parse(html)
|
||||||
|
}
|
||||||
|
|
||||||
function scanParsedHTML(json) {
|
function scanParsedHTML(json) {
|
||||||
for (var i = 0; i < json.length; i++) {
|
for (var i = 0; i < json.length; i++) {
|
||||||
|
@ -196,7 +199,11 @@ function converter(html) {
|
||||||
|
|
||||||
parsedHTML = himalaya.stringify(parsedHTML)
|
parsedHTML = himalaya.stringify(parsedHTML)
|
||||||
|
|
||||||
html = html.substring(0, html.indexOf("<body>")) + parsedHTML + html.substring(html.indexOf("</body>") + 7)
|
if (html.includes("<body>")) {
|
||||||
|
html = html.substring(0, html.indexOf("<body>")) + parsedHTML + html.substring(html.indexOf("</body>") + 7)
|
||||||
|
} else {
|
||||||
|
html = parsedHTML
|
||||||
|
}
|
||||||
|
|
||||||
html = html.replaceAll("{LOAD_TIME}", (Date.now() - startTime).toString() + "ms")
|
html = html.replaceAll("{LOAD_TIME}", (Date.now() - startTime).toString() + "ms")
|
||||||
|
|
||||||
|
@ -205,7 +212,7 @@ function converter(html) {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getActivities: function () {
|
getActivities: function () {
|
||||||
return htmlMinifier.minify(activityToHTML.activitiesToHTML(lanyardData, cachedImages))
|
return htmlMinifier.minify(converter(activityToHTML.activitiesToHTML(lanyardData, cachedImages)))
|
||||||
},
|
},
|
||||||
|
|
||||||
middleWare: async function (req, res, next) {
|
middleWare: async function (req, res, next) {
|
||||||
|
|
Loading…
Reference in a new issue