From 4dda0040f4f602d8ad9f579635ce226ba38742b5 Mon Sep 17 00:00:00 2001 From: Timkor Date: Sat, 28 Dec 2019 11:56:26 +0100 Subject: [PATCH 1/5] Support for disabling JavaScript at navigation --- packages/goto/src/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/goto/src/index.js b/packages/goto/src/index.js index 7fe16d65c4..dab3a7ce89 100644 --- a/packages/goto/src/index.js +++ b/packages/goto/src/index.js @@ -56,11 +56,15 @@ module.exports = ({ timeout, ...deviceOpts }) => { const goto = async ( page, - { url, media, adblock = true, headers = {}, waitFor = 0, disableAnimations = true, ...args } + { url, media, adblock = true, headers = {}, waitFor = 0, disableAnimations = true, disableJavaScript = false ...args } ) => { if (adblock) { await engine.enableBlockingInPage(page) } + + if (disableJavaScript) { + await page.setJavaScriptEnabled(!disableJavaScript); + } if (Object.keys(headers).length !== 0) { debug('headers', headers) From a27a7ac2bd5a27d2d68b5cf0642d79a5cb0d0fde Mon Sep 17 00:00:00 2001 From: Timkor Date: Sat, 28 Dec 2019 11:58:22 +0100 Subject: [PATCH 2/5] Remove semicolon --- packages/goto/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/goto/src/index.js b/packages/goto/src/index.js index dab3a7ce89..e40d80fb8c 100644 --- a/packages/goto/src/index.js +++ b/packages/goto/src/index.js @@ -63,7 +63,7 @@ module.exports = ({ timeout, ...deviceOpts }) => { } if (disableJavaScript) { - await page.setJavaScriptEnabled(!disableJavaScript); + await page.setJavaScriptEnabled(!disableJavaScript) } if (Object.keys(headers).length !== 0) { From 59cfd2d02a823475fbad7b0f8688134263ae126a Mon Sep 17 00:00:00 2001 From: Timkor Date: Sat, 28 Dec 2019 12:03:12 +0100 Subject: [PATCH 3/5] Update index.js --- packages/goto/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/goto/src/index.js b/packages/goto/src/index.js index e40d80fb8c..dce99eaa2e 100644 --- a/packages/goto/src/index.js +++ b/packages/goto/src/index.js @@ -56,7 +56,7 @@ module.exports = ({ timeout, ...deviceOpts }) => { const goto = async ( page, - { url, media, adblock = true, headers = {}, waitFor = 0, disableAnimations = true, disableJavaScript = false ...args } + { url, media, adblock = true, headers = {}, waitFor = 0, disableAnimations = true, disableJavaScript = false, ...args } ) => { if (adblock) { await engine.enableBlockingInPage(page) From 517f9c35022d314c31902bc378a7d19865b83ac6 Mon Sep 17 00:00:00 2001 From: Timkor Date: Sat, 28 Dec 2019 12:10:34 +0100 Subject: [PATCH 4/5] Remove `annoying` trailing spaces --- packages/goto/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/goto/src/index.js b/packages/goto/src/index.js index dce99eaa2e..7aca346cf0 100644 --- a/packages/goto/src/index.js +++ b/packages/goto/src/index.js @@ -61,7 +61,7 @@ module.exports = ({ timeout, ...deviceOpts }) => { if (adblock) { await engine.enableBlockingInPage(page) } - + if (disableJavaScript) { await page.setJavaScriptEnabled(!disableJavaScript) } From 71eba3b822db5b0fe20b559dbe419a2cd98f7ddc Mon Sep 17 00:00:00 2001 From: Timkor Date: Sat, 28 Dec 2019 13:50:31 +0100 Subject: [PATCH 5/5] Update index.js --- packages/goto/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/goto/src/index.js b/packages/goto/src/index.js index 7aca346cf0..5e4b0f20b9 100644 --- a/packages/goto/src/index.js +++ b/packages/goto/src/index.js @@ -63,7 +63,7 @@ module.exports = ({ timeout, ...deviceOpts }) => { } if (disableJavaScript) { - await page.setJavaScriptEnabled(!disableJavaScript) + await page.setJavaScriptEnabled(false) } if (Object.keys(headers).length !== 0) {