nerdydrew / Random-Pokemon-Generator

Source code for randompokemon.com
https://randompokemon.com
GNU General Public License v2.0
86 stars 29 forks source link

Feature request: Hotlinking a set of parameters #5

Closed mid-kid closed 3 years ago

mid-kid commented 3 years ago

First of all, thanks for this nice website.

In the wild (mostly on 4chan/vp/, but probably other places, too), I see many people using this site in messages like:

https://randompokemon.com/ generate 1 pokemon this pokemon knocks down your door at night. how screwed are you?

(Not an exact quote but messages follow similar formats)

I think it'd be nice if when pressing the "generate" button, you'd get a URL (in your address bar), that when copied and clicked by another party, will prefill the exact same parameters as the other person, allowing you to tweak them before pressing "generate".

This could be implemented as GET parameters, or a base64 string where the fields are bitpacked to keep the URL short. Anything's good.

nerdydrew commented 3 years ago

I just pushed and deployed 865402c—let me know what you think. (You'll need to refresh the page to clear the cached JavaScript.) You can also build the URL manually without specifying every setting, like https://randompokemon.com?n=1.

mid-kid commented 3 years ago

It's perfect. Thanks!

nerdydrew commented 3 years ago

I just added a bonus feature. If you include generate as a URL parameter (no need for a value), it generates on page load. For example, https://randompokemon.com?n=1&generate would generate one Pokémon automatically.