I know how to disable images and plugins, but there doesn't seem to be an apparent option to disable css in CasperJS.
Anyone knows how that works?
Assuming you want to suppress the loading of all external style sheets, you can do it by aborting requests to load css files, which is done by assigning a function to options.onResourceRequested
:
var casper = require('casper').create();
casper.options.onResourceRequested = function(C, requestData, request) {
if ((/https?:\/\/.+?\.css/gi).test(requestData['url']) || requestData['Content-Type'] == 'text/css') {
console.log('Skipping CSS file: ' + requestData['url']);
request.abort();
}
}
To avoid the usage of inline style sheets, my only idea is to use some JavaScript to remove all styles just after the page has loaded.
If you used SlimerJS with CasperJS then there is almost certainly an option in the Gecko engine to disable CSS (based on the fact that the Web Developer plugin has an option).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With