mirror of
https://github.com/velocitatem/garlic.git
synced 2026-05-31 08:43:36 +00:00
New
This commit is contained in:
@@ -1,31 +1,51 @@
|
|||||||
function garlic(body) {
|
|
||||||
let bodyCopy = {...body};
|
class Garlic {
|
||||||
if (body.props) {
|
|
||||||
if (body.props.children) {
|
static clove(body) {
|
||||||
// check if children is an array
|
let bodyCopy = {...body};
|
||||||
if (Array.isArray(body.props.children)) {
|
if (body.props) {
|
||||||
let newList = []
|
if (body.props.children) {
|
||||||
for (let i = 0; i < body.props.children.length; i++) {
|
// check if children is an array
|
||||||
// if child is a string, convert it to base64
|
if (Array.isArray(body.props.children)) {
|
||||||
if (typeof body.props.children[i] === 'string') {
|
let newList = []
|
||||||
newList.push(btoa(body.props.children[i]));
|
for (let i = 0; i < body.props.children.length; i++) {
|
||||||
} else {
|
// if child is a string, convert it to base64
|
||||||
// if child is not a string, apply this function to it
|
if (typeof body.props.children[i] === 'string') {
|
||||||
newList.push(garlic(body.props.children[i]));
|
newList.push(this.encode(body.props.children[i]));
|
||||||
|
} else {
|
||||||
|
// if child is not a string, apply this function to it
|
||||||
|
newList.push(this.clove(body.props.children[i]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
bodyCopy = {...bodyCopy, props: {...bodyCopy.props, children: newList}};
|
||||||
bodyCopy = {...bodyCopy, props: {...bodyCopy.props, children: newList}};
|
|
||||||
} else {
|
|
||||||
// if child is a string, convert it to base64
|
|
||||||
if (typeof body.props.children === 'string') {
|
|
||||||
bodyCopy = {...body, props: {...body.props, children: btoa(body.props.children)}};
|
|
||||||
} else {
|
} else {
|
||||||
bodyCopy = {...body, props: {...body.props, children: garlic(body.props.children)}};
|
// if child is a string, convert it to base64
|
||||||
|
if (typeof body.props.children === 'string') {
|
||||||
|
bodyCopy = {...body, props: {...body.props, children: this.encode(body.props.children)}};
|
||||||
|
} else {
|
||||||
|
bodyCopy = {...body, props: {...body.props, children: this.clove(body.props.children)}};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return bodyCopy;
|
||||||
|
}
|
||||||
|
|
||||||
|
static addSalt(salt) {
|
||||||
|
// set a static variable to the salt
|
||||||
|
this.salt = "_yummy_" + salt;
|
||||||
|
document.salt = salt;
|
||||||
|
}
|
||||||
|
|
||||||
|
static encode(string) {
|
||||||
|
return btoa(string+this.salt);
|
||||||
}
|
}
|
||||||
return bodyCopy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default garlic;
|
export default Garlic;
|
||||||
|
/*
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
</script>
|
||||||
|
*/
|
||||||
|
|||||||
16
src/script.js
Normal file
16
src/script.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
function decodeBase64(root) {
|
||||||
|
for (let i = 0; i < root.childNodes.length; i++) {
|
||||||
|
const child = root.childNodes[i];
|
||||||
|
if (child.childNodes.length === 1 && child.childNodes[0].nodeType === 3) {
|
||||||
|
const decoded = atob(child.childNodes[0].nodeValue).split("_yummy_")[0]
|
||||||
|
child.innerHTML = decoded;
|
||||||
|
console.log(child);
|
||||||
|
} else {
|
||||||
|
decodeBase64(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// when document is ready, decode the base64
|
||||||
|
document.addEventListener("DOMContentLoaded", function(event) {
|
||||||
|
decodeBase64(document.getElementById("root"));
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user