webview-devtools.html 949 B

12345678910111213141516171819202122232425262728293031
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. </head>
  6. <body>
  7. <webview nodeintegration src="./a.html"></webview>
  8. <script>
  9. var wv = document.querySelector('webview')
  10. wv.addEventListener('dom-ready', () => {
  11. const webContents = wv.getWebContents()
  12. webContents.on('devtools-opened', function () {
  13. var showPanelIntevalId = setInterval(function () {
  14. if (webContents.devToolsWebContents) {
  15. webContents.devToolsWebContents.executeJavaScript('(' + (function () {
  16. var lastPanelId = UI.inspectorView._tabbedPane._tabs.peekLast().id
  17. UI.inspectorView.showPanel(lastPanelId)
  18. }).toString() + ')()')
  19. } else {
  20. clearInterval(showPanelIntevalId)
  21. }
  22. }, 100)
  23. })
  24. wv.openDevTools()
  25. })
  26. </script>
  27. </script>
  28. </body>
  29. </html>