huginn / huginn

Create agents that monitor and act on your behalf. Your agents are standing by!
MIT License
42.4k stars 3.72k forks source link

Feature request - Ability to add JavaScript widgets from tradingview into Digest/Message #2111

Open educatedwarrior opened 6 years ago

educatedwarrior commented 6 years ago

I would like to be able to add a java script widget into a message from a trigger alert. Any suggestions?

Widget Site https://www.tradingview.com/widget/

Sample Widget Code

dsander commented 6 years ago

Hi @educatedwarrior,

do you just want to include the javascript code in the Event emitted by your TriggerAgent? You should be able to but the code in the message option.

educatedwarrior commented 6 years ago

I can't get it to work. When I get the email, java script show the text of the java script instead of what needs to be rendered. I pasted the output below. This is what comes back in the email.

educatedwarrior commented 6 years ago

new TradingView.widget({ "width": 980, "height": 610, "symbol": "NASDAQ:AAPL", "interval": "D", "timezone": "Etc/UTC", "theme": "Light", "style": "1", "locale": "en", "toolbar_bg": "#f1f3f6", "enable_publishing": false, "allow_symbol_change": true, "hideideas": true });

educatedwarrior commented 6 years ago

thought of something. Think I'm missing the escape symbol before double quotes inside the tags.

educatedwarrior commented 6 years ago

Nope, didn't work. I was using Java Script I entered into a credential.

dsander commented 6 years ago

Did you set the content_type option of the EmailAgent to text/html? I can't find any sanitization code that would remove the script tags in our code.

educatedwarrior commented 6 years ago

I tried your suggestion above for content_type and I get the same issue. The JavaScript within the script tag is displayed as text in the message and not interpretted. Here is an example formatted output message.

educatedwarrior commented 6 years ago

image

educatedwarrior commented 6 years ago

I using also tried using javascript from cryptocompare widgets, just to see if there was an issue with trading view widgets. Here is the link for cryptocompare widgets - https://www.cryptocompare.com/dev/widget/wizard/

educatedwarrior commented 6 years ago

I don't think it's a huginn problem so I'm closing this ticket for now.

educatedwarrior commented 6 years ago

It's a huginn issue. Huginn is stripping the script tags from the message output, so then the java script then becomes text in the html.

educatedwarrior commented 6 years ago

I also noticed the & symbol gets replaced with "\&" in the message output.. and this causes an issue with the script running as well. I can run the javascript here https://www.w3schools.com/jquerymobile/tryit.asp?filename=tryjqmob_collapsible and get it to work.