Can I somehow change the JavaScript language such that the word end
equates to the }
symbol and begin
equates to {
?
No, you can't. The best you could do is have a script that modifies another script with an invalid type
and changes it to a valid type
so you'd get the effect, kind of.
<script type="text/x-algolscript">
function hello() begin
alert("Hello, world!");
end
hello();
</script>
<script type="text/javascript">
Array.prototype.forEach.call(document.getElementsByTagName('script'), function(script) {
if(script.type === 'text/x-algolscript') {
var oldParent = script.parentNode;
var oldNext = script.nextSibling;
oldParent.removeChild(script);
script.textContent = script.textContent.replace(/\bbegin\b/g, '{').replace(/\bend\b/g, '}');
script.type = 'text/javascript';
oldParent.insertBefore(script, oldNext);
}
});
</script>
This is context-insensitive, however, and will gladly change your strings and such.
Bonus: Minified and more browser-compatible version:
!function(s,i,t,e,l,p,o,n){for(l=s.length;i<l;i++)((e=s[i]).type==='text/x-algolscript')&&t.push(e);for(i=0;i<t.length;i++)o=(e=t[i]).parentNode,n=e.nextSibling,o.removeChild(e),p='textContent',e[p]||(p='innerText'),e[p]=e[p].replace(/\bbegin\b/,'{').replace(/\bend\b/,'}'),e.type='text/javascript',o.insertBefore(e,n)}(document.getElementsByTagName('script'),0,[]);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With