-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdevtools-frontend.html
85 lines (80 loc) · 2.71 KB
/
devtools-frontend.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>DevTools</title>
<style>
body {
filter: blur(2px) grayscale(1);
transition: filter 1s linear;
}
body.ready {
filter: none;
}
</style>
<meta
http-equiv="Content-Security-Policy"
content="object-src 'none'; script-src 'self' 'unsafe-eval' 'unsafe-inline' https://chrome-devtools-frontend.appspot.com"
/>
<meta name="referrer" content="no-referrer" />
<script
type="module"
src="../devtools-frontend/entrypoints/devtools_app/devtools_app.js"
></script>
<script>
async function getTimelinePanel() {
const module = await import(
'../devtools-frontend/panels/timeline/TimelinePanel.js'
);
return module.TimelinePanel.instance();
}
function registerLoadCompleted() {
// Use the legacy "loadCompleted" callback to hide navigation
window.InspectorFrontendHost.loadCompleted = () => {
const main = document.querySelector('.main-tabbed-pane');
if (main && main.shadowRoot) {
const header = main.shadowRoot.querySelector('.tabbed-pane-header');
if (header) {
header.style.display = 'none';
}
}
};
}
async function load(payload) {
try {
console.log(`Attempting to load`, payload);
document.body.classList.add('ready');
const TimelinePanel = await getTimelinePanel();
const { events } = payload;
TimelinePanel.loadFromEvents(events);
} catch (error) {
console.log(`Tried to load, but failed. Deferring.`);
setTimeout(() => load(payload), 250);
}
}
async function setDarkMode(isDarkMode) {
console.log(`Setting dark mode to`, isDarkMode);
const html = document.documentElement;
if (isDarkMode) {
html.classList.add('-theme-with-dark-background');
} else {
html.classList.remove('-theme-with-dark-background');
}
}
// Since we're on a file:// protocol, we can't just
// call window.myMethod() from Sleuth and have to send
// it as a cross-origin message. This will help.
window.addEventListener('message', async ({ data }) => {
if (!data) return;
const { instruction, payload } = data;
if (instruction === 'load') {
return await load(payload);
} else if (instruction === 'dark-mode') {
setDarkMode(!!payload);
}
});
document.addEventListener('DOMContentLoaded', registerLoadCompleted);
</script>
</head>
<body class="undocked" id="-blink-dev-tools"></body>
</html>