I modded the extension a bit. If you click the blank page, you can now type notes. it will save them forever too.
<!DOCTYPE html>
<title>Notes</title>
<link rel="icon" href="icons/favicons/dark.ico">
<style>
html,
body {
background-color: rgba(33, 33, 33, 1);
width: 100%;
height: 100%;
margin: 0;
padding: 0;
color: #fcfcfc;
white-space: pre;
}
.note-wrapper {
height: 100%;
padding: 0 0 0 0;
}
.note-container {
width: 100%;
margin: 0 auto;
min-height: 100%;
padding: 40px 40px;
outline: 0;
border: 0;
font-size: 14px;
font-family: monospace;
background: rgba(33, 33, 33, 1);
white-space: pre;
tab-size: 4;
}
</style>
<body>
<div class="note-wrapper">
<div class="note-container" id="js-note-container" contenteditable="" spellcheck="false"></div>
</div>
<script src="index.js"></script>
</body>
// Set title
document.title = chrome.i18n.getMessage("tabTitle");
// Set favicon
function updateFavicon(e) {
const color = e.matches ? "light" : "dark";
document.querySelector('link[rel="icon"]').href = `icons/favicons/${color}.ico`;
}
const darkMode = window.matchMedia("(prefers-color-scheme: dark)");
darkMode.addEventListener("change", updateFavicon);
updateFavicon(darkMode);
//make tab key work
document.getElementById('js-note-container').addEventListener('keydown', function(event) {
if (event.key === 'Tab') {
event.preventDefault();
var selection = window.getSelection();
var range = selection.getRangeAt(0);
var start = range.startOffset;
var end = range.endOffset;
var textNode = range.startContainer;
var textContent = textNode.textContent;
var lines = textContent.substring(start, end).split(/\r?\n/);
for (var i = 0; i < lines.length; i++) {
lines[i] = '\t' + lines[i];
}
textNode.textContent = textContent.substring(0, start) + lines.join('\n') + textContent.substring(end);
// put caret at right position again
range.setStart(textNode, start + 1);
range.setEnd(textNode, start + 1);
}
});
//save
window.addEventListener("load", function() {
document.querySelector("#js-note-container").innerHTML = localStorage.getItem("notes");
});
document.querySelector("#js-note-container").addEventListener("input", function() {
localStorage.setItem("notes", this.innerHTML);
});
//clean pastes to plain text
document.querySelector("#js-note-container").addEventListener("paste", function(e) {
e.preventDefault();
var text = "";
if (e.clipboardData && e.clipboardData.getData) {
text = e.clipboardData.getData("text/plain");
} else if (window.clipboardData && window.clipboardData.getData) {
text = window.clipboardData.getData("Text");
}
document.execCommand("insertHTML", false, text);
});
feel free to steal all this code I added, it was chatGPT that wrote it anyway lol