Here are some examples how a possible solution for specific problems could look like.
Disclaimer: As for all things, there ain't a perfect solution, nor a one fits all.
Copyright (c) 2020 Marc Eichenseher
Good news, this stuff is free for everyone! Since it's released under the MIT you can use it free of charge on your personal or commercial project.
All feedback / bug reports / pull requests are welcome.