Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Added Memory usage monitor #2612

Merged
merged 4 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Memory usage monitor/icons/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Memory usage monitor/icons/icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Memory usage monitor/icons/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions Memory usage monitor/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Memory Usage Monitor</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Memory Usage Monitor</h1>
<div class="memory-info">
<div class="info-item">
<span class="label">Total Memory:</span>
<span class="value" id="total-memory">Loading...</span>
</div>
<div class="info-item">
<span class="label">Available Memory:</span>
<span class="value" id="available-memory">Loading...</span>
</div>
<div class="info-item">
<span class="label">Used Memory:</span>
<span class="value" id="used-memory">Loading...</span>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html>
18 changes: 18 additions & 0 deletions Memory usage monitor/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"manifest_version": 3,
"name": "Memory Usage Monitor",
"version": "1.0",
"description": "Monitor memory usage of your system",
"action": {
"default_popup": "index.html",
"default_icon": {
"16": "icons/icon16.png",
"48": "icons/icon48.png",
"128": "icons/icon128.png"
}
},
"permissions": [
"system.memory"
]
}

22 changes: 22 additions & 0 deletions Memory usage monitor/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
document.addEventListener('DOMContentLoaded', () => {
const totalMemoryElement = document.getElementById('total-memory');
const availableMemoryElement = document.getElementById('available-memory');
const usedMemoryElement = document.getElementById('used-memory');

if (chrome.system && chrome.system.memory) {
chrome.system.memory.getInfo((info) => {
const totalMemory = (info.capacity / (1024 * 1024 * 1024)).toFixed(2); // Convert to GB
const availableMemory = (info.availableCapacity / (1024 * 1024 * 1024)).toFixed(2); // Convert to GB
const usedMemory = (totalMemory - availableMemory).toFixed(2);

totalMemoryElement.textContent = `${totalMemory} GB`;
availableMemoryElement.textContent = `${availableMemory} GB`;
usedMemoryElement.textContent = `${usedMemory} GB`;
});
} else {
totalMemoryElement.textContent = 'Not supported';
availableMemoryElement.textContent = 'Not supported';
usedMemoryElement.textContent = 'Not supported';
}
});

45 changes: 45 additions & 0 deletions Memory usage monitor/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}

.container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
text-align: center;
}

h1 {
margin-bottom: 20px;
font-size: 24px;
color: #333;
}

.memory-info {
display: flex;
flex-direction: column;
align-items: center;
}

.info-item {
margin-bottom: 10px;
font-size: 18px;
}

.label {
font-weight: bold;
}

.value {
margin-left: 10px;
color: #555;
}