I am trying to make a bookmarklet to take notes but I can’t get to work here’s the bookmarklet that it is based off of.
javascript:(function(){
function save() {
localStorage.setItem('SavedState', document.body.innerHTML);
alert('State saved!');
}
function load() {
var savedContent = localStorage.getItem('SavedState');
if (savedContent !== null) {
document.body.innerHTML = savedContent;
alert('State loaded!');
} else {
alert('No saved state found.');
}}
var saveorload = prompt('save or load? It must be exactly save or load.');
if (saveorload == 'save') {
save();
}
if (saveorload == 'load') {
load();
}})()
And here’s the notes bookmarklet.
javascript:(function(){
function take() {
var notetotake = prompt('Note?');
localStorage.setItem('notes', notetotake);
alert('State saved!');
}
function read() {
var notetoread = localStorage.getItem('notes');
if (notetoread !== null) {
prompt('Copy this text', oldnotes);
} else {
alert('No taken notes found.');
}}
var todo = prompt('take or read? It must be exactly take or read.');
if (todo == 'take') {
take();
}
if (todo == 'read') {
read();
}})()
Please help fix this bookmarklet.
I tried it and it just won’t work for me.
2
Answers
Nvm sorry I got it to work.
There is a typo in your
read
function.If you change
prompt('Copy this text', oldnotes);
toprompt('Copy this text', notetoread);
your bookmarklet should work fine.