mirror of
https://github.com/velocitatem/garlic.git
synced 2026-05-31 08:43:36 +00:00
Fixed bugs works for all now
This commit is contained in:
@@ -12,13 +12,14 @@ function encodeTextNodes(node) {
|
|||||||
node.nodeValue = Buffer.from(node.nodeValue).toString('base64')
|
node.nodeValue = Buffer.from(node.nodeValue).toString('base64')
|
||||||
} else {
|
} else {
|
||||||
for (let i = 0; i < node.childNodes.length; i++) {
|
for (let i = 0; i < node.childNodes.length; i++) {
|
||||||
let val = node.childNodes[i].nodeValue
|
// if its text, we encode it, otherwise we keep going
|
||||||
val = val ? val.trim() : val
|
console.log(node.childNodes[i].nodeType, node.childNodes[i].nodeName)
|
||||||
if (node.childNodes[i].nodeType === 3 && val) {
|
if (node.childNodes[i].nodeType === 3) {
|
||||||
node.childNodes[i].nodeValue = Buffer.from(val).toString('base64')
|
node.childNodes[i].nodeValue = Buffer.from(node.childNodes[i].nodeValue).toString('base64')
|
||||||
} else {
|
} else {
|
||||||
encodeTextNodes(node.childNodes[i])
|
encodeTextNodes(node.childNodes[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,34 @@
|
|||||||
---
|
---
|
||||||
---
|
---
|
||||||
<div id="root">
|
<script is:global>
|
||||||
<slot />
|
function decodeBase64(root) {
|
||||||
</div>
|
for (let i = 0; i < root.childNodes.length; i++) {
|
||||||
|
const child = root.childNodes[i];
|
||||||
|
if (child.childNodes.length === 1 && child.childNodes[0].nodeType === 3) {
|
||||||
|
try {
|
||||||
|
const decoded = atob(child.childNodes[0].nodeValue).split("_yummy_")[0]
|
||||||
|
child.innerHTML = decoded;
|
||||||
|
console.log(child);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (child.nodeType === 3) {
|
||||||
|
try {
|
||||||
|
const decoded = atob(child.nodeValue).split("_yummy_")[0]
|
||||||
|
child.nodeValue = decoded;
|
||||||
|
console.log(child);
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
decodeBase64(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
|
||||||
|
decodeBase64(document.body);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
Reference in New Issue
Block a user