Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

page.Call('Page.addScriptToEvaluateOnNewDocument',param) is not working #2

Closed
simpleMemory opened this issue Mar 10, 2020 · 3 comments
Assignees
Labels
question Questions related to rod

Comments

@simpleMemory
Copy link

I want call addScriptToEvaluateOnNewDocument method when i open a new page,But it not working,
`out := page.Call("Page.addScriptToEvaluateOnNewDocument", cdp.Object{

"source" :
"window.navigator.chrome = window.chrome = {...window.chrome, runtime: {},};",
})`

how can i do it like puppeteer

`
const page = await browser.newPage()

await page.evaluateOnNewDocument(
"window.navigator.chrome = window.chrome = {...window.chrome, runtime: {},};"
);
`

@simpleMemory simpleMemory changed the title page.Call('Page.addScriptToEvaluateOnNewDocument',param) is not work page.Call('Page.addScriptToEvaluateOnNewDocument',param) is not working Mar 10, 2020
@ysmood ysmood self-assigned this Mar 10, 2020
@ysmood ysmood added bug When you are sure about it's a bug question Questions related to rod and removed bug When you are sure about it's a bug labels Mar 10, 2020
@ysmood
Copy link
Member

ysmood commented Mar 10, 2020

@simpleMemory to use Page.addScriptToEvaluateOnNewDocument

You have to call Page.enable first, there's no mention about it on chrome api doc site.
Apparently they are lacking of doc about it 😂

So this should work:

page.Call("Page.enable", nil)
page.Call("Page.addScriptToEvaluateOnNewDocument", cdp.Object{
    "source" : "window.navigator.chrome = window.chrome = {...window.chrome, runtime: {},};",
})

@ysmood ysmood closed this as completed Mar 10, 2020
@ysmood
Copy link
Member

ysmood commented Mar 10, 2020

@simpleMemory after consideration, I think it's better to make it enabled by default, check the new version 95a1b16

v0.22.1

@simpleMemory
Copy link
Author

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions related to rod
Projects
None yet
Development

No branches or pull requests

2 participants