Skip to content

Instantly share code, notes, and snippets.

@sanmai
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sanmai/8caa70f4f3132d543bd7 to your computer and use it in GitHub Desktop.
Save sanmai/8caa70f4f3132d543bd7 to your computer and use it in GitHub Desktop.
LiveJournal Editor Autosave Watch
// ==UserScript==
// @name LiveJournal Editor Autosave Watch
// @namespace https://gist.github.com/sanmai
// @description Warns user if autosave not happens
// @include http://www.livejournal.com/update.bml*
// @author Alexey Kopytko
// @updateURL https://gist.github.com/sanmai/8caa70f4f3132d543bd7/raw/LiveJournalAutosaveWatch.user.js
// @version 1.0
// @licence MIT
// ==/UserScript==
var warning = unsafeWindow.jQuery('<div style="position: fixed; top: 1em; right: 1em; border: 2px solid red; background-color: white; padding: 1em; font-size: 2em; z-index: 100;">Document Not Saved</div>');
warning.appendTo("body").hide();
var prevValue = '';
var checkEverySeconds = 60;
window.setInterval(function () {
var elements = document.getElementsByClassName('b-updatepage-draft');
if (!elements.length) {
return;
}
var currentValue = elements[0].textContent;
if (currentValue == prevValue && prevValue != '') {
warning && warning.show();
} else {
prevValue = currentValue;
warning && warning.hide();
}
}, 1000 * checkEverySeconds);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment