Last Updated: February 25, 2016
·
377
· founddrama

“Just give me a list of the URLs of all the scripts on this page, OK?”

For those times when you’re not sure of all the things getting loaded on the page, but you need to know those things, and you need some quick and convenient way to just get that damn list.

// Assuming `har` is a HAR document:
// http://www.softwareishard.com/blog/har-12-spec/
// e.g., right-click in Chrome's Network tab and select
// "Copy All as HAR"
har.log.entries.filter(function(it) {
  return /\.js$/.test(it.request.url);
}).map(function(it) {
  return it.request.url;
}).join('\n');

// Although I suppose you could also do this:
Array.prototype.slice.call(
  document.getElementsByTagName('script'))
  .map(function(it) {
    return it.src;
  });