- From: Patrick H. Lauke <redux@splintered.co.uk>
- Date: Tue, 6 Jul 2021 16:17:30 +0100
- To: www-validator@w3.org
- Message-ID: <752ba2c1-0285-9f4e-7da6-7da917a85a88@splintered.co.uk>
Following proper process and sending it to the general email address... P -------- Forwarded Message -------- Subject: Tweaks to the "Check serialized DOM" bookmarklets to clean up after themselves Date: Wed, 16 Jun 2021 14:53:07 +0100 From: Patrick H. Lauke <redux@splintered.co.uk> To: Michael[tm] Smith <mike@w3.org> CC: Steve Faulkner <sfaulkner@paciellogroup.com> Hi Michael, just a quick one: while the two bookmarklets to check serialized DOM on https://validator.w3.org/nu/about.html work great, one niggle is that they leave behind a visible form after they've been triggered (see attached). I've made a quick patch that, after submission, removes the injected form again, leaving the page as it was. Check serialized DOM: javascript:(function(){function c(a,b){var c=document.createElement("textarea");c.name=a;c.value=b;d.appendChild(c)}var e=function(a){for(var b="",a=a.firstChild;a;){switch(a.nodeType){case Node.ELEMENT_NODE:b+=a.outerHTML;break;case Node.TEXT_NODE:b+=a.nodeValue;break;case Node.CDATA_SECTION_NODE:b+="<![CDATA["+a.nodeValue+"]]\>";break;case Node.COMMENT_NODE:b+="<\!--"+a.nodeValue+"--\>";break;case Node.DOCUMENT_TYPE_NODE:b+="<!DOCTYPE "+a.name+">\n"}a=a.nextSibling}return b}(document),d=document.createElement("form");d.method="POST";d.action="https://validator.w3.org/nu/";d.enctype="multipart/form-data";d.target="_blank";d.acceptCharset="utf-8";c("showsource","yes");c("content",e);document.body.appendChild(d);d.submit();document.body.removeChild(d);})(); Check serialized DOM (JSON): javascript:(function(){function c(a,b){var c=document.createElement("textarea");c.name=a;c.value=b;d.appendChild(c)}var e=function(a){for(var b="",a=a.firstChild;a;){switch(a.nodeType){case Node.ELEMENT_NODE:b+=a.outerHTML;break;case Node.TEXT_NODE:b+=a.nodeValue;break;case Node.CDATA_SECTION_NODE:b+="<![CDATA["+a.nodeValue+"]]\>";break;case Node.COMMENT_NODE:b+="<\!--"+a.nodeValue+"--\>";break;case Node.DOCUMENT_TYPE_NODE:b+="<!DOCTYPE "+a.name+">\n"}a=a.nextSibling}return b}(document),d=document.createElement("form");d.method="POST";d.action="https://validator.w3.org/nu/";d.enctype="multipart/form-data";d.target="_blank";d.acceptCharset="utf-8";c("showsource","yes");c("out","json");c("content",e);document.body.appendChild(d);d.submit();document.body.removeChild(d);})(); Any chance these could be updated? Thanks, P -- Patrick H. Lauke https://www.splintered.co.uk/ | https://github.com/patrickhlauke https://flickr.com/photos/redux/ | https://www.deviantart.com/redux twitter: @patrick_h_lauke | skype: patrick_h_lauke
Attachments
- image/png attachment: Screenshot_2021-06-16_145246.png
Received on Tuesday, 6 July 2021 15:17:44 UTC