 linkColorAttrName = 'data-smart-underline-link-color'
 linkSmallAttrName = 'data-smart-underline-link-small'
 linkLargeAttrName = 'data-smart-underline-link-large'
-linkContainerIdAttrName = 'data-smart-underline-container-id'
+containerIdAttrName = 'data-smart-underline-container-id'
 
 performanceTimes = []
 time = -> + new Date


styleNode = document.createElement 'style'

init = (options) ->
  startTime = time()

  links = document.querySelectorAll "#{ if options.location then options.location + ' ' else '' }a"
  return unless links.length

  linkContainers = {}
  for link in links
    style = getComputedStyle link
    fontSize = parseFloat style.fontSize

        if fontSize >= 20
          link.setAttribute linkLargeAttrName, ''

        id = container.getAttribute containerIdAttrName

        if id
          containers[id].links.push link
        else
          id = uniqueLinkContainerID()
          container.setAttribute containerIdAttrName, id
          containers[id] =
            id: id
            container: container
            links: [link]

  styles = ''

  containersWithPrecedence = sortContainersForCSSPrecendence containers

  for container in containersWithPrecedence
    linkColors = {}
    linkColors[getLinkColor link] = true for link in container.links

    backgroundColor = getBackgroundColor container.container

    for color of linkColors
      linkSelector = """[#{ containerIdAttrName }="#{ container.id }"] a[#{ linkColorAttrName }="#{ color }"]"""
      linkSmallSelector = """#{ linkSelector }[#{ linkSmallAttrName }]"""
      linkLargeSelector = """#{ linkSelector }[#{ linkLargeAttrName }]"""

