Skip to main content
100%

detecting window.document.domain

✓ Published0🌍 Public
NN0taN3rd
Last edited Mar 17, 2017
Created on Mar 17, 2017

This example detects assignments to `window.document.domain` inside inline JavaScript and removes them from a saved CNN news page. It parses each inline script into an abstract syntax tree using Babylon, traverses the tree with Babel’s `traverse`, and filters `AssignmentExpression` nodes where the computed key is the literal `'domain'` and the object is `document`. Modified scripts are regenerated with `babel-generator`, and the updated HTML is written back to disk using `fs-extra`. The code reads the original page with Cheerio and writes the result to `mod.html`.

AI-generated description

Similar vizzes