Giter Club home page Giter Club logo

dl-webapp-sources's Introduction

Download original source code from public sourcemaps

Get original JavaScript/TypeScript files/project layout:

dl-webapp-sources -o my-react-app \
  https://app.com/chunk1.js https://app.com/chunk2.js.map localChunk.js localMap.js.map ...
  • sanitize output paths / pad relative parents
  • .js arguments
  • .js.map arguments
  • URL arguments
  • filename arguments
  • sourceMappingURL=data:...
  • sourceMappingURL=file:...
  • sourceMappingURL=http...
  • sourceMappingURL=<relativepath>
  • guess sourceMappingURL by adding .map (find sources that Chrome misses)
  • lookup from sourcesContent
  • lookup from sources paths

Installation

npm install -g @llllvvuu/dl-webapp-sources

CLI Usage

Automated crawler may not pass auth, and it may also miss asynchronously loaded JS. But, you can get a list of loaded JS files by manually logging in.

After logging in, paste into the console:

performance
  .getEntriesByType("resource")
  .map(resource => resource.name)
  .filter(name => name.endsWith(".js"))
  .map(name => `"${name}"`)
  .join(" ")

This gives you the CLI args for:

dl-webapp-sources ${JS_URLS} -o ${OUTPUT_DIRECTORY}

If you got anything interesting, go back and click around the app to load all of the chunks (if it's a SPA), and repeat.

Now you can try to add some create-react-app or create-next-app boilerplate to try to get the app to build.

⚠️ Sometimes axios gets 403; I will try to fix this if I have time, but in the meantime you can get around this by manually downloading .js.map from the browser and passing the local filepath into the CLI.

⚠️ Some sites clear the performance timeline, so the performance API won't list all of the JS files. If this happens you can try another method to get the list of JS files.

Library Usage

See the API reference at markdown/dl-webapp-sources.md.

Motivation

I created this solution since neither denands/sourcemapper, tehryanx/sourcemapper, nor paazmaya/shuji accept a list of multiple JS files, which is quite common with chunked webapps.

jonluca/source-map-cloner is a solution for crawling an HTML page.

dl-webapp-sources leaves auth/crawling to the user. It accepts a list of .js or .js.map.

Sometimes it can find sources that Google Chrome misses.

Credits

dl-webapp-sources's People

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.