Remove the Page.setBlockedURLs method
This patch removes the Page.setBlockedURLs method. The functionality is trivially implementable with the request interception (see examples/loadurlwithoutcss.js). Fixes #1.
This commit is contained in:
parent
85ecce31f9
commit
5ba6621cde
@ -7,7 +7,6 @@
|
||||
- [browser.version()](#browserversion)
|
||||
- [browser.close()](#browserclose)
|
||||
- [class: Page](#class-page)
|
||||
- [page.setBlockedURLs(patterns)](#pagesetblockedurlspatterns)
|
||||
- [page.addScriptTag(url)](#pageaddscripttagurl)
|
||||
- [page.injectFile(filePath)](#pageinjectfilefilepath)
|
||||
- [page.setInPageCallback(name, callback)](#pagesetinpagecallbackname-callback)
|
||||
@ -75,11 +74,6 @@ browser.newPage().then(page => {
|
||||
```
|
||||
Pages could be closed by `page.close()` method.
|
||||
|
||||
#### page.setBlockedURLs(patterns)
|
||||
|
||||
- `patterns` [<Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
|
||||
- returns: [<Promise>](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise) Promise which resolves when blocked URLs have been successfully set.
|
||||
|
||||
#### page.addScriptTag(url)
|
||||
|
||||
- `url` [<string>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) Url of a script to be added
|
||||
|
@ -25,7 +25,12 @@ var address = process.argv[2];
|
||||
|
||||
var browser = new Browser({headless: false});
|
||||
browser.newPage().then(async page => {
|
||||
await page.setBlockedURLs(['*.css']);
|
||||
page.setRequestInterceptor(request => {
|
||||
if (request.url().endsWith('.css'))
|
||||
request.abort();
|
||||
else
|
||||
request.continue();
|
||||
});
|
||||
var success = await page.navigate(address);
|
||||
if (!success)
|
||||
console.log('Unable to load the address!');
|
||||
|
13
lib/Page.js
13
lib/Page.js
@ -55,8 +55,6 @@ class Page extends EventEmitter {
|
||||
this._sourceURLToPageCallback = new Map();
|
||||
/** @type {!Map<string, !InPageCallback>} */
|
||||
this._scriptIdToPageCallback = new Map();
|
||||
/** @type {!Array<string>} */
|
||||
this._blockedURLs = [];
|
||||
/** @type {?function(!Request)} */
|
||||
this._requestInterceptor = null;
|
||||
|
||||
@ -86,17 +84,6 @@ class Page extends EventEmitter {
|
||||
this._requestInterceptor(request);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {!Array<string>} patterns
|
||||
* @return {!Promise}
|
||||
*/
|
||||
async setBlockedURLs(patterns) {
|
||||
this._blockedURLs = patterns;
|
||||
await this._client.send('Network.setBlockedURLs', {
|
||||
urls: patterns
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} url
|
||||
* @return {!Promise}
|
||||
|
Loading…
Reference in New Issue
Block a user