Last active
August 29, 2015 14:12
-
-
Save sanmai/8caa70f4f3132d543bd7 to your computer and use it in GitHub Desktop.
LiveJournal Editor Autosave Watch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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