Skip to content

Commit

Permalink
feat: delete hide and remove options
Browse files Browse the repository at this point in the history
use `styles` instead
  • Loading branch information
Kikobeats committed Jun 30, 2022
1 parent 06e8bc0 commit ac85313
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 55 deletions.
30 changes: 3 additions & 27 deletions README.md
Expand Up @@ -361,7 +361,9 @@ You can configure the overlay specifying:

```js
const buffer = await browserless.screenshot(url.toString(), {
hide: ['.crisp-client', '#cookies-policy'],
styles: [
'.crisp-client, #cookies-policy { display: none; }'
],
overlay: {
browser: 'dark',
background:
Expand Down Expand Up @@ -581,18 +583,6 @@ await browserless.goto(page, {
})
```

##### hide

type: `string``string[]`</br>

Hide DOM elements matching the given [CSS selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors).

```js
const buffer = await browserless.screenshot(url.toString(), {
hide: ['.crisp-client', '#cookies-policy']
})
```

This sets [`visibility: hidden`](https://stackoverflow.com/a/133064/64949) on the matched elements.

##### html
Expand Down Expand Up @@ -637,20 +627,6 @@ const buffer = await browserless.screenshot(url.toString(), {
})
```

##### remove

type: `string``string[]`</br>

Remove DOM elements matching the given [CSS selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors).

```js
const buffer = await browserless.screenshot(url.toString(), {
remove: ['.crisp-client', '#cookies-policy']
})
```

This sets [`display: none`](https://stackoverflow.com/a/133064/64949) on the matched elements, so it could potentially break the website layout.

##### colorScheme

type: `string`</br>
Expand Down
29 changes: 1 addition & 28 deletions packages/goto/src/index.js
Expand Up @@ -92,10 +92,7 @@ const disableAnimations = `
}
`.trim()

const inject = async (
page,
{ timeout, mediaType, animations, hide, remove, modules, scripts, styles }
) => {
const inject = async (page, { timeout, mediaType, animations, modules, scripts, styles }) => {
const postPromises = []

if (mediaType) {
Expand All @@ -118,26 +115,6 @@ const inject = async (
)
}

if (hide) {
postPromises.push(
run({
fn: injectStyle(page, `${castArray(hide).join(', ')} { visibility: hidden !important; }`),
timeout,
debug: 'hide'
})
)
}

if (remove) {
postPromises.push(
run({
fn: injectStyle(page, `${castArray(remove).join(', ')} { display: none !important; }`),
timeout,
debug: 'remove'
})
)
}

if (modules) {
postPromises.push(
run({
Expand Down Expand Up @@ -215,12 +192,10 @@ module.exports = ({
click,
colorScheme,
headers = {},
hide,
html,
javascript = true,
mediaType,
modules,
remove,
scripts,
scroll,
styles,
Expand Down Expand Up @@ -384,8 +359,6 @@ module.exports = ({
timeout: actionTimeout,
mediaType,
animations,
hide,
remove,
modules,
scripts,
styles
Expand Down

0 comments on commit ac85313

Please sign in to comment.