loadurlwithoutcss.js 715 B

1234567891011121314151617181920212223242526
  1. "use strict";
  2. var page = require('webpage').create(),
  3. system = require('system');
  4. if (system.args.length < 2) {
  5. console.log('Usage: loadurlwithoutcss.js URL');
  6. phantom.exit();
  7. }
  8. var address = system.args[1];
  9. page.onResourceRequested = function(requestData, request) {
  10. if ((/http:\/\/.+?\.css/gi).test(requestData['url']) || requestData.headers['Content-Type'] == 'text/css') {
  11. console.log('The url of the request is matching. Aborting: ' + requestData['url']);
  12. request.abort();
  13. }
  14. };
  15. page.open(address, function(status) {
  16. if (status === 'success') {
  17. phantom.exit();
  18. } else {
  19. console.log('Unable to load the address!');
  20. phantom.exit();
  21. }
  22. });