]
})
const page = await browser.newPage()
+ await page.setBypassCSP(true)
+ await page.goto('chrome://newtab')
page.on('console', async (msg) => {
+ console.log('start test')
+ console.log(msg.text())
+ console.log('end test')
const output = msg.text().split(' ')
if (output[0] === 'cli') {
if (output[1] === 'exit') {
}
})
start = performance.now()
- await page.setContent(`
- <!DOCTYPE html>
- <html>
- <head>
- <script type="module">
- ${NanoPow}
- const hashes = ["${hashes.join('","')}"]
- for (const hash of hashes) {
- try {
- console.log(\`cli \${hash}\`)
- const work = await NanoPow.search(hash)
- console.log(\`cli \${work}\`)
- } catch (err) {
- console.error(\`cli \${err}\`)
- }
- }
- console.log('cli exit')
- </script>
- </head>
- <body></body>
- </html>
- `)
+ await page.addScriptTag({
+ type: 'module',
+ content: `
+ window.trustedTypes?.createPolicy?.('default', {
+ createHTML: string => string,
+ createScriptURL: string => string,
+ createScript: string => string,
+ })
+ ${NanoPow}
+ const hashes = ["${hashes.join('","')}"]
+ for (const hash of hashes) {
+ try {
+ console.log(\`cli \${hash}\`)
+ const work = await NanoPow.search(hash)
+ console.log(\`cli \${work}\`)
+ } catch (err) {
+ console.error(\`cli \${err}\`)
+ }
+ }
+ console.log('cli exit')
+ `
+ })
})()