Created
March 15, 2023 12:38
-
-
Save chomamateusz/d9b8397aec6fda9bdbe79d3409c23a85 to your computer and use it in GitHub Desktop.
Canva page screenshots
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
WARNING each page must be visible in the viewport during taking a screenshot!