(function () {
	'use strict';

	if (document.body.textContent.match(/Stable ID: \d+/)) {
		if (sessionStorage.postLogin) {
			delete sessionStorage.postLogin;
			chrome.runtime.sendMessage({command: 'post_login'});
		}
	} else {
		Array.prototype.forEach.call(document.querySelectorAll('form[id^="login_content_form"]'), function (form) {
			form.addEventListener('submit', function () {
				sessionStorage.postLogin = true;
			});
		});
	}
}());