Skip to content

Instantly share code, notes, and snippets.

@marc22alain
Created August 16, 2019 21:05
Show Gist options
  • Save marc22alain/5dbab53ac70109f35b5b695eb63940b3 to your computer and use it in GitHub Desktop.
Save marc22alain/5dbab53ac70109f35b5b695eb63940b3 to your computer and use it in GitHub Desktop.
Adding content to ShadowDOM.innerHTML
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<title>Adding content to slot.innerHTML</title>
<script type="text/javascript" src="seckit.document_write.js"></script>
<link type="text/css" rel="stylesheet" id="seckit-clickjacking-no-body" media="all" href="seckit.no_body.css" />
<!-- stop SecKit protection -->
</head>
<body>
<h1>Content should appear below</h1>
<p>Check out what happens in the head...</p>
<div id="slot"></div>
<script>
const CRLcontent = '\u003c!DOCTYPE html\u003e\n\u003chtml lang=\"en\" dir=\"ltr\"\u003e\n \u003chead\u003e\n \u003clink rel=\"stylesheet\" href=\"/sites/default/files/css/css_PXKyJUac5CjOsyl7xA6aCmq51JomRky41Sc9wSdnkNM.css?pt3g8u\" media=\"all\" /\u003e\n\u003clink rel=\"stylesheet\" href=\"/sites/default/files/css/css_-KtFzMTyHEmOsnjTaOTUnxzm2UeNekah9k3I8gvAjyQ.css?pt3g8u\" media=\"all\" /\u003e\n\n \n\u003c!--[if lte IE 8]\u003e\n\u003cscript src=\"/sites/default/files/js/js_VtafjXmRvoUgAzqzYTA3Wrjkx9wcWhjP0G4ZnnqRamA.js\"\u003e\u003c/script\u003e\n\u003c![endif]--\u003e\n\n \u003cscript type=\"text/javascript\" src=\"seckit.document_write.js\"\u003e\u003c/script\u003e\n \u003clink type=\"text/css\" rel=\"stylesheet\" id=\"seckit-clickjacking-no-body\" media=\"all\" href=\"seckit.no_body.css\" /\u003e\n \u003c!-- stop SecKit protection --\u003e\n \u003cnoscript\u003e\n \u003clink type=\"text/css\" rel=\"stylesheet\" id=\"seckit-clickjacking-noscript-tag\" media=\"all\" href=\"/modules/contrib/seckit/css/seckit.noscript_tag.css\" /\u003e\n \u003cdiv id=\"seckit-noscript-tag\"\u003e\n Sorry, you need to enable JavaScript to visit this website.\n \u003c/div\u003e\n \u003c/noscript\u003e\u003c/head\u003e\n \u003cbody\u003e\n \u003cdiv class=\"dialog-off-canvas-main-canvas\" data-off-canvas-main-canvas\u003e\n \u003ca target=\"_blank\" href=\"http://eureka.criver.com/compounding-and-unapproved-drugs/\"\u003e\n\u003carticle id=\"node-35561\" data-history-node-id=\"35561\" role=\"article\" about=\"/insights/compounding-and-unapproved-drugs\" class=\"card__small\"\u003e\n \u003cdiv class=\"image--thumbnail\" style=\"background-image:url(https://embed.widencdn.net/img/criver/2z1cr75qu4/exact/72693897_xxl.jpeg?position=c\u0026amp;amp;crop=no\u0026amp;amp;color=ffffffff\u0026amp;amp;u=fwtil1)\"\u003e\u003c/div\u003e\n\n \u003ch5\u003e \u003cdiv class=\"field-wrapper field field--name-field-insight-type field--type-entity-reference field--label-hidden field__items\"\u003e\n \u003cdiv class=\"field__item\"\u003e\n Blog\n \u003c/div\u003e\n \u003c/div\u003e\n\u003c/h5\u003e\n \n \u003ch3 class=\"node-title\"\u003e\n \u003cspan class=\"field-wrapper field field--name-title field--type-string field--label-hidden\"\u003e Compounding and Unapproved Drugs\n \u003c/span\u003e\n\n \u003c/h3\u003e\n \n \u003ch4\u003eLearn More\u003c/h4\u003e\n \u003cdiv class=\"view-mode-card\"\u003e\n \n \u003c/div\u003e\n\u003c/article\u003e\n\u003c/a\u003e\n\n\n\n \u003c/div\u003e\n\n \u003cdiv data-content-barrier-exclude=\"true\"\u003e\n \u003cscript type=\"application/json\" data-drupal-selector=\"drupal-settings-json\"\u003e{\"path\":{\"baseUrl\":\"\\/\",\"scriptPath\":null,\"pathPrefix\":\"\",\"currentPath\":\"acquia-contenthub\\/bulk-upload\",\"currentPathIsAdmin\":false,\"isFront\":false,\"currentLanguage\":\"en\",\"currentQuery\":{\"node\":\"35561\"}},\"pluralDelimiter\":\"\\u0003\",\"smartIp\":\"{\\u0022location\\u0022:{\\u0022source\\u0022:\\u0022smart_ip\\u0022,\\u0022ipAddress\\u0022:\\u0022162.158.78.160\\u0022,\\u0022ipVersion\\u0022:4,\\u0022timestamp\\u0022:1560526363,\\u0022country\\u0022:\\u0022US\\u0022,\\u0022countryCode\\u0022:\\u0022US\\u0022,\\u0022isEuCountry\\u0022:false,\\u0022isGdprCountry\\u0022:false}}\",\"smartIpSrc\":{\"smartIp\":\"smart_ip\",\"geocodedSmartIp\":\"geocoded_smart_ip\",\"w3c\":\"w3c\"},\"user\":{\"uid\":0,\"permissionsHash\":\"ed7a8a8e5032bcacb17bc8f1fbf7d8888c7fefe15f90d755a8368be84778977f\"}}\u003c/script\u003e\n\u003cscript src=\"/sites/default/files/js/js_jv-czj5F8cpxwj5JAlnv_hs5bAYL0WFBnTVXInBAcIg.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-59f0e354fa66ba72\"\u003e\u003c/script\u003e\n\u003cscript src=\"/sites/default/files/js/js_0tdYcWEZxg6IQ7ofY7EE8v2P9es1iS_-Vbr0hUxNwtE.js\"\u003e\u003c/script\u003e\n\n \u003c/div\u003e\n \u003c/body\u003e\n\u003c/html\u003e\n';
const slot = document.getElementById('slot');
const shadow = slot.attachShadow({ mode: 'closed' });
shadow.innerHTML = CRLcontent;
</script>
</body>
</html>
/**
* If site is not being framed or being framed within the same host,
* start commenting out seckit.no_body.css.
*/
if (top === self || top.location.hostname === self.location.hostname) {
document.write('<!--');
}
/**
* Hide <body> element.
*/
body {
display: none !important;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment