I'm trying to write a script to leverage the screenshot capability in headless_shell.--I tried the following, using a recent build (I think) of headless_shell (https://hub.docker.com/r/yukinying/chrome-headless/) along with a node library (https://github.com/cyrus-and/chrome-remote-interface) - but looking at my logs it doesn't seem that anything is being actually blocked - either by my explicit addBlockedURL line or in the one inside requestWillBeSent.Any guesses?```const CDP = require('chrome-remote-interface');const fs = require('fs');const blacklistURLs = ['facebook','fullstory','getdrip','segment.com','olark',];CDP(client => {// extract domainsconst { Network, Page } = client;// setup handlersNetwork.addBlockedURL('https://cdn.segment.com/analytics.js/v1/oD9PafeNRrJRbC3NL41R8DgV8SANLDZ9/analytics.min.js');Network.requestWillBeSent(params => {const url = params.request.url;console.log(`-> ${params.requestId} ${url.substring(0, 150)}`);blacklistURLs.some(blacklistedURL => {if (url.indexOf(blacklistedURL) !== -1) {Network.addBlockedURL(url);console.log('BLOCKING', url, '(I hope)');return true;}return false;});});Network.loadingFailed(params => {console.log('*** loadingFailed: ', params.requestId);})Network.loadingFinished(params => {console.log('<-', params.requestId, params.encodedDataLength);})Page.loadEventFired(() => {console.log('loadEventFired!');Page.captureScreenshot().then(v => {let filename = `screenshot-${Date.now()}`;fs.writeFileSync(filename + '.png', v.data, 'base64');console.log(`Image saved as ${filename}.png`);client.close();});});// enable events then start!Promise.all([Network.enable(),Page.enable()]).then(() => {return Page.navigate({ url: 'https://shift.com/cars/san-francisco' });},() => {console.log('REJECT');client.close();});}).on('error', (err) => {console.error('Cannot connect to remote endpoint:', err);});```
You received this message because you are subscribed to the Google Groups "headless-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to headless-dev+unsubscribe@chromium.org.
To post to this group, send email to headle...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/headless-dev/1edffe3b-cf68-4f49-8695-ba51a60f6462%40chromium.org.