Tuesday, November 19, 2019
  • Index
  •  » Automator
  •  » how to input an html document in javascript action in automator

#1 2019-09-25 02:07:52 am

jaladuvar
Member
Registered: 2008-12-06
Posts: 16

how to input an html document in javascript action in automator

Hello,
I'm trying to create an automator action  that records and process a web page through :
first a web archive ( the page is a bank statement, that I can see on my screen, but cannot record directly )
then extract the html page from the archive ( via textutil ) which is the Apple converted form
then extract parts of the web page through a series of javascript functions like
var xyz =   document.getElements..textContent and process these further to format them etc...
I can reach the state where I can have the "local" web page opened in Safari, but I cannot go any further
I've tested the javascript script outside automator and it is working but I cannot find the way to get the correct input parameter that will enable the var xyz =   document.getElements..textContent functions in the run javascript action in automator ?
How could I pass the html file as a DOM element ?
I cannot use Applescript because I want as much of my actions and codes to be usable in iOS devices as well (Shortcuts) and there I cannot use AppleScript..

Thank you for any help, I've been searching this for months now..

Model: MacBook Pro 13"
Browser: Safari 537.36
Operating System: macOS 10.14

Offline

 

#2 2019-09-28 02:21:27 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 712

Re: how to input an html document in javascript action in automator

jaladuvar wrote:


How could I pass the html file as a DOM element ?



I think, you can do something that:

put at the end line of your JavaScript

myHTML=blablabla;

then, perform this in AppleScript:

Applescript:

set mHTML to do JavaScript "YourJavaScriptText"

Last edited by KniazidisR (2019-09-28 02:22:18 am)


Model: MacBook Pro
macOS Mojave -- version 10.14.4
Safari -- version 12.1
Firefox -- version 70.0

Offline

 

#3 2019-10-01 12:47:12 am

jaladuvar
Member
Registered: 2008-12-06
Posts: 16

Re: how to input an html document in javascript action in automator

Thanks for the indication, but I would like to avoid  using Applescript altogether

I don't know how to tell automator to run a "browser" javascript in an html file with the automator action "Run Javascript", if it makes sense at all ?
The corresponding "Shortcuts" action works with safari pages as input...

Offline

 

#4 2019-10-01 06:03:57 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6034

Re: how to input an html document in javascript action in automator

jaladuvar wrote:

I don't know how to tell automator to run a "browser" javascript in an html file with the automator action "Run Javascript", if it makes sense at all ?



The Run JavaScript action is for running JXA, or JavaScript for Applications, code. JXA is like AppleScript written in JavaScript. It's not for direct browser scripting.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#5 2019-10-01 09:36:08 am

jaladuvar
Member
Registered: 2008-12-06
Posts: 16

Re: how to input an html document in javascript action in automator

Thank you very much for clarifying this...
My "dream" of using the same javascript script in automator and shortcuts goes away...
I'll have to do with this...

Offline

 
  • Index
  •  » Automator
  •  » how to input an html document in javascript action in automator

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)