From c032f74806da65acacb49a757ee427729c347c51 Mon Sep 17 00:00:00 2001 From: Leonardo Domingues Date: Tue, 1 Mar 2022 14:35:17 -0300 Subject: [PATCH] FindUrl --- api/chrome/cli.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/api/chrome/cli.go b/api/chrome/cli.go index c73e328..52799fd 100644 --- a/api/chrome/cli.go +++ b/api/chrome/cli.go @@ -64,16 +64,16 @@ func (c *Cli) Wait(id string, s string, to int) (string, error) { json.Unmarshal(bs, &ret) return ret, err } -func (c *Cli) Send(id string, m string, ps map[string]interface{}) (string, error) { +func (c *Cli) Send(id string, m string, ps map[string]interface{}) (interface{}, error) { // id -> ID do Websocket no qual se deseja realizar a alteração. - ret := "" + var ret interface{} in := map[string]interface{}{ "method": m, "params": ps, } - err := c.HttpCli().JsonPost("/ipc/chrome/eval/"+id, in, &ret) + err := c.HttpCli().JsonPost("/ipc/chrome/send/"+id, in, &ret) return ret, err - // ret -> + // ret -> Retorno do comando (Referência em: https://chromedevtools.github.io/devtools-protocol/) } func (c *Cli) OpenTabs() (ret []map[string]string, err error) { @@ -89,6 +89,13 @@ func (c *Cli) FindTabByUrl(url string) (ret string, err error) { // ret -> ID do WebSocket contendo a aba encontrada. } +func (c *Cli) FindUrlById(id string) (ret string, err error) { + // url -> URL ativa em uma das abas abertas. + err = c.HttpCli().JsonGet("/ipc/chrome/findurlbyid/"+id, &ret) + return ret, err + // ret -> Url da aba encontrada. +} + func (c *Cli) FindTabByTitle(title string) (ret string, err error) { // title -> Título de uma das abas abertas. err = c.HttpCli().JsonGet("/ipc/chrome/findtabbytitle/"+title, &ret)