TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Hide this in your coworkers' JavaScript code tomorrow

85 pointsby cfjabout 11 years ago

16 comments

madeofpalkabout 11 years ago
On a related note, I got a pleasent surprise when I opened the Developer Console on Facebook.com: they present you with a giant red warningp[1] and block any code execution in it until you explicitly &#x27;allow [your] account to be hijacked if I paste malicious Javascript&#x27;[2]<p>[1]: <a href="http://i.imgur.com/6UVaTen.png" rel="nofollow">http:&#x2F;&#x2F;i.imgur.com&#x2F;6UVaTen.png</a><p>[2]: <a href="https://www.facebook.com/selfxss" rel="nofollow">https:&#x2F;&#x2F;www.facebook.com&#x2F;selfxss</a>
评论 #7501082 未加载
评论 #7501465 未加载
dangabout 11 years ago
By the way, we&#x27;re going to penalize April Fools&#x27; jokes tomorrow so that they fall off the front page quickly. This isn&#x27;t new, but we&#x27;re going to be more systematic about it. The April 1 tech thing has become stale. If you guys see April Fools stories that we miss, flag them unless they&#x27;re really particularly good.<p>People complain about HN&#x27;s humorlessness, and they&#x27;re right to a point. The trouble is that with a culture of humor comes a flood of lame humor. HN wants to optimize for intellectual curiosity, which wants higher signal&#x2F;noise ratio. It&#x27;s not that we&#x27;re killjoys—we like jokes and laughing—it&#x27;s that the signal&#x2F;noise problem is hard.
chewxyabout 11 years ago
One of my favourite ways to punish JavaScript developers who don&#x27;t use `var` is to randomly hide a<p><pre><code> if (false) { var GLOBALVAR; } </code></pre> somewhere in the code.<p>It&#x27;s fun (in a harmless fun kinda way, but you can also use some really dirty tricks to really hamper someone&#x27;s work) to fuck up people&#x27;s code - that&#x27;s why I wrote Underhanded JavaScript. :P<p>EDIT:<p>Another fun one is to add `return`s to constructor functions.
评论 #7501529 未加载
评论 #7501422 未加载
mathiasabout 11 years ago
For more, see the evil.js project: <a href="https://github.com/kitcambridge/evil.js" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;kitcambridge&#x2F;evil.js</a><p>Also note that `string.split(&#x27;&#x27;).reverse().join(&#x27;&#x27;)` is not a very good way to reverse a string in JavaScript. See <a href="http://mathiasbynens.be/notes/javascript-unicode#reversing-strings" rel="nofollow">http:&#x2F;&#x2F;mathiasbynens.be&#x2F;notes&#x2F;javascript-unicode#reversing-s...</a>
评论 #7501409 未加载
评论 #7501190 未加载
cluxabout 11 years ago
Alternatively, put this in your code tomorrow to pre-empt all the April 1st bastards:<p><pre><code> Object.freeze(console) </code></pre> Or safe JS up entirely: <a href="https://gist.github.com/clux/3823024" rel="nofollow">https:&#x2F;&#x2F;gist.github.com&#x2F;clux&#x2F;3823024</a>
blinryabout 11 years ago
I did something similar in high school. You dropped a file named &quot;System.java&quot; into a Java project, which then intercepted all calls to System.out.println() and, for example, printed the text backwards, <i>very</i> slowly, or googled the text in Firefox:<p><a href="https://github.com/blinry/fake-java-println" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;blinry&#x2F;fake-java-println</a>
ijkabout 11 years ago
A silly prank, but it makes me wonder: has anyone implemented an antivirus&#x2F;anti-problem scanner for open source code? i.e. scan the source code on a git repository and report any suspicious code that matches known malicious patterns? Lint, but targeted at detecting likely security flaws and code injections.
评论 #7501091 未加载
评论 #7501125 未加载
tootieabout 11 years ago
Tomorrow, 8 people will commit this to our repo with zero net effect.
Trufaabout 11 years ago
This is pretty hilarious, would drive me nuts.<p>I once did a similarly annoying chrome extension just for fun: <a href="https://chrome.google.com/webstore/detail/annoying-typo-generator/mblbeacchfoblmckinmgeedilgncpfok" rel="nofollow">https:&#x2F;&#x2F;chrome.google.com&#x2F;webstore&#x2F;detail&#x2F;annoying-typo-gene...</a><p>Randomly generates typo in inputs and text boxes.<p>Side note: Mihai, since I know you will be reading this, watch out if your arrays in LRTF are upside down ;)
sz4kertoabout 11 years ago
There&#x27;s the old C prank: #define true false<p>.. but in reality, I had a serious issue with Qt once: #ifndef TRUE #define TRUE true #define FALSE false #endif<p>Now this screwed up some other library&#x27;s similar definitions...
评论 #7501239 未加载
ceedanabout 11 years ago
[&quot;-webkit-&quot;, &quot;-moz-&quot;, &quot;-ms-&quot;, &quot;-o-&quot;, &quot;&quot;].forEach(function(prefix) { document.body.style[prefix+&quot;transform&quot;] = &quot;rotate(180deg)&quot;; });
mholtabout 11 years ago
#define while if<p>(C, obviously)
ultimatedelmanabout 11 years ago
To anyone on my team reading this: DON&#x27;T YOU DARE :)
rquantzabout 11 years ago
This makes me glad I set up the workflow I did at our company. Nothing gets into the central code base without a pull request.
yukichanabout 11 years ago
Yes kill your coworker&#x27;s productivity by making her or him even more miserable when dealing with a bug. If you did this and I was your manager, at worst you&#x27;d end up on a PIP. If you want conduct a prank do something that doesn&#x27;t frustrate the work they&#x27;re paid to do.
评论 #7501372 未加载
lscott3about 11 years ago
Ha, this is pretty cool.