Skip to content

Instantly share code, notes, and snippets.

@chomamateusz
Created March 15, 2023 12:38
Show Gist options
  • Save chomamateusz/d9b8397aec6fda9bdbe79d3409c23a85 to your computer and use it in GitHub Desktop.
Save chomamateusz/d9b8397aec6fda9bdbe79d3409c23a85 to your computer and use it in GitHub Desktop.
Canva page screenshots
// works only in Firefox and its based on https://firefox-source-docs.mozilla.org/devtools-user/taking_screenshots/index.html
// you need to find the wrapper over pages in Canva (they all should have same class) and pass them as an arg to this function
// if Canva structure will change you can play with selector in first `.map`
const makeScreenshotsOfAllPages = ({ pageWrapperClass }) => (
$$(`.${pageWrapperClass}`)
.map((e, i) => `.${pageWrapperClass}:nth-of-type(${i+1}) > div:nth-of-type(2)`)
.map((selector, i) => `:screenshot --selector "${selector}" --file --filename "${document.title.replaceAll('/', '')} – ${i + 1}.png"`)
.map((command) => {
copy(command)
return command
})
)
// example working when creating this gits
makeScreenshotsOfAllPages({ pageWrapperClass: '_71UiLA' })
// sadly `copy` fucntionality do not work for me in this case same as invoking :screenshot command programaticaly
@chomamateusz
Copy link
Author

WARNING each page must be visible in the viewport during taking a screenshot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment