Can I get chrome extension's original source code instead of min.js file??

246 views
Skip to first unread message

taehee kim

unread,
Sep 6, 2023, 10:07:36 AM9/6/23
to Chromium Extensions
Hi, Recently, I can get the source code of chrome extension from my local chrome directory.

But there are only files which name is "min.js".

I think it is not same with original source code. If I am right, any method to get original source code??

Thanks all.

Robbi

unread,
Sep 6, 2023, 11:33:09 AM9/6/23
to Chromium Extensions, taehee kim
you can open a indent the code with various tools that you can find online or integrated in many IDEs,
but you can't separate the flour, eggs and water once the cake is made :-)
it's basically a one-way process

Deco

unread,
Sep 6, 2023, 11:38:02 AM9/6/23
to taehee kim, Chromium Extensions
This is a process called minification - and is done for performance reasons primarily with JS to reduce the parsing required by the client.

To answer the question, you cannot directly use it to infer (readable) source code no, you'll need to manually investigate to infer what it means, and before you ask, yes this is allowed by the CWS.

Cheers,
Deco


--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/723385ce-1a61-4328-9e06-0f710ca89041n%40chromium.org.

taehee kim

unread,
Sep 6, 2023, 2:30:53 PM9/6/23
to Chromium Extensions, Robbi, taehee kim
Thanks, so I think we(those who haven't access to this original code) can't find or see any original source code unless google introduce their original source code publiciely. Am I right? You said this is a one-way process. So google only published their code as a minified form, not their entire code. 

Thanks for answer again.

taehee kim

unread,
Sep 6, 2023, 2:39:35 PM9/6/23
to Chromium Extensions, Deco, Chromium Extensions, taehee kim

Thanks, you said I infer it manually. Yeah, So I think so. I have a following question. I know the process of restoring source code from already compiled source code.

This process is pretty well, but many variable names are so bad to read. I mean, There are so many variables which name is such as "var1", "var2", etc...

I've heard this variable names was good to read before this was compiled. There are unavoidable results if someone wanna restore code from compiled code.

If I beautify this minified source code using IDE or online tools, should I infer even variable names like above example??

I already beautified and saw the some minified source code of chrome extension. but I think those are good to read(I mean, readability is good)

So, I just only infer the specific logic, not even variables.

Am I right? Thanks for answer again.

Robbi

unread,
Sep 6, 2023, 5:09:37 PM9/6/23
to Chromium Extensions, taehee kim, Deco, Chromium Extensions
Another reason code is minified by the developer is to make life a little harder for those who try to understand the logics of the extension.
You can (not so infrequently) see extensions practically cloned from the original ones in the store.
This certainly does not please the rightful owner of the extension and Google does not always "punish" those responsible despite the reports.

On the other hand, I also have to point out cases where the developer complained that his "amazing and unique" extension had been cloned;
Then, when you went to investigate what made their extension so "amazing and unique" you realized that it was nothing more than a digital clock inside the popup...


There are unavoidable results if someone wanna restore code from compiled code.
The code following the minification is not compiled, but only rewritten so that it occupies fewer bytes.

for instance...
function foo(bar) {
if (bar == true)
alert("hi")
}


...could become something like this...
a=b=>b && alert("hi")

...which for many may seem ancient Aramaic while for others they see only poetry :-)

My advice is:
If your purpose is purely didactic and you can't understand "that piece of minified code", write an email to the developer asking for explanations.

Patrick Kettner

unread,
Sep 6, 2023, 6:51:30 PM9/6/23
to Robbi, Chromium Extensions, taehee kim, Deco
If it is your own code, you may want to look into source maps. This will let you continue to publish your own code minified while also being able to read the original code in your tooling.

Reply all
Reply to author
Forward
0 new messages