- npm install
- npm run go
- node.js >= 8.0.0
| { | |
| "name": "WaybackReplayCNN", | |
| "author": "John Berlin <jberlin@cs.odu.edu>", | |
| "version": "1.0.0", | |
| "main": "replayCNN.js", | |
| "license": "MIT", | |
| "scripts": { | |
| "go": "node replayCnn.js" | |
| }, | |
| "dependencies": { | |
| "puppeteer": "^0.13.0" | |
| }, | |
| "engines": { | |
| "node": ">=8.0.0" | |
| } | |
| } |
| const puppeteer = require('puppeteer') | |
| function magic () { | |
| Object.defineProperty(window.document, 'domain', { | |
| configurable: true, | |
| enumerable: false, | |
| get () { | |
| return window.location.host | |
| }, | |
| set (to) { | |
| console.log(`somebody tried to set the domain to ${to}`) | |
| } | |
| }) | |
| } | |
| // change to whatever your screen size is. Puppeteer does not use the full width of your viewport | |
| const viewPortSize = { | |
| width: 1920, | |
| height: 1080, | |
| mobile: false | |
| } | |
| async function go () { | |
| const browser = await puppeteer.launch({headless: false}) | |
| const page = await browser.newPage() | |
| await page.evaluateOnNewDocument(magic) | |
| await page.setViewport(viewPortSize) | |
| // await page.goto('https://web.archive.org/web/*/http://www.cnn.com/', {timeout: 60000}) | |
| await page.goto('http://web.archive.org/web/20171212122910/http://www.cnn.com/', {timeout: 60000}) | |
| } | |
| go().catch(error => { | |
| console.error(error) | |
| }) |