Waboodoo / HTTP-Shortcuts

Android app to create home screen shortcuts that trigger arbitrary HTTP requests
https://http-shortcuts.rmy.ch
MIT License
1.11k stars 110 forks source link

Display modified HTML reponse #438

Open 77-77SP opened 2 months ago

77-77SP commented 2 months ago

I would like to propose a new feature that would make it possible to display modified HTML string. I can be done by adding a new scripting function under User Interaction which would take the modified response or any vaild HTML code as an argument and display it inside the existing response component.

The current alternative use showDialog which isn't the most optimal way since it only displays text and has limited formatting features.

Thank you for your time and for this amazing app <3

Waboodoo commented 2 months ago

Thanks for your request. This is already somewhat possible, albeit a bit of a workaround. Here's what you can try:

  1. Open the shortcut editor (for a regular HTTP shortcut)
  2. In "Response Handling", change "On Success" to "Show a message"
  3. In the "Message" field, insert a placeholder for a static variable (let's call it myCustomResponse)
  4. Click "Display Settings" and on the screen that opens change "Message Type" to "HTML".
  5. Go back to the editor overview screen
  6. Open the Scripting screen and in the "Run on Success" field, enter code that modifies the response in the way you want and then stores the result into your variable. Here's an example:
const input = response.body;
const output = input.toUpperCase(); // your custom logic here
setVariable("myCustomResponse", output);

I know this isn't ideal and definitely quite hidden, but hopefully it solves your issue. I'll see that I can make this easier to use in the future.

77-77SP commented 2 months ago

Thank you from the bottom of my heart. I really appreciate your hard work and support. Works as intended.

One note I would add, for future reference (if anyone else is interested), is that the Display Type in Response Handling should be changed to Fullscreen Window to display HTML correctly.