-
-
Save Yash-Singh1/6198c27acb6966b290ba2024c0e45e38 to your computer and use it in GitHub Desktop.
Extract source code & directories from the javascript .map files (modified to support maps with sections)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Created by PhpStorm. | |
* User: edwinsturt | |
* Date: 2020-06-24 | |
* Time: 00:45 | |
*/ | |
$file = 'main.js.map'; | |
if(file_exists($file)) { | |
$json = json_decode(file_get_contents($file)); | |
foreach ($json->sections as $index => $section) { | |
$directories = []; | |
foreach ($section->map->sources as $index => $source) { | |
$dir = dirname($source); | |
if (!is_dir($dir)) { | |
mkdir($dir, 0755, true); | |
} | |
$data = explode('/', $source); | |
$file = end($data); | |
file_put_contents($dir . "/" . $file, $section->map->sourcesContent[$index]); | |
$files[] = $dir . "/" . $file; | |
} | |
echo "<pre>All Source codes has been extracted from map file "; | |
print_r($files); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment