-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs.go
24 lines (17 loc) · 942 Bytes
/
js.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package browser
import (
_ "embed"
"github.com/ysmood/gson"
)
// npx extract-stealth-evasions
//go:embed stealth.min.js
var stealth string
var jsWaitDOMContentLoad = `()=>{const n=this===window;return new Promise((e,t)=>{if(n){if("complete"===document.readyState)return e();window.addEventListener("DOMContentLoaded",e)}else void 0===this.complete||this.complete?e():(this.addEventListener("DOMContentLoaded",e),this.addEventListener("error",t))})}`
var jsWaitLoad = `()=>{const n=this===window;return new Promise((e,t)=>{if(n){if("complete"===document.readyState)return e();window.addEventListener("load",e)}else void 0===this.complete||this.complete?e():(this.addEventListener("load",e),this.addEventListener("error",t))})}`
func (page *Page) EvalJS(js string, params ...interface{}) (gson.JSON, error) {
resp, err := page.Timeout().page.Eval(js, params...)
if err != nil {
return gson.JSON{}, err
}
return resp.Value, nil
}