Skip to content

Instantly share code, notes, and snippets.

@N0taN3rd
Last active December 13, 2017 04:53
Show Gist options
  • Select an option

  • Save N0taN3rd/308a0e1218236ceb3b833c75bd7c5004 to your computer and use it in GitHub Desktop.

Select an option

Save N0taN3rd/308a0e1218236ceb3b833c75bd7c5004 to your computer and use it in GitHub Desktop.
Re-enable replay of cnn.com's homepage for the Internet Archives WaybackMachine

Usage

  1. npm install
  2. npm run go

Requirements

  1. 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)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment