                                                 :rules {}
                                                 :pacScript {}}
                                         :scope "regular"}))
-(defonce ^:export proxy-switch (atom false))
 (defonce ^:export proxy-types {:raw [:auto_detect
                                      :pac_script
                                      :direct

                                     :system]
                               :run ["pac_script"
                                     "fixed_servers"]})
(declare on-proxy-error!)

(defn set-link! [id uri]
  (set-attr! (by-id id) :href (.getURL js/chrome.runtime uri)))

(defn make-proxy-settings! [uri]
  (when-let [u (re-find #"(\w+)://([\w\.]+)(:(\d+))?(/(\w+\.\w+))?" uri)]
    (let [p {:url (first u)
             :scheme (nth u 1)


(defn on-doc-ready []
  (when-let [ready-state (.-readyState js/document)]
    (when (and (= "complete" ready-state)
             (:div proxy-ui))
      (set-link! "options_link" "resources/public/options.html")
      (set-link! "echo_link" "resources/public/echo.html")
      (restore-proxy-settings!)
      (ev/listen! (:button-run proxy-ui) :click on-proxy-run!))))

(set! (.-onreadystatechange js/document) on-doc-ready)
