Hi
Extremely new, and javascript illiterate unfortunately. I’ve had a mate help me thus far but the solution was with jQuery rather than JavaScript which I believe Scriptable requires.
I have a webpage that looks like this,
The relevant source code is this…
<tr><td colspan="5" class="ris_save_buttons_container"><a href="package.php?ac=0xxxx00000000100d028f&id=7483869,7483870,7483871,7483872,7483876,7483875,7483874,7483873&file=6637533,6637534,6637535,6637536,6637540,6637539,6637538,6637537&action=PRINTALL&openwith=GOODREADER" class="ris_button" target="_self">
Open in GoodReader
</a>
<a href="package.php?ac=0xxxx00000000100d028f&id=7483869,7483870,7483871,7483872,7483876,7483875,7483874,7483873&file=6637533,6637534,6637535,6637536,6637540,6637539,6637538,6637537&action=PRINTALL&openwith=BROWSER" class="ris_button" target="_self">
Open in Browser
The jQuery solution for selecting the “open in browser” link was
url = $('a.ris_button:nth-child(2)').attr('href');
window.open(url)
I am trying to write a Scriptable code that will pass back the value of the link behind the “Open with browser” link… I have the below code but I am getting an error - “Error: Expected value of type string but got value of type {any: any}.”
Is anyone able to steer me in the right direction?
Cheers
K
var url = args.shortcutParameter
const webview = new WebView();
await webview.loadURL(url);
var getData =
function runit() {
const url2 = document.querySelector('a.ris_button:nth-child(2)').attr('href');
return (url2);
}
let link = await webview.evaluateJavaScript(getData, false);
Script.setShortcutOutput(link);
Script.complete();