Jellycuts / Jellycuts-Issues

A public issue tracker for the Jellycuts iOS app.
23 stars 0 forks source link

Run Javascript on Webpage typo and error #68

Closed JdenHartog closed 3 years ago

JdenHartog commented 3 years ago

What action is the issue?

Run Javascript on Webpage

Describe the bug

URL (https://jellycuts.com/documentation/ranjavascriptonwebpage), Syntax and Example all state ranJavascriptOnWebpage instead of runJavascriptOnWebpage.

After correcting this I get the following error: Compilation: Cannot find the variable https://jellycuts in the scope

Steps To Reproduce

import Shortcuts 1092.6 #Color: red, #Icon: shortcuts

runJavascriptOnWebpage(url: https://jellycuts.com, javascript: "console.log('Hello World')")

Information

Additional context

Thanks for building Jellycuts! I just started looking into this and it looks really nice and promising.

ActuallyTaylor commented 3 years ago

Hey, thanks for the feedback!

Script

I just checked out the bug and it seems to be an issue with the code that you supplied. The runJavascriptOnWebPage function excepts a Variable and not a string. Currently, Jellycuts does not automatically create variables for you so you will need to modify your script to this

import Shortcuts 1092.6
#Color: red, #Icon: shortcuts

url("https://jellycuts.com") >> URL
runJavascriptOnWebpage(url: URL, javascript: "console.log('Hello World')")

Documentation

Thank you for the feedback on the misnamed documentation item.

Other

You’re welcome! I‘m happy you enjoy Jellycuts!

JdenHartog commented 3 years ago

Thank you. I got it working!

I would like to propose a few changes to the example at https://jellycuts.com/documentation/runjavascriptonwebpage

  1. Changing url: https://jellycuts.com to url: Shortcut Input as this is the only way Apple allows to run JavaScript on a webpage (I guess this is for security reasons).
  2. Adding completion(); at the end of the JavaScript as this has to be there to make it work.
  3. Changing console.log('Hello World') to document.body.style.backgroundColor = 'yellow'; as the successful execution is much easier to see on an iOS device.
  4. Removing the double quotes " as they will also be in the JavaScript and will stop it from working.

The complete example, I would like to suggest, lokes like this: runJavascriptOnWebpage(url: Shortcut Input, javascript: document.body.style.backgroundColor = 'yellow'; completion();)

P.S. A nice bonus feature would be adding a linefeed after every ; sign, when converting te JellyCut into a shortcut, so each statement gets its own line. Please let me know if you want me to create a new "Feature request issue" for this.

ActuallyTaylor commented 3 years ago

Hey! I have updated the website and documentation to match the changes you proposed. I also fixed the issue with quotations being moved into the final shortcut. If you could make a feature request for the linefeeds that would be awesome! Thank you.

ActuallyTaylor commented 3 years ago

This issue will now be covered in #72