スクロール位置の永続保存
var scroll = eval(GM_getValue('Scroll', "({})"));
log("%1.o", scroll);
window.addEventListener("load", function (e) {
if (scroll[location.href])
document.body.scrollTop = scroll[location.href];
}, false);
GM_registerMenuCommand("Save scroll positon for next time", function () {
if (document.body.scrollTop)
scroll[location.href] = document.body.scrollTop;
else
delete scroll[location.href];
GM_setValue('Scroll', scroll.toSource());
alert('saved');
}, 's', 'control meta');
GM_registerMenuCommand("Reset scroll positons", function () {
scroll = {};
location.reload();
});を test.user.js に書いてみた。Ctrl-Cmd-S で保存のつもりなんだけど、なんかショートカットちゃんと効いてくれない……
自動で全サイト保存するように最初は書いたんだけどうざいのでやめた。
というか、一番最初はブックマークにスクロール位置を保存して復元するっていうのをやりたかった。でも一発でブックマークする関数 (サイドバーに開くのしかないよね。チェックはずすのめんどいし) が見つからないのでやめた。