-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(app): fix potential autoplay from webpage and embed media
- Loading branch information
Showing
4 changed files
with
26 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import type { WebviewTag } from "electron"; | ||
|
||
export async function evalInWebview(code: string, webview: WebviewTag) { | ||
code = code.replaceAll(/\bexport\b/g, ""); | ||
return await webview.executeJavaScript(`(async function(){${code}})()`); | ||
// set userGesture to true to allow full control | ||
// like triggering play/pause without user interaction | ||
return await webview.executeJavaScript(`(async function(){${code}})()`, true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters