Perchance - Create a Random Text Generator
⚄︎ Perchance
This is a Lemmy Community for perchance.org, a platform for sharing and creating random text generators.
Feel free to ask for help, share your generators, and start friendly discussions at your leisure :)
This community is mainly for discussions between those who are building generators. For discussions about using generators, especially the popular AI ones, the community-led Casual Perchance forum is likely a more appropriate venue.
See this post for the Complete Guide to Posting Here on the Community!
Rules
1. Please follow the Lemmy.World instance rules.
- The full rules are posted here: (https://legal.lemmy.world/)
- User Rules: (https://legal.lemmy.world/fair-use/)
2. Be kind and friendly.
- Please be kind to others on this community (and also in general), and remember that for many people Perchance is their first experience with coding. We have members for whom English is not their first language, so please be take that into account too :)
3. Be thankful to those who try to help you.
- If you ask a question and someone has made a effort to help you out, please remember to be thankful! Even if they don't manage to help you solve your problem - remember that they're spending time out of their day to try to help a stranger :)
4. Only post about stuff related to perchance.
- Please only post about perchance related stuff like generators on it, bugs, and the site.
5. Refrain from requesting Prompts for the AI Tools.
- We would like to ask to refrain from posting here needing help specifically with prompting/achieving certain results with the AI plugins (
text-to-image-plugin
andai-text-plugin
) e.g. "What is the good prompt for X?", "How to achieve X with Y generator?" - See Perchance AI FAQ for FAQ about the AI tools.
- You can ask for help with prompting at the 'sister' community Casual Perchance, which is for more casual discussions.
- We will still be helping/answering questions about the plugins as long as it is related to building generators with them.
6. Search through the Community Before Posting.
- Please Search through the Community Posts here (and on Reddit) before posting to see if what you will post has similar post/already been posted.
view the rest of the comments
Allowing general-purpose cross-domain access like this is not possible, since it would allow very easy login credential stealing, and stuff like that, but these particular things that you've mentioned are good suggestions.
RE gallery button: You're talking about the "send to gallery" and the "open gallery" buttons in the menu after clicking the heart button, right? Would something like this work?
I have needed
history.replaceState
before myself, but haven't gotten around to properly thinking about it. I think it should be fine to allow a generator to change the query parameters and hash (i.e. everything other than the pathname - since otherwise could 'spoof' other generators/pages). Can you let me know your specific use case to help me triangulate on a good approach here? Do you specifically need pushState? Or will replaceState do? I'm reluctant to add pushState because it can be used ~maliciously - like the spammy sites that effectively hijack your back button to prevent you from leaving the page (or at least, make it require an extra click or two).Ah yeah, I thought there'd be other repercussions. Maybe just somehow injecting in certain object so they can work? Or something? Yeah, only allow changing hash and params. That should be fine.
Assuming replaceState is just changing the current entry in history, yeah that's totally fine. But as it's going to be different to that in some ways anyway, you could build in your own property with getter/setter perhaps. Like...
May require messages or whatever.
We can currently read hash, but set it only on our own iframe. And we can read params, but with potentially other added stuff like for the preview iframe.
What I've done for now is, when the user clicks a button it clicks a hidden link which is then (presumably) caught by perchance, and changes the top-level page.
Speaking of which, by the way... it seems going to perchance.org/generator#anchor works. But if you click a link within the generator going to #anchor it loads up /welcome#anchor instead? At the moment I've got some code that catches and handles clicks on such links so it just scrolls there correctly. But just a heads up, as it seems some of this stuff is implemented and working, but not fully and not all aspects.
Thanks!
I've hackily fixed
<a href="#foo">foo</a>
clicks so they work properly now.I've also added a fix so if you visit perchance.org/whatever#foo it'll correctly try to scroll to the
id="foo"
element if it exists: https://perchance.org/dkp9npcidc#foo - pinging @[email protected]You can also type a hash into the address bar of an already loaded page and press enter, and it'll scroll to the element, like a normal top-level page does.
I've also fixed
history.replaceState
so you can now change the query string of the top-level frame as shown below. It'll throw an error if you try to change the pathname, since that could allow for malicious 'spoofing' of other generators as mentioned above.window.location.hash = "#foo"
(you can also do this withreplaceState
IIUC).document.title = "foo";
and it'll propagate to the top-level frame.<link rel="icon" href="https://exampe.com/image.png">
to<head>
) and it'll propagate to the top-level frame.Let me know if you find any bugs 👍
And I've added a
hideGalleryButtons
to the text to image plugin.