Skip to content

Commit

Permalink
Improve system for taking screenshots
Browse files Browse the repository at this point in the history
Removed a check for SVG texture support that was interfering with taking screenshots programatically *and* doesn't seem to do anything in Chrome/Safari/Firefox/Silk.
  • Loading branch information
iaincollins committed May 11, 2022
1 parent b4c9463 commit 5f68881
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 9 deletions.
Binary file modified resources/images/screenshots/eng-blueprint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/images/screenshots/nav-list.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/images/screenshots/nav-map.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/images/screenshots/nav-route.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified resources/images/screenshots/ship-status.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 18 additions & 8 deletions scripts/screenshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,27 @@ const takeScreenshot = require('take-screenshots')

const HOST = 'http://localhost:3300'
const BASE_DIR = __dirname+'/../resources/images/screenshots'
const OPTIONS = {
const DEFAULT_OPTIONS = {
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36',
viewport: {width: 1024, height: 768},
pageDelay: 1000
viewport: {
width: 1024,
height: 768,
deviceScaleFactor: 2
},
}

function screenshot(url, path, options) {
return takeScreenshot(url, {...DEFAULT_OPTIONS, ...options, screenshot: { path }})
}

;(async () => {
//await takeScreenshot(`${HOST}/nav/map?system=Maia`, `${BASE_DIR}/nav-map.png`, OPTIONS)
await takeScreenshot(`${HOST}/nav/list?system=Farwell`, `${BASE_DIR}/nav-list.png`, OPTIONS)
await takeScreenshot(`${HOST}/nav/route`, `${BASE_DIR}/nav-route.png`, OPTIONS)
await takeScreenshot(`${HOST}/eng/blueprints?symbol=FSD_LongRange`, `${BASE_DIR}/eng-blueprint.png`, OPTIONS)
await takeScreenshot(`${HOST}/ship/status`, `${BASE_DIR}/ship-status.png`, OPTIONS)
await Promise.all([
screenshot(`${HOST}/nav/map?system=maia`, `${BASE_DIR}/nav-map.png`, { pageDelay: 1000 }),
screenshot(`${HOST}/nav/list?system=farwell&selected=farwell+a+6+a`, `${BASE_DIR}/nav-list.png`),
screenshot(`${HOST}/nav/route`, `${BASE_DIR}/nav-route.png`),
screenshot(`${HOST}/eng/blueprints?symbol=FSD_LongRange`, `${BASE_DIR}/eng-blueprint.png`),
screenshot(`${HOST}/ship/status`, `${BASE_DIR}/ship-status.png`)
])
await takeScreenshot.closeBrowser()
process.exit()
})()
1 change: 0 additions & 1 deletion src/web/pages/_document.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ class MyDocument extends Document {
} else if (
// Check is Google Chrome (and not impostor)
isChromium !== null &&
typeof isChromium !== "undefined" &&
window.navigator.vendor === "Google Inc." &&
!window.navigator.userAgent.match("like Chrome") && // Browsers like Amazon Fire's Silk Browsers use the Google Inc. vendor name, but that's a lie and it doesn't support this feature
isOpera === false &&
Expand Down

0 comments on commit 5f68881

Please sign in to comment.