Last Updated: February 25, 2016
·
590
· 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;
  });

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside