Download assets/js/dynamic-encoder.js from EDUrocks/EDUrocks-3.0-frontend-source-code: direct link, hf CLI and curl.
- Browser
- Download file 1.96 kB
-
https://huggingface.co/datasets/EDUrocks/EDUrocks-3.0-frontend-source-code/resolve/main/assets/js/dynamic-encoder.js
- Command line
-
hf download hf://datasets/EDUrocks/EDUrocks-3.0-frontend-source-code/assets/js/dynamic-encoder.js
-
curl -L -o dynamic-encoder.js https://huggingface.co/datasets/EDUrocks/EDUrocks-3.0-frontend-source-code/resolve/main/assets/js/dynamic-encoder.js
1.96 kB
| function encrypt(plain, cipher, text) { | |
| plain = plain + plain.toUpperCase(); | |
| cipher = cipher + cipher.toUpperCase(); | |
| var newText = ''; | |
| for(var i=0; i<text.length; i++) { | |
| var c = text.charAt(i); | |
| var index = plain.indexOf(c); | |
| if(index >= 0 && index < cipher.length) { | |
| newText += cipher.charAt(index); | |
| } else { | |
| newText += c; | |
| } | |
| } | |
| return newText; | |
| } | |
| document.addEventListener('DOMContentLoaded', function() { | |
| var plain = "abcdefghijklmnopqrstuvwxyz"; | |
| var cipher = "nopqrstuvwxyzabcdefghijklm"; | |
| function walk(node) { | |
| if (node.nodeType === 3) { // Text node | |
| var original = node.nodeValue; | |
| if (original.trim().length > 0) { | |
| // Check if parent is a script, style, or the logo | |
| var parent = node.parentElement; | |
| if (parent.tagName === 'SCRIPT' || parent.tagName === 'STYLE' || parent.closest('#site-logo')) { | |
| return; | |
| } | |
| // Encrypt text | |
| var encrypted = encrypt(plain, cipher, original); | |
| // Create a wrapper span with the ROT13 font class | |
| var span = document.createElement('span'); | |
| span.className = 'rot13-font'; | |
| span.textContent = encrypted; | |
| // Replace the text node with the span | |
| parent.replaceChild(span, node); | |
| } | |
| } else if (node.nodeType === 1 && node.nodeName !== 'SCRIPT' && node.nodeName !== 'STYLE') { | |
| // Element node, recurse | |
| // Avoid recursing into the logo | |
| if (node.id === 'site-logo') return; | |
| var children = Array.from(node.childNodes); | |
| for (var i = 0; i < children.length; i++) { | |
| walk(children[i]); | |
| } | |
| } | |
| } | |
| walk(document.body); | |
| }); |