Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-fill extension id #1

Closed
xsrf opened this issue Nov 24, 2020 · 3 comments
Closed

Auto-fill extension id #1

xsrf opened this issue Nov 24, 2020 · 3 comments

Comments

@xsrf
Copy link

xsrf commented Nov 24, 2020

Hey,
when you add the comment // extension-fixmenu-id to your main.js, EasyEDA will auto-fill the extension id field on install 😉
Simple but useful extension btw. Thanks!

@turbobabr
Copy link
Owner

turbobabr commented Nov 25, 2020

Wow! That's just awesome!

After experimenting with this finding it turned out that EasyEDA performs a brute forced regexp search for extension- + whatever + -id prefix/suffix pair, where whatever is a string to be picked as the id. 🤔

There are some limitations though for that whatever portion:

  • It should be a whole string
  • no dots
  • no dashes
  • no special symbols
  • the length is apparently unlimited

The // extension-whatever-id macro can be put in any place of the javascript file, moreover - it can be part of the code what allows to inject the defined identifier even with obfuscated and post processed code via webpack or any other bundler that strips comments during the bundling process:

image

I'm curious, how did you found out about this easter egg? :)

@xsrf
Copy link
Author

xsrf commented Nov 25, 2020

Well, I already tried to tell you here, but I guess you missed it ;)
https://easyeda.com/forum/topic/Extensions-installation-UX-issues-Getting-rid-of-useless-ExtentionID-field-7e311609a243486683f0baad2fb21f3c

/*
	extension-testone-test
	extension-testtwo-test
	extension-testtwo-test
	extension-testthree-test
*/

Will register testtwo as extension id.

I found this because the extension id was auto-filled when I imported the official example extension (which doesn't work) and I found that the explicit string used as id was only used as parts of the registered commands within the extension.
e.g.

api('createCommand', {
	'extension-svgimport-import' : () => {
        doImport();
	}
});

I thought creating at least one command would be required, but then I tried to verify this by looking at EasyEDAs main minified javascript code and actually (kind of) found the regex used to extract the extension id.

I'm still not sure how they choose the extension id if there are multiple matches. But I think the one that is found most often is used.

@turbobabr
Copy link
Owner

turbobabr commented Nov 25, 2020

Well, I already tried to tell you here, but I guess you missed it ;)

Ugh... the EasyEda's forum(and the whole community as welll) is so broken! I'd never received any notifications about that comment, thus I didn't have a chance to check it. 😕

Anyway, thank you for pointing it out here! Despite the fact that such "easter egg" doesn't sit very well - it works! ¯_(ツ)_/¯

Going to update all of my plugins/extension with this technique :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants