Hacker News new | ask | show | jobs
by heyplanet 2363 days ago
Is the only reason for the iframe so that it is possible to keep a state in the top frame while loading different pages?

Because otherwise - since you use the dev tools to inject the iframe - you don't really need the iframe. You can just run it as a "snippet" in Chromium or from the multi-line-code-editor in Firefox.

Both have the problem that it all has to be a single file. It would be much nicer if one could import modules.

3 comments

I think having this on a production website means you can crawl the web using your user's CPUs and network connections, making it harder for people to stop you from harvesting their data.
>Both have the problem that it all has to be a single file. It would be much nicer if one could import modules.

Isn't this a solved problem in javascript land? Just use a compiler/minifier and your module oriented js code is in a single file as a build artifact.

Then every time you want to make a change to your code, you have to go to your original codebase, make the change, start the compiler, copy the output and paste it into your dev tools ...
> It would be much nicer if one could import modules.

Is there some reason es modules wouldn't work here? Just a snippet that inserts a tag of type=module

Yes, the reason is that most sites these days serve a content security policy which only allows code from whitelisted origins.