User script to add a confirm prompt to Phabricator when you have written text
Completely untested, probably does not work as-is, just stored here to not lose the idea.
It will not handle other pending actions than text written in a textarea (like checking "done" on conversations, etc.).
window.onbeforeunload(function(event) {
var textAreas = document.getElementsByTagName("textarea");
if (textAreas.some(function(area) { area.value.length > 0})) {
return "You have unsaved changes. Are you sure you want to leave this page?"
}
});