Function: js--get-tabs

js--get-tabs is a byte-compiled function defined in js.el.gz.

Signature

(js--get-tabs)

Documentation

Enumerate all JavaScript contexts available.

Each context is a list:
   (TITLE URL BROWSER TAB TABBROWSER) for content documents
   (TITLE URL WINDOW) for windows

All tabs of a given window are grouped together. The most recent window is first. Within each window, the tabs are returned left-to-right.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
(defun js--get-tabs ()
  "Enumerate all JavaScript contexts available.
Each context is a list:
   (TITLE URL BROWSER TAB TABBROWSER) for content documents
   (TITLE URL WINDOW) for windows

All tabs of a given window are grouped together.  The most recent
window is first.  Within each window, the tabs are returned
left-to-right."
  (with-js
   (let (windows)

     (cl-loop with window-mediator = (js! ("Components" "classes"
                                           "@mozilla.org/appshell/window-mediator;1"
                                           "getService")
                                          (js< "Components" "interfaces"
                                               "nsIWindowMediator"))
              with enumerator = (js! (window-mediator "getEnumerator") nil)

              while (js? (js! (enumerator "hasMoreElements")))
              for window = (js! (enumerator "getNext"))
              for window-info = (js-list window
                                         (js< window "document" "title")
                                         (js! (window "location" "toString"))
                                         (js< window "closed")
                                         (js< window "windowState"))

              unless (or (js? (cl-fourth window-info))
                         (eq (cl-fifth window-info) 2))
              do (push window-info windows))

     (cl-loop for (window title location) in windows
              collect (list title location window)

              for gbrowser = (js< window "gBrowser")
              if (js-handle? gbrowser)
              nconc (cl-loop
                     for x below (js< gbrowser "browsers" "length")
                     collect (js-list (js< gbrowser
                                           "browsers"
                                           x
                                           "contentDocument"
                                           "title")

                                      (js! (gbrowser
                                            "browsers"
                                            x
                                            "contentWindow"
                                            "location"
                                            "toString"))
                                      (js< gbrowser
                                           "browsers"
                                           x)

                                      (js! (gbrowser
                                            "tabContainer"
                                            "childNodes"
                                            "item")
                                           x)

                                      gbrowser))))))