Methods: Get chrome tabs (all, by url, by title)

master
Leonardo Domingues 2021-11-29 12:02:23 -03:00
parent 571810c476
commit f3f5e80160
1 changed files with 25 additions and 3 deletions

View File

@ -3,6 +3,7 @@ package chrome
import (
"encoding/json"
"fmt"
"go.digitalcircle.com.br/open/replaycli-go/api"
)
@ -10,9 +11,15 @@ type Cli struct {
*api.ApiCli
}
//func (c *Cli) HttpCli() *httpcli.Cli {
// return c.ApiCli.HttpCli()
//}
type TabMetadata struct {
Description string `json:"description"`
DevtoolsFrontendUrl string `json:"devtoolsFrontendUrl"`
Id string `json:"id"`
Title string `json:"title"`
Type string `json:"type"`
Url string `json:"url"`
WebSocketDebuggerUrl string `json:"webSocketDebuggerUrl"`
}
func (c *Cli) Start(to int) error {
err := c.HttpCli().JsonGet(fmt.Sprintf("/ipc/chrome/start?to=%d", to), nil)
@ -57,6 +64,21 @@ func (c *Cli) Send(id string, m string, ps map[string]interface{}) (string, erro
return ret, err
}
func (c *Cli) OpenTabs() (ret interface{}, err error) {
err = c.HttpCli().JsonGet("/ipc/chrome/opentabs", &ret)
return ret, err
}
func (c *Cli) FindTabByUrl(url string) (ret interface{}, err error) {
err = c.HttpCli().JsonGet("/ipc/chrome/findtabbyurl/"+url, &ret)
return ret, err
}
func (c *Cli) FindTabByTitle(title string) (ret interface{}, err error) {
err = c.HttpCli().JsonGet("/ipc/chrome/findtabbytitle/"+title, &ret)
return ret, err
}
func NewCli() *Cli {
ret := &Cli{ApiCli: api.NewApiCli()}
return ret