YAJSWTF (Yet another Javascript WTF)



  • Always amazes me the odd things I find in Javascript.

    Yes, I know that 80% of the crap can be explained by cluelessness, and another 19.99% can be explained by being trying to bypass add-blocking systems, but what on EARTH could have prompted this?

    http://rmd.atdmt.com/tl/DocumentDotWrite.js  - Entire contents.
    function DocumentDotWrite(s){document.write(s);}
    


  • How the hell are you planning on calling methods when your . key breaks??



  • Copy and paste from Character Map. 



  • It's... it's... it's... the world's first C wrapper to a Javascript method, only it's written in Javascript!!!



  • Maybe they wanted to keep their main script free from these slow object-oriented function calls (to cite my CS prof)



  • @r3jjs said:

    Yes, I know that 80% of the crap can be explained by ClueLessNess

    I think you missed some necessary capitalization in that word ... fixed it for you.     



  • My money is on some coding-by-phone situations where the genius at the keyboard heard "document dot write" and took it a little too literally.



  • As crazy it sounds, there may actually be a ... sane ... ish ... reason for this. Maybe for some reason the developer wanted to pass document.write as a callback. The problem is that the "this binding" gets lost if just write is passed and the function doesn't work with other "this" objects. So the function could be a callback wrapper. Poor man's bind(), so to say.

    Even if this were true, however, it would still be an exceptionally dumb name. 



  • I'd say that they want to get around Javascript filters that have [code]document.write[/code] in their matching rules. It's probably very basic obfuscation in order to defeat ad blockers and the like.



  • Even if there are such filters (which I don't believe, since document.write() is still used in a large number sites in non-ad contexts) how would this solve the problem? The document.write() call is still there, it's just wrapped in a function.



  • A quick web search reveals more information: Generating a Privacy Footprint on the Internet



  • I'm not talking about supressing the functionlity of [code]document.write()[/code] but about having it in a regexp. I've seen people using it to write additional Javascript code/ad HTML into the page in the hopes of obfuscating it enough to foil ad blockers/people looking at the HTML code. Obviously, such code might end up being filtered in the next version of the ad blocker.



  • @j6cubic said:

    I'd say that they want to get around Javascript filters that have <font face="Lucida Console" size="2">document.write</font> in their matching rules. It's probably very basic obfuscation in order to defeat ad blockers and the like.

    Indeed! How very clever! Heh, heh, those ad-blocking bastards will never figure that one out! Let's see them wiggle out of that one!

    Damn it, the real WTF: why do I have *view.atdmt.com/* and http://*.atdmt.com/* as separate Adblock patterns? Guess this is what happens when you add these in a hurry...



  • @djork said:

    My money is on some coding-by-phone situations where the genius at the keyboard heard "document dot write" and took it a little too literally.

     

    Ya know, that "feels" right.  Best  explanation yet. 




  • The
    documentDotWrite function is used to circumvent the restrictions put in
    place after microsoft lost the eolas ActiveX lawsuit.


    Basically, you can only embed ActiveX objects (including flash,
    quicktime, whatever) if the actual document.write call is called from
    an external js file.








  • @WWWWolf said:

    Indeed! How very clever! Heh, heh, those ad-blocking bastards will never figure that one out! Let's see them wiggle out of that one!

    I'm pretty sure you've got the wrong mode of operation there.

    "I hope this will get around the current filters.  I wonder how long it'll work?  If it works for at least an hour, I'll have made back my time investment on it."



  • Saw this thread and had to reply :-)

    I think you guys may have missed a very likely scenario. I've spent some time working in a small firm that did 'A'gile development. Yes that's with a capital 'A'. As a result of that I came across people who had that evangelical look in their eye's. You know, the one's who have read every single book ever written about how to do great development and write great code, and just have to personally tell you how you are doing *everything* wrong. ... Yep, thats a rant :-)

    Anyway, this code is exactly the sort of code these people promote. The idea is quite simple, everything has to be abstracted and protected from change. So in this case the author is worried that code "document.write(s);" exposes the calling software to internal workings and may need to change some time in the future. So they cleverly wrap it in a method so the calling code does not have to worry about the internal implementation. What a Brilliant idea! Everything should be done that way!

    Needless to say, the code I saw from these same people was pretty much useless.



  • @evrt said:

    The
    documentDotWrite function is used to circumvent the restrictions put in
    place after microsoft lost the eolas ActiveX lawsuit.


    Basically, you can only embed ActiveX objects (including flash,
    quicktime, whatever) if the actual document.write call is called from
    an external js file.
    I just wanted to quote this again since everybody seem to have ignored it and continue to speculate.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.