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

ResourceLoader and runScripts can not be used together #3652

Open
fancy45daddy opened this issue Jan 2, 2024 · 0 comments
Open

ResourceLoader and runScripts can not be used together #3652

fancy45daddy opened this issue Jan 2, 2024 · 0 comments

Comments

@fancy45daddy
Copy link

Basic info:

  • Node.js version: v21.2.0
  • jsdom version: 23.0.1

Minimal reproduction case

import jsdom from 'jsdom'

const virtualConsole = new jsdom.VirtualConsole()
const userAgent = await jsdom.JSDOM.fromURL('https://www.useragents.me', {virtualConsole}).then(_ => _.window.document.evaluate('//textarea[@Class="form-control ua-textarea" and contains(text(), "Linux x86_64")]/text()', .window.document, null, 2, null).stringValue)
console.log(userAgent)
const resources = new jsdom.ResourceLoader({userAgent, strictSSL:false})
console.log(await jsdom.JSDOM.fromURL('https://www.youtube.com/@Travelkel', { resources, virtualConsole, runScripts:'dangerously'}).then(
=> _.window.ytInitialData))

show: undefined

But if I remove resources, the actual ytInitialData is show
import jsdom from 'jsdom'

const virtualConsole = new jsdom.VirtualConsole()
const userAgent = await jsdom.JSDOM.fromURL('https://www.useragents.me', {virtualConsole}).then(_ => _.window.document.evaluate('//textarea[@Class="form-control ua-textarea" and contains(text(), "Linux x86_64")]/text()', .window.document, null, 2, null).stringValue)
console.log(userAgent)
const resources = new jsdom.ResourceLoader({userAgent, strictSSL:false})
console.log(await jsdom.JSDOM.fromURL('https://www.youtube.com/@Travelkel', { virtualConsole, runScripts:'dangerously'}).then(
=> _.window.ytInitialData))

Any idea how to change the useragent and also {runScripts:'dangerously'}

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

No branches or pull requests

1 participant