Skip to content

Commit

Permalink
implant: add :scope-content scraper
Browse files Browse the repository at this point in the history
  • Loading branch information
darwin committed Mar 14, 2018
1 parent 23dd00a commit 1e4a9a9
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/implant/dirac/implant/automation/scrapers.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[chromex.logging :refer-macros [log warn error info]]
[cljs.core.async :refer [put! <! chan timeout alts! close! go go-loop]]
[cljs.pprint :refer [pprint]]
[com.rpl.specter :refer [ALL select-first]]
[dirac.implant.automation.reps :refer [select-subrep select-subreps build-rep]]
[clojure.walk :refer [prewalk postwalk]]
[dirac.dom :as dom]
Expand Down Expand Up @@ -47,6 +46,26 @@
(let [{:keys [title content]} rep]
(str content (if title (str " / " title)))))

; -- scope UI ----------------------------------------------------------------------------------------------------------

(defn find-scope-section-elements []
(dom/query-selector "html /deep/ .scope-chain-sidebar-pane-section /deep/ .object-properties-section"))

(defn interesting-scope-tree-item-rep? [rep]
(let [class (str (:class rep))]
(or (re-find #"name" class)
(re-find #"value" class)
(re-find #"object-properties-section-custom-section" class))))

(defn extract-scope-info [[rep-name rep-value]]
(let [name (str (:content rep-name))
value (str (:content rep-value))
class (str (:class rep-value))
display-value (if (re-find #"object-properties-section-custom-section" class)
"<custom>"
value)]
(str name ": " display-value)))

; -- suggest box UI (code completions) --------------------------------------------------------------------------------------

(defn find-suggest-box-element []
Expand Down Expand Up @@ -196,6 +215,16 @@
(map print-callstack-location)
(print-list)))

(defmethod scrape :scope-content [_ & _]
(safe->> (find-scope-section-elements)
(first)
(build-rep)
(select-subreps interesting-scope-tree-item-rep?)
(partition-all 2)
(map extract-scope-info)
(print-list)
))

(defmethod scrape :suggest-box [_ & _]
(if-let [suggest-box-el (find-suggest-box-element)]
(safe->> suggest-box-el
Expand Down

0 comments on commit 1e4a9a9

Please sign in to comment.