Robot-Chicken Bipolar Bear (and a JavaScript Download-Video Trick For adultswim Host-Website)



  • The escaped animal is a polar bear with the ability to survive in the Arctic and Antarctic.
  • It exhibits massive mood swings like that of a manic-depressive,
  • and has equal sexual desires for both males and females.

Army Guy:

  • Dear god, are you suggesting what I think you’re suggesting?


  • That’s right.. –
  • A bi-polar, bipolar, – bi polar bear.

Army Guy:

  • That is very stupid..

Robot Chicken (by is a sketch-like comedy TV-show made with action-figures using stop-motion and a funny voice-over, usually filled with pun-games, which are the type of comedy that make me laugh the most :))

Original website is

and running the following code, will add a download button,
it just uses the video-url from the page’s internal-source code, and isn’t decrypting or breaking stuff or anything.. its publicly accessible (just don’t use it in any evil doing sort..)

(function(window,document, info){
  "use strict";

    window.setTimeout(function(){     //execute a non-blocker = info.vid_href; = info.vid_downloadfilename; =
                          .replace("##TITLE_FULL##", info.vid_title_full)
                          .replace("##VID_TYPE##", info.vid_type)
                          .replace("##VID_DURATION##", (~~info.vid_duration))

      info.placement.insertBefore(, info.placement.firstElementChild);

    }, 200);

  }(window,document, {"_":""
    ,'placement':             document.querySelector("#video-player-object-wrapper")
    ,'placement_first':       document.querySelector("#video-player-object-wrapper").firstElementChild
    ,'link':                  (function(){
                                 var a       = document.createElement('a');
                           = "_self";
                                 a.rel       = "nofollow";
                                 a.className = "download_button";
                                 a.title     = "Click To Download \"##TITLE_FULL##\" (##VID_TYPE##: ##VID_DURATION## Seconds)";
                                 return a;
    ,'style':                  (function(){
                                 var s  = document.createElement('style');
                                 s.type = "text/css";
                                 '.download_button{background-color:rgba(255,183,57,.8);border:3px solid rgba(255,183,57,.3);border-radius:10px;box-shadow:2px 2px 2px rgba(255,255,255,.3);cursor:pointer;display:block;height:30px;height:100% !important;margin:0px 0px 10px 0px;max-width:100px;outline:1px rgba(255,255,255,.3);text-align:center;transition:all .3s ease-in-out;-webkit-font-smoothing:subpixel-antialiased;}'
                               + '.download_button:hover{background-color:rgba(255,237,142,.8);border:3px solid rgba(255,237,142,.3);}'
                                 document.getElementsByTagName("body")[0].appendChild(s); //already add this to the document (parsed into stylesheet)
                                 return s; //unneeded..
    ,'vid_href':              bootstrappedData.slugged_video.segments[0].assets[0].url
    ,'vid_downloadfilename':  encodeURI((bootstrappedData.slugged_video.collection_title + " - " + bootstrappedData.slugged_video.title + " - " + bootstrappedData.slugged_video.description).replace("\n","").replace("\r","").replace(".","")) + ".flv"
    ,'vid_title_full':        (bootstrappedData.slugged_video.collection_title + " - " + bootstrappedData.slugged_video.title + " - " + bootstrappedData.slugged_video.description).replace("\n","").replace("\r","").replace(".","")
    ,'vid_duration':          bootstrappedData.slugged_video.segments[0].assets[0].duration
    ,'vid_type':              bootstrappedData.slugged_video.segments[0].assets[0].mime_type

q: what is so interesting about this code ?
a: well..

  • while the main logic is in the “big” anonymous method,
  • most of the minor work preparing the elements, or data, is done before the main-method executes,
  • kept to the minimal, the memory used is quickly disposed once its logically unneeded.
  • code uses a unique technique I’ve made and refined over the time, of not using var statements overall in the main method (pre-preparing..).
  • another concept is avoiding moving a long-list of arguments to the method, and using a data-structure such as json-like object to pass a static-data, variables, etc.. where they order is not important,
  • this way maintenance is easy adding, or removing “”arguments””- does not required “Function Signature (a.k.a Header) Change – Function looks the same.
  • 2014-11-01_183051

Leave a Reply