@@ 3,7 3,7 @@ const save = (text) => {
{ entries: [] }
).then((items) => {
// Can't store a Map, use an Object instead
- let entry = {
+ const entry = {
"date": Date(),
"hostname": location.hostname,
"text": text,
@@ 20,7 20,7 @@ const undam = (hostname) => {
chrome.storage.sync.get(
{ dammed: [] },
).then((items) => {
- let index = items.dammed.indexOf(hostname);
+ const index = items.dammed.indexOf(hostname);
if (index !== -1) {
items.dammed.splice(index, 1);
chrome.storage.sync.set(
@@ 32,16 32,16 @@ const undam = (hostname) => {
const buildDam = () => {
- let dam = document.createElement("div");
+ const dam = document.createElement("div");
dam.id = "beavers-dam";
document.body.append(dam);
- let textarea = document.createElement("textarea");
+ const textarea = document.createElement("textarea");
dam.append(textarea);
dam.append(document.createElement("br"));
- let saveAndViewJournal = document.createElement("button");
+ const saveAndViewJournal = document.createElement("button");
saveAndViewJournal.textContent = "Save & View Journal";
saveAndViewJournal.addEventListener("click", () => {
if (textarea.value.length > 0) {
@@ 51,13 51,13 @@ const buildDam = () => {
});
dam.append(saveAndViewJournal)
- let saveAndContinue = document.createElement("button");
+ const saveAndContinue = document.createElement("button");
saveAndContinue.textContent = `Save & Continue to ${location.hostname}`;
saveAndContinue.addEventListener("click", () => {
chrome.storage.sync.get(
{ minWords: 0 }
).then((items) => {
- let numWords = textarea.value.trim().split(" ").length;
+ const numWords = textarea.value.trim().split(" ").length;
if (numWords >= items.minWords) {
save(textarea.value);
dam.remove();
@@ 17,9 17,8 @@ document.getElementById("clear").addEventListener(
);
chrome.tabs.query({ active: true}).then(([tab]) => {
let currentURL = new URL(tab.url);
let hostname = currentURL.hostname;
let toggleDammedButton= document.getElementById("toggle-dammed");
const hostname = new URL(tab.url).hostname;
const toggleDammedButton= document.getElementById("toggle-dammed");
chrome.storage.sync.get(
{ dammed: [] },
).then((items) => {