Wrap injected JS in IIFE to prevent scope conflicts

This commit is contained in:
Max Goodhart
2020-07-23 19:51:46 -07:00
parent b8109735fa
commit 36fe472fdc

View File

@@ -221,6 +221,7 @@ const viewStateMachine = Machine(
} }
const wc = view.webContents const wc = view.webContents
const info = await wc.executeJavaScript(` const info = await wc.executeJavaScript(`
(function() {
const sleep = ms => new Promise((resolve) => setTimeout(resolve, ms)) const sleep = ms => new Promise((resolve) => setTimeout(resolve, ms))
async function waitForVideo() { async function waitForVideo() {
@@ -336,6 +337,7 @@ const viewStateMachine = Machine(
return info return info
} }
findVideo() findVideo()
}())
`) `)
return info return info
}, },