@sebgroup/document-write-intervene

Prevent document write from writing to your document and instead insert a new script to the dom.

Usage no npm install needed!

<script type="module">
  import sebgroupDocumentWriteIntervene from 'https://cdn.skypack.dev/@sebgroup/document-write-intervene';
</script>

README

document-write-intervene

Build Status Commitizen friendly semantic-release

Overwrites document.write function and will prevent it from clearing your document contents due to how document.write works when the document has been loaded.

It checks if the markup is a <script> tag and will load it asynchronous.

Otherwise it will insert the contents using insertAdjacentHTML on the body

Tested inside an Angular project.

It should work seamlessly with a React project.

Otherwise you could have a look at browserify to integrate it in your project

Installation

Install via npm:

$ npm install @sebgroup/document-write-intervene

Example

const { intervene } = require('@sebgroup/document-write-intervene')
intervene()

Testing

Unit tests:

$ npm t

E2E tests:

  • Chrome tests:
$ npm run webdriver:chrome

and then

$ npm run e2e:chrome
  • Internet Explorer tests:
$ npm run webdriver:ie

and then

$ npm run e2e:ie