forked from theosanderson/firehose
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp.html
More file actions
165 lines (147 loc) · 5.18 KB
/
temp.html
File metadata and controls
165 lines (147 loc) · 5.18 KB
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Browser Memory Information</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
max-width: 800px;
margin: 2rem auto;
padding: 0 1rem;
background-color: #f5f5f5;
}
.container {
background-color: white;
padding: 2rem;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
h1 {
color: #2d3748;
margin-bottom: 1.5rem;
}
.memory-grid {
display: grid;
gap: 1rem;
}
.memory-item {
padding: 1rem;
background-color: #f8fafc;
border-radius: 6px;
border: 1px solid #e2e8f0;
}
.memory-item h2 {
margin: 0 0 0.5rem 0;
font-size: 1.1rem;
color: #4a5568;
}
.value {
font-size: 1.2rem;
font-weight: bold;
color: #2d3748;
}
.not-available {
color: #a0aec0;
font-style: italic;
}
.update-button {
margin-top: 1rem;
padding: 0.5rem 1rem;
background-color: #4a90e2;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.2s;
}
.update-button:hover {
background-color: #357abd;
}
.last-updated {
margin-top: 1rem;
color: #718096;
font-size: 0.9rem;
}
</style>
</head>
<body>
<div class="container">
<h1>Browser Memory Information</h1>
<div class="memory-grid" id="memoryInfo">
<div class="memory-item">
<h2>Device Memory</h2>
<div class="value" id="deviceMemory">Checking...</div>
</div>
<div class="memory-item">
<h2>Total JS Heap Size</h2>
<div class="value" id="totalJSHeapSize">Checking...</div>
</div>
<div class="memory-item">
<h2>Used JS Heap Size</h2>
<div class="value" id="usedJSHeapSize">Checking...</div>
</div>
<div class="memory-item">
<h2>JS Heap Size Limit</h2>
<div class="value" id="jsHeapSizeLimit">Checking...</div>
</div>
<div class="memory-item">
<h2>Available Storage</h2>
<div class="value" id="availableStorage">Checking...</div>
</div>
</div>
<button class="update-button" onclick="updateMemoryInfo()">Update Information</button>
<div class="last-updated" id="lastUpdated"></div>
</div>
<script>
async function detectBrowserMemory() {
const memoryInfo = {
deviceMemory: 'Not available',
totalJSHeapSize: 'Not available',
usedJSHeapSize: 'Not available',
jsHeapSizeLimit: 'Not available',
availableStorage: 'Not available'
};
// Check device memory
if ('deviceMemory' in navigator) {
memoryInfo.deviceMemory = `${navigator.deviceMemory} GB`;
}
// Check performance memory
if (window.performance && performance.memory) {
const { totalJSHeapSize, usedJSHeapSize, jsHeapSizeLimit } = performance.memory;
memoryInfo.totalJSHeapSize = `${Math.round(totalJSHeapSize / 1024 / 1024)} MB`;
memoryInfo.usedJSHeapSize = `${Math.round(usedJSHeapSize / 1024 / 1024)} MB`;
memoryInfo.jsHeapSizeLimit = `${Math.round(jsHeapSizeLimit / 1024 / 1024)} MB`;
}
// Check available storage
if (navigator.storage && navigator.storage.estimate) {
try {
const { quota, usage } = await navigator.storage.estimate();
if (quota) {
memoryInfo.availableStorage = `${Math.round((quota - usage) / 1024 / 1024)} MB`;
}
} catch (error) {
console.error('Error estimating storage:', error);
}
}
return memoryInfo;
}
function updateMemoryInfo() {
detectBrowserMemory().then(info => {
for (const [key, value] of Object.entries(info)) {
const element = document.getElementById(key);
if (element) {
element.textContent = value;
element.className = value === 'Not available' ? 'value not-available' : 'value';
}
}
document.getElementById('lastUpdated').textContent =
`Last updated: ${new Date().toLocaleTimeString()}`;
});
}
// Initial update
updateMemoryInfo();
</script>
</body>
</html>