A save your place bookmarklet
Posted Tue, Dec 1, 2009 in:I read a lot of web comics, and one of the things that happens when reading through the archives of a comic is that I lose my place in the history, so when I come back, I have to spend a lot of time searching to find where I left off.
I wrote this simple set of bookmarklets to help me in this situation. The “save place” bookmarklet stuffs the current URL into a cookie (cookies are per site, so there will be one cookie for each site you use this on), and the “restore place” bookmarklet takes the URL out of the cookie (if it exists) and loads that page. The “clear place” bookmarklet clears the cookie.
To use them, just drag the bookmarklets to your bookmark toolbar, or right-click on them and select “bookmark this link”.
Save Place | Restore Place | Clear Place
For those who are interested, here’s the code in function form:
function savePlace() {
var date = new Date();
document.cookie='ppdc_saved_location='+escape(document.location)
+'; expires='+date.setTime(date.getTime()+22896000000)+'; path=/';
}
function restorePlace() {
document.location = (function() {
var ca = document.cookie.split(';');
for(var i=0;i<ca.length;i++) {
var c=ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf('ppdc_saved_location=') == 0)
return unescape(c.substring(20,c.length));
}
return document.location;
})();
}
function clearPlace() {
document.cookie='ppdc_saved_location=; expires=-1; path=/';
}
I based my code off the createCookie and readCookie functions from QuirksMode