-
Notifications
You must be signed in to change notification settings - Fork 0
/
newtab.js
35 lines (32 loc) · 1.12 KB
/
newtab.js
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
(function () {
function getRandomHex() {
var letters = "0123456789ABCDEF".split("");
var color = "#";
for (var i = 0; i < 6; i++) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}
document.addEventListener("DOMContentLoaded", function () {
var reminder = document.getElementById("reminder");
reminder.textContent = "*".repeat(20);
chrome.storage.local.get(["reminder"], function (result) {
if (result.reminder) {
var content = result.reminder;
var toggler = document.getElementById("toggler");
toggler.addEventListener("click", function () {
let reminder = document.querySelector("#reminder");
if (reminder.getAttribute("data-type") === "password") {
reminder.setAttribute("data-type", "text");
reminder.textContent = content;
} else {
reminder.setAttribute("data-type", "password");
reminder.textContent = "*".repeat(20);
}
});
}
});
});
reminder.style.color = getRandomHex();
document.body.style.backgroundColor = getRandomHex();
})();