Skip to content

Commit

Permalink
adjusted frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
imagemlt committed Feb 26, 2020
1 parent 8902c11 commit 7f1ad98
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 29 deletions.
18 changes: 13 additions & 5 deletions src/main/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,35 @@ export const startDebugging = (
setTimeout(function(){
CDP({port:nodePort},async client => {
let count=0;
let renew=false;
let interval=setInterval(async function() {
try{
let length=await client.Runtime.evaluate({
expression: `process.mainModule.require('electron').webContents.getAllWebContents().length`
})
if(length.result.value!=count){

if(renew || length.result.value!=count){
count=length.result.value;
let webcontents=await client.Runtime.evaluate({
expression: `
result=[]
contents=process.mainModule.require('electron').webContents.getAllWebContents();
for(let i=0;i<contents.length;i++){
let cw=contents[i];
result.push({"url":cw.getURL(),"webPreferences":cw.getWebPreferences()})
result.push({"id":cw.id,"url":cw.getURL(),"webPreferences":cw.getWebPreferences()})
};
JSON.stringify(result);
`
})

dispatch(updateContents(id,JSON.parse(webcontents.result.value)))
renew=false;
let webContents=JSON.parse(webcontents.result.value)
console.log(webContents);
for(let wc=0;wc<webContents.length;wc++){
if(webContents[wc].url==""){
renew=true;
}
}
dispatch(updateContents(id,webContents))
}
}catch(e){
console.log(e)
Expand Down
4 changes: 4 additions & 0 deletions src/renderer/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ body {
.hoverable:hover {
background-color: #eeeeee;
}

.bp3-tab-panel {
margin-top: 3px;
}
135 changes: 111 additions & 24 deletions src/renderer/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,31 +208,118 @@ export const App: React.FC = () => {
</HTMLTable>
</div>
<Divider />
<Pre
style={{
flexGrow: 1,
overflow: 'auto',
userSelect: 'text',
width:'50%',
fontFamily:
'SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace',
}}
<Tabs
defaultSelectedTabId={'Log'}
>
{session.log}
</Pre>
<Pre
style={{
flexGrow: 1,
overflow: 'auto',
userSelect: 'text',
width:'50%',
fontFamily:
'SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace',
}}
>
webContents count:{session.webcontents==undefined?0:session.webcontents.length};{"\n"}
{JSON.stringify(session.webcontents,null,2)}
</Pre>
<Tab
id={'webContents'}
key={'webContents'}
title={'webContents'}
panel={
<HTMLTable style={{
//flexGrow: 0,
//overflow: 'auto',
userSelect: 'text',
width: '50%',
fontFamily:
'SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace',

}} condensed interactive>

<thead>
<tr>
<th>URL</th>
<th>nodeIntegration</th>
<th>contextIsolation</th>
<th>sandbox</th>
<th>nativeWindowOpen</th>
<th>webPreferences</th>
</tr>
</thead>
<tbody>
{session.webcontents == undefined ? <tr></tr> : session.webcontents.map((webcontent) => (
<tr key={webcontent.id}>
<td
style={{
maxWidth: 200,
wordWrap: 'break-word',
}}
>
{webcontent.url}
</td>
<td
style={{
maxWidth: 100,
wordWrap: 'break-word',
color: webcontent.webPreferences.nodeIntegration == true ? 'red' : 'black',
}}
>
{webcontent.webPreferences.nodeIntegration ? "true" : "false"}
</td>
<td
style={{
maxWidth: 100,
wordWrap: 'break-word',
color: webcontent.webPreferences.contextIsolation == false ? 'red' : 'black',
}}
>
{webcontent.webPreferences.contextIsolation ? "true" : "false"}
</td>
<td
style={{
maxWidth: 100,
wordWrap: 'break-word',
color: webcontent.webPreferences.sandbox == false ? 'red' : 'black',
}}
>
{webcontent.webPreferences.sandbox ? "true" : "false"}
</td>
<td
style={{
maxWidth: 100,
wordWrap: 'break-word',
color: webcontent.webPreferences.nativeWindowOpen == false ? 'red' : 'black',
}}
>
{webcontent.webPreferences.nativeWindowOpen ? "true" : "false"}
</td>
<td
style={{
maxWidth: 400,
wordWrap: 'break-word',
overflow: 'auto'
}}
>
{JSON.stringify(webcontent.webPreferences, null, 2)}
</td>
</tr>
))}
</tbody>
</HTMLTable>
}>
</Tab>
<Tab
id={'Log'}
key={'Log'}
title={'Log'}
style={{
marginTop:0,
}}
panel={
<Pre
style={{
flexGrow: 1,
overflow: 'auto',
userSelect: 'text',
fontFamily:
'SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace',
}}
>
{session.log}
</Pre>
}>
</Tab>
</Tabs>
</div>
}
/>
Expand Down

0 comments on commit 7f1ad98

Please sign in to comment.