update jsonToBase64()

This commit is contained in:
Glitchii 2021-09-06 17:51:57 +01:00
parent f4f542a6c4
commit 4cee22107f

View file

@ -16,14 +16,11 @@ var params = new URL(location).searchParams,
onlyEmbed = hasParam('embed'), onlyEmbed = hasParam('embed'),
activeFields, colNum = 1, num = 0, validationError, activeFields, colNum = 1, num = 0, validationError,
jsonToBase64 = (jsonCode, withURL, redirect) => { jsonToBase64 = (jsonCode, withURL, redirect) => {
let data = jsonCode || json; data = btoa(escape((JSON.stringify(typeof jsonCode === 'object' ? jsonCode : json))));
if (typeof data === 'object')
data = JSON.stringify(data);
data = btoa(escape(data));
if (withURL) { if (withURL) {
let currentURL = new URL(location); let currentURL = new URL(location);
currentURL.searchParams.append('data', data); currentURL.searchParams.append('data', data);
redirect && (window.location = currentURL) if (redirect) window.location = currentURL;
data = currentURL.href; data = currentURL.href;
} }
return data; return data;
@ -740,8 +737,8 @@ window.onload = () => {
error(false); error(false);
twemoji.parse(msgEmbed); twemoji.parse(msgEmbed);
} else document.body.classList.add('emptyEmbed'); } else document.body.classList.add('emptyEmbed');
if (!embedCont.innerText) if (!embedCont.innerText) document.body.classList.add('emptyEmbed');
document.body.classList.add('emptyEmbed'); json = data;
} catch (e) { } catch (e) {
console.log(e); console.log(e);
error(e); error(e);