-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinject.js
More file actions
41 lines (35 loc) · 1.3 KB
/
inject.js
File metadata and controls
41 lines (35 loc) · 1.3 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
"use strict"
if (document.querySelector("#memorymonitor")) {
document.querySelector("#memorymonitor").remove();
}
document.querySelector("body").insertAdjacentHTML("beforeend", "<div id='memorymonitor'>memory monitor</div>");
var bar = document.querySelector("#memorymonitor");
bar.style.zIndex = "4646";
bar.style.position = "fixed";
bar.style.left = (window.innerWidth - 100) + "px";
bar.style.top = (window.innerHeight - 40) + "px";
bar.style.cursor = "move";
bar.style.webkitUserSelect = "none";
chrome.runtime.onMessage.addListener(function(request) {
bar.textContent = request.available;
});
chrome.storage.sync.get({
bartextcolor: "#000000", barbackground: "#ffffff", barsize: 20
}, function(items) {
bar.style.backgroundColor = items.barbackground;
bar.style.color = items.bartextcolor;
bar.style.fontSize = items.barsize + "px";
});
window.addEventListener("resize", function() {
bar.style.left = (window.innerWidth - 100) + "px";
bar.style.top = (window.innerHeight - 40) + "px";
});
bar.onmousedown = function() {
document.onmousemove = function(event) {
bar.style.left = (event.pageX - (bar.clientWidth / 2)) + "px";
bar.style.top = (event.pageY - (bar.clientHeight / 2)) + "px";
}
document.onmouseup = function() {
document.onmousemove = null;
document.onmouseup = null;
} }