                 document.body.dataset.youtubeCommentScraper = "ready"
 
           .then ->
-            console.log "ge"
             # Check data-youtube-comment-scraper is ready, which means all pages
             # are loaded and all collapsed comments are expanded.
             # If not, wait more 1000 msec.

  else
    0

phantom_instances = []
###
List of PhantomJS instances.

Basically one instance will be reused. But when get_or_create_phantom method
called many times at the same time, multiple instances could be created.
To exit all instances safe, this list holds them.
###

get_or_create_phantom = ->
  ###
  Get an instance of PhantomJS.

  If there are no instances, this function creates it.
  ###
  if phantom_instances.length isnt 0
    new Promise (resolve) ->
      resolve phantom_instances[0]
  else
    phantom.create().then (instance) ->
      phantom_instances.push instance
      return instance


delete_phantom = ->
  ###
  Delete PhantomJS instances.

  It is safe to call this method many times.
  ###
  console.log phantom_instances.length
  while phantom_instances.length isnt 0
    phantom_instances.pop().exit()
  return null


# Register delete_phantom method so that it will be called when

                  reject reason

          .then (status) ->
            page.evaluate ->
              load_hidden_pages = (delay, callback) ->
                # Load hidden pages.
                #
