aboutsummaryrefslogtreecommitdiffstats
path: root/pages/popup.coffee
blob: 6d7afafcbbbc637ab2955b783342d61852cb0ff7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
onLoad = ->
  document.getElementById("optionsLink").setAttribute "href", chrome.runtime.getURL("pages/options.html")
  chrome.tabs.getSelected null, (tab) ->
    # The common use case is to disable Vimium at the domain level.
    # This regexp will match "http://www.example.com/" from "http://www.example.com/path/to/page.html".
    domain = tab.url.match(/[^\/]*\/\/[^\/]*\//) or tab.url
    document.getElementById("popupInput").value = domain + "*"

onExcludeUrl = (e) ->
  url = document.getElementById("popupInput").value
  chrome.extension.getBackgroundPage().addExcludedUrl url
  document.getElementById("excludeConfirm").setAttribute "style", "display: inline-block"

document.addEventListener "DOMContentLoaded", ->
  document.getElementById("popupButton").addEventListener "click", onExcludeUrl, false
  onLoad()