Created
August 2, 2018 23:13
-
-
Save DanNi0130/719445ee113323120b349b2c65c6f944 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const blockedResourceTypes = [ | |
'image', | |
'media', | |
'font', | |
'texttrack', | |
'object', | |
'beacon', | |
'csp_report', | |
'imageset', | |
]; | |
const skippedResources = [ | |
'quantserve', | |
'adzerk', | |
'doubleclick', | |
'adition', | |
'exelator', | |
'sharethrough', | |
'cdn.api.twitter', | |
'google-analytics', | |
'googletagmanager', | |
'google', | |
'fontawesome', | |
'facebook', | |
'analytics', | |
'optimizely', | |
'clicktale', | |
'mixpanel', | |
'zedo', | |
'clicksor', | |
'tiqcdn', | |
]; | |
page.on('request', request => { | |
const requestUrl = request._url.split('?')[0].split('#')[0]; | |
if ( | |
blockedResourceTypes.indexOf(request.resourceType()) !== -1 || | |
skippedResources.some(resource => requestUrl.indexOf(resource) !== -1) | |
) { | |
request.abort(); | |
} else { | |
request.continue(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment