Drag each bookmarklet to your bookmarks bar and then click them to save, restore, and clear the saved position.
// Save Position
(function() {
if(!localStorage.hasOwnProperty('sbrl-bookmarks')) localStorage.setItem('sbrl-bookmarks', '{}');
var bookmarks = JSON.parse(localStorage.getItem('sbrl-bookmarks'));
bookmarks[location.pathname] = {
x: document.body.scrollTop,
y: document.body.scrollLeft
};
localStorage.setItem('sbrl-bookmarks', JSON.stringify(bookmarks));
alert('Position saved for ' + location.pathname + ' on ' + location.host);
})();
// Restore Position
(function() {
if(!localStorage.hasOwnProperty('sbrl-bookmarks')) localStorage.setItem('sbrl-bookmarks', '{}');
var bookmarks = JSON.parse(localStorage.getItem('sbrl-bookmarks'));
if(!bookmarks.hasOwnProperty(location.pathname))
{
alert('No position saved for ' + location.pathname + ' on ' + location.host);
return false;
}
document.body.scrollTop = bookmarks[location.pathname].x;
document.body.scrollLeft = bookmarks[location.pathname].y;
})();
// Clear Position
(function() {
if(!localStorage.hasOwnProperty('sbrl-bookmarks')) localStorage.setItem('sbrl-bookmarks', '{}');
var bookmarks = JSON.parse(localStorage.getItem('sbrl-bookmarks'));
if(bookmarks.hasOwnProperty(location.pathname)) delete bookmarks[location.pathname];
localStorage.setItem('sbrl-bookmarks', JSON.stringify(bookmarks));
alert('Position cleared for ' + location.pathname + ' on ' + location.host);
})();