Skip to content

Instantly share code, notes, and snippets.

@yaronf
Created August 14, 2021 21:44
Show Gist options
  • Save yaronf/3fda1adba687b9781e2efb3c6b1e902b to your computer and use it in GitHub Desktop.
Save yaronf/3fda1adba687b9781e2efb3c6b1e902b to your computer and use it in GitHub Desktop.
Render Internet Draft from XML
// ==UserScript==
// @name Render Internet Draft from XML 279509
// @version 1
// @resource xslFile https://tools.ietf.org/id/rfc2629.xslt
// @grant GM_getResourceText
// @match https://tools.ietf.org/id/*.xml
// @match https://www.ietf.org/archive/id/*.xml
// ==/UserScript==
console.log("Render I-D: Loaded")
var xsl_str = GM_getResourceText ("xslFile");
var processor = new XSLTProcessor ();
var dataXSL = new DOMParser ().parseFromString (xsl_str, "text/xml");
processor.importStylesheet (dataXSL);
var newDoc = processor.transformToDocument (document);
//-- These next lines swap the new, processed doc in for the old one...
window.content = newDoc;
document.replaceChild (
document.importNode (newDoc.documentElement, true),
document.documentElement
);
console.log("Render I-D: Done")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment