Skip to content

Commit

Permalink
🐛 Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cookiengineer committed Jan 24, 2025
1 parent 407ae8c commit 672bf0f
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 5 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/cv/source/DECRYPTED.cv
/cv/source/de.cv
/cv/source/en.cv
/toolchain/serve.bin

147 changes: 147 additions & 0 deletions cv/design/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@

(function(global) {

const replace = (section, data) => {

let str0 = data.indexOf('<section id="' + section + '"');
let str1 = data.indexOf('</section>', str0);

let target = global.document.querySelector('section#' + section);
if (target !== null && str0 !== -1 && str1 !== -1) {

let chunk = data.substr(str0, str1 - str0 + 10);
let element = global.document.createElement('this-is-a-dummy');

element.innerHTML = chunk;

setTimeout(() => {

let elements = Array.from(element.querySelector('section#' + section).children);
if (elements.length > 0) {

Array.from(target.children).forEach((node) => {
target.removeChild(node);
});

elements.forEach((element) => {
target.appendChild(element);
});

}

}, 0);

}

};



if (global.location.search === "?debug") {

global.addEventListener('DOMContentLoaded', () => {

const DECODER = new TextDecoder();

let xhr = new XMLHttpRequest();

xhr.open('GET', '/cv/source/DECRYPTED.cv');
xhr.responseType = 'arraybuffer';

xhr.onerror = () => {
console.error('Decrypted CV not found.');
};

xhr.onload = async () => {

let decrypted = await DECODER.decode(xhr.response);
if (decrypted.length > 0) {

if (
decrypted.includes('<section id="profile">')
|| decrypted.includes('<section id="open-source">')
|| decrypted.includes('<section id="teaching">')
) {

console.error('Decrypted CV found.');

replace('profile', decrypted);
replace('open-source', decrypted);
replace('teaching', decrypted);

console.error('Done. H4v3 fun :)');

setTimeout(() => {

let wrapper = global.document.querySelector('#crypto');
if (wrapper !== null) {
wrapper.parentNode.removeChild(wrapper);
}

}, 1000);

setTimeout(() => {

let profile = global.document.querySelector('#profile');
if (profile !== null) {

let avatar = profile.querySelector('#avatar');

avatar.addEventListener('click', () => {

[
profile.querySelector('img'),
profile.querySelector('figcaption b'),
profile.querySelector('aside a[href^="mailto:"]')
].forEach((element) => {

if (element.getAttribute('data-src') !== null) {

let tmp = element.src;

element.setAttribute('src', element.getAttribute('data-src'));
element.setAttribute('data-src', tmp);

}

if (element.getAttribute('data-html') !== null) {

let tmp = element.innerHTML;

element.innerHTML = element.getAttribute('data-html');
element.setAttribute('data-html', tmp);

}

if (element.getAttribute('data-href') !== null) {

let tmp = element.href;

element.href = element.getAttribute('data-href');
element.setAttribute('data-href', tmp);

}

});

});

}

}, 1000);

}

}

};

xhr.send();

});

}

})(typeof window !== 'undefined' ? window : this);


1 change: 1 addition & 0 deletions cv/design/profile.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ section#profile figure#avatar img {
border-radius: 72px;
border: 8px solid #252530;
vertical-align: middle;
cursor: pointer;
user-select: none;
-moz-user-select: none;
-ms-user-select: none;
Expand Down
1 change: 1 addition & 0 deletions cv/secret.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<!-- CV Design -->
<link rel="stylesheet" href="/cv/design/index.css">
<script src="/cv/design/index.js" defer></script>

<!-- CV Functionality -->
<link rel="stylesheet" href="/cv/design/crypto/index.css">
Expand Down
Binary file not shown.
6 changes: 3 additions & 3 deletions toolchain/cmds/cv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func showHelp() {

console.Group("Examples")
console.Log("")
console.Log("# Write decrypted CV to /tmp/output.cv")
console.Log("# Write decrypted CV to ../cv/source/DECRYPTED.cv")
console.Log("cv decrypt \"password\";")
console.Log("")
console.Log("# Write encrypted CV to ../cv/source/<derived password>.cv")
Expand Down Expand Up @@ -61,7 +61,7 @@ func main() {

if action == "encrypt" {

result := actions.EncryptCV(cwd + "/cv/source", password, "/tmp/output.cv")
result := actions.EncryptCV(cwd + "/cv/source", password, cwd + "/cv/source/DECRYPTED.cv")

if result == true {
os.Exit(0)
Expand All @@ -71,7 +71,7 @@ func main() {

} else if action == "decrypt" {

result := actions.DecryptCV(cwd + "/cv/source", password, "/tmp/output.cv")
result := actions.DecryptCV(cwd + "/cv/source", password, cwd + "/cv/source/DECRYPTED.cv")

if result == true {
os.Exit(0)
Expand Down

0 comments on commit 672bf0f

Please sign in to comment.