├── 128.png ├── LICENSE ├── README.md ├── background.js ├── icon.png └── manifest.json /128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pd4d10/memory-monitor/d6334cd576e87ebb5747030552784b2bf18448ca/128.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 pd4d10 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Memory Monitor 2 | 3 | A Chrome extension. Add an icon to extension bar to monitor memory usage. 4 | 5 | Install it from Chrome Web Store: 6 | 7 | https://chrome.google.com/webstore/detail/memory-monitor/abijjlmdgkdoahjkdbicefofaicdendm 8 | -------------------------------------------------------------------------------- /background.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 3 | // Draw browser action icon with HTML5 canvas 4 | document.write(''); 5 | 6 | var SIZE = 19; // Icon size 7 | var canvas = document.getElementById('canvas'); 8 | canvas.width = SIZE; 9 | canvas.height = SIZE; 10 | 11 | var c = canvas.getContext("2d"); 12 | 13 | // Define an array to storage available memory percent 14 | var availMem = Array(SIZE); 15 | for (var i = availMem.length; i--; ) { 16 | availMem[i] = 1; 17 | } 18 | 19 | (function draw() { 20 | 21 | // Get available memory percent 22 | chrome.system.memory.getInfo(function (info) { 23 | availMem.push(info.availableCapacity / info.capacity); 24 | availMem.shift(); 25 | 26 | // Show memory information on mouse over 27 | chrome.browserAction.setTitle({ 28 | title: 'Total: ' + (info.capacity / 1073741824).toFixed(2) + ' GiB\n' + 29 | 'Available: ' + (info.availableCapacity / 1073741824).toFixed(2) + ' GiB', 30 | }); 31 | 32 | c.clearRect(0, 0, SIZE, SIZE); 33 | 34 | // Draw memory usage change 35 | c.beginPath(); 36 | c.moveTo(0, SIZE); 37 | for (var i = 0; i < SIZE; i++) { 38 | c.lineTo(i, availMem[i] * SIZE); 39 | } 40 | c.lineTo(SIZE, SIZE); 41 | c.lineWidth = 2; 42 | c.fillStyle = '#66cdaa'; 43 | c.fill(); 44 | 45 | // Draw border 46 | c.beginPath(); 47 | c.moveTo(0, 0); 48 | c.lineTo(0, SIZE); 49 | c.lineTo(SIZE, SIZE); 50 | c.lineTo(SIZE, 0); 51 | c.closePath(); 52 | c.lineWidth = 2; 53 | c.strokeStyle = '#008744'; 54 | c.stroke(); 55 | 56 | chrome.browserAction.setIcon({ 57 | imageData: c.getImageData(0, 0, SIZE, SIZE) 58 | }); 59 | }); 60 | 61 | setTimeout(draw, 1000); 62 | })(); 63 | })(); 64 | -------------------------------------------------------------------------------- /icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pd4d10/memory-monitor/d6334cd576e87ebb5747030552784b2bf18448ca/icon.png -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "manifest_version": 2, 3 | "name": "Memory Monitor", 4 | "description": "Monitor memory status at location bar", 5 | "version": "1.0.0", 6 | "homepage_url": "https://github.com/pd4d10/memory-monitor", 7 | "background": { 8 | "scripts": ["background.js"] 9 | }, 10 | "permissions": ["system.memory"], 11 | "browser_action": {}, 12 | "icons": { 13 | "128": "icon.png" 14 | } 15 | } 16 | --------------------------------------------------------------------------------