// ==UserScript== // @namespace http://www.squarefree.com/userscripts // @name Valid XHTML // @description Makes it easier to keep your blog posts and comments well-formed and valid. // @include */wp-admin/post.php* // @include */mt.cgi* // @include http://simon.incutio.com/archive/* // ==/UserScript== /* Version history: 2005-12-01: Use unsafeWindow to access DOMParser :( 2005-08-29: Made the script work with XPCNativeWrappers, at least in Gecko 1.8 branch builds. Many other changes, mostly small. */ /* MESSAGES */ const GOOD = { color: "green" }; const PENDING = { color: "" }; const BAD = { color: "red" }; const REALLYBAD = { color: "fuchsia" }; function message(messageDiv, type, nodes) { // Remove the old message, if any. while (messageDiv.firstChild) messageDiv.removeChild(messageDiv.firstChild); // Update the color. messageDiv.style.color = type.color; // Add the new message. var i, node; for (i = 0; node = nodes[i]; ++i) messageDiv.appendChild(node); } function text(t) { return document.createTextNode(t); } function link(fun, child) { var a = document.createElement("a"); a.style.color = "inherit"; a.style.background = "inherit"; a.href = "javascript:void 0"; a.addEventListener("click", fun, false); a.appendChild(child); return a; } /* "SELECT ERROR" LINKS */ function selectError(ta, line, column) { var i, spot, cc, lines; lines = ta.value.split("\n"); cc = 0; for (i = 0; i < (line - 3); ++i) { cc += lines[i].length + 1; } spot = Math.min(cc + (column - 1), ta.value.length - 1); ta.focus(); ta.selectionStart = spot; ta.selectionEnd = spot + 2; } /* "VALIDATE" LINKS */ const transitionalDTD = ''; const strictDTD = ''; var validateFragment = function (doctype, fragment) { // Construct a complete document. var htmlToUpload = doctype + '