DDoSolitary / URL in Title

// ==UserScript==
// @name        URL in Title
// @description Add URL to your page title. (Usefull for KeePass.)
// @author      DDoSolitary
// @version     0.1.1
// @updateURL   https://openuserjs.org/meta/DDoSolitary/URL_in_Title.meta.js
// @match       *://*/*
// @run-at      document-start
// @grant       none
// ==/UserScript==

(function() {
	var lastSuffix = null;
	var addUrlSuffix = function() {
	    if (document.getElementsByTagName('title').length === 0) return;
		var urlSuffix = '| ' + location.href;
		var title = document.title;
		if (!title.endsWith(urlSuffix)) {
			if (lastSuffix !== null && title.endsWith(lastSuffix)) {
				title = title.substr(0, title.length - lastSuffix.length - 1);
			}
			lastSuffix = urlSuffix;
			document.title = title + ' ' + urlSuffix;
		}
	};
	addUrlSuffix();
	setInterval(addUrlSuffix, 250);
})();