Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --no-javascript flag #14

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const cli = meow(`
--click-element Click the DOM element matching the CSS selector
--scroll-to-element Scroll to the DOM element matching the CSS selector
--disable-animations Disable CSS animations and transitions [default: false]
--no-javascript Disable JavaScript execution (does not affect --module/--script)
--module Inject a JavaScript module into the page. Can be inline code, absolute URL, and local file path with \`.js\` extension. (Can be set multiple times)
--script Same as \`--module\`, but instead injects the code as a classic script
--style Inject CSS styles into the page. Can be inline code, absolute URL, and local file path with \`.css\` extension. (Can be set multiple times)
Expand Down Expand Up @@ -61,6 +62,7 @@ const cli = meow(`
--click-element="button"
--scroll-to-element="#map"
--disable-animations
--no-javascript
--module=https://sindresorhus.com/remote-file.js
--module=local-file.js
--module="document.body.style.backgroundColor = 'red'"
Expand Down Expand Up @@ -125,6 +127,10 @@ const cli = meow(`
disableAnimations: {
type: 'boolean'
},
javascript: {
type: 'boolean',
default: true
},
module: {
type: 'string'
},
Expand Down Expand Up @@ -189,6 +195,8 @@ if (options.authentication) {
options.authentication = {username, password};
}

options.isJavaScriptEnabled = options.javascript;

(async () => {
if (options.internalPrintFlags) {
console.log(JSON.stringify(options));
Expand Down
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ $ capture-website --help
--click-element Click the DOM element matching the CSS selector
--scroll-to-element Scroll to the DOM element matching the CSS selector
--disable-animations Disable CSS animations and transitions [default: false]
--no-javascript Disable JavaScript execution (does not affect --module/--script)
--module Inject a JavaScript module into the page. Can be inline code, absolute URL, and local file path with `.js` extension. (Can be set multiple times)
--script Same as `--module`, but instead injects the code as a classic script
--style Inject CSS styles into the page. Can be inline code, absolute URL, and local file path with `.css` extension. (Can be set multiple times)
Expand Down Expand Up @@ -74,6 +75,7 @@ $ capture-website --help
--click-element="button"
--scroll-to-element="#map"
--disable-animations
--no-javascript
--module=https://sindresorhus.com/remote-file.js
--module=local-file.js
--module="document.body.style.backgroundColor = 'red'"
Expand Down
1 change: 1 addition & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ test('check flags', async t => {
--click-element="button"
--scroll-to-element="#map"
--disable-animations
--no-javascript
--module=https://sindresorhus.com/remote-file.js
--module=local-file.js
--module="document.body.style.backgroundColor = 'red'"
Expand Down
1 change: 1 addition & 0 deletions test.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Generated by [AVA](https://ava.li).
'.sidebar',
],
internalPrintFlags: true,
javascript: false,
launchOptions: {
headless: false,
},
Expand Down
Binary file modified test.js.snap
Binary file not shown.