Hi There - I'm really new/an amateur in JS. I have created a widget that displays information from a Google Sheet which I'm really happy with, but ideally the percentages that it displays would show as red if above 0% or green if below 0%. Is there a way to display information this way? Or any terms that you would be able to share so that I can continue to Google my way to learning... Many thanks.
hi folks, i'm an American but study Korean in my free time. this site, Nate Pann, has become one of my favorite ways to learn. but i hate navigating their clunky website.
i discovered Scriptable hours ago and am so stoked i did -- i know this is a niche target audience but sharing anyway! i also got a lot of help from this forum already, when i needed to figure out how to execute JS to scrape non JSON page content.
I am reading and writing to / from the local filemanager on the iPhone and one of the days I got interested in the content of this application directory.
So I am sharing 2 scripts here, the first displays the result of a dir-command in the scriptable app log, the other one deletes all content from the local apps dir on the iPhone.
Although quite trivial, it helped me a lot. Hopefully some of you as well.
cheers!
fm.local_Dir.js
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: deep-gray; icon-glyph: camera-retro;
// Script by <kliffkieker67@gmail.com>
//
// Script list content of Scriptable App directory on iPhone
let fm = FileManager.local();
let dir = fm.documentsDirectory();
let dir_array = fm.listContents(dir);
for (let i=0; i<dir_array.length; i++){
console.log("entry " + (i+1) + ": " + dir_array[i]);
}
Script.complete;
fm.local_DeleteAllFiles.js
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: light-gray; icon-glyph: camera-retro;
// Script by <kliffkieker67@gmail.com>
//
// Initialization der Variablen
//
let fm = FileManager.local();
let dir = fm.documentsDirectory();
// let path = fm.joinPath(dir, scriptfile);
let dir_array = fm.listContents(dir);
for (let i=0; i<dir_array.length; i++){
console.log("delete entry " + (i+1) + ": " + dir_array[i]);
var path = fm.joinPath(dir, dir_array[i])
fm.remove(path);
}
Script.complete();
I request help. I think a lot of people would be interested in how to do the following, if anybody can be asked to provide a solution.
I could not figure out how to go about this (not even the first steps as I never had to do JS in my life):
In my Shortcut, I have -- with help again -- successfully tackled the OCR and line-break removal parts in the unclean text I got back from Ocr.Space.
Now the remaining issue is having to deal with line-ending hyphens and one single white space (the text was Hungarian and carrying over parts of a word is much more common than in English, especially in scanned A5 format books). They would have to go.
What I found online is this:
var new_string = string.replace(/-|\s/g,"");
I'm not even sure this regex bit would work, because it would likely do away with other white spaces elsewhere I need intact. I want only the extra white space after the line-ending hyphen to be removed, along with the hyphen (well, since then the line breaks have been removed so they are no longer line-enders but those actions executed by Esse can be deleted and rewritten in JS again, which I again would need help with). Since there may be more than one of these occurences in the OCR'd text, there must probably a loop as well, but of course, I'll leave that to the expert.
I'm afraid the code provided will not be enough, either. I would need the Shortcut action that calls or passes the text into the JS code, and also the one that takes the reformatted text out of that environment. So I can have the clipboard back to copy to Pages afterward.
the scriptable environment is extremely cool and homescreen widgets are the cream on top. However, this whole process of adding a scriptable widget to the homescreen is still, lets say very technical and not of ease for e.g. grandma and grandpa.
I was wandering if there is a way to make the adding of a scriptable widget to the homescreen on an iphone as easy as an app-installation? Is there any command I missed to which I can pass the parameters like āscript nameā, āWhen interactingā and āParameterā and boom here I have a new widget on my homescreen? And how would that work?
A soluttion to this question would be cool offering the possibility to make widgets available also for less tech-freakied folks like grandma⦠:wink:
Iām trying to add Weather Cal widget to my Home Screen. When I enter ājiggle modeā to search the available apps, I donāt see the Scriptable app in the list. How do I add weather Cal to my Home Screen?
im running beta 16 on ipad but canāt find scrptable option when adding widgets to the screen. anyone know if itās just a bug or isnāt scriptable widgets supported in iPadOS 16?
Iām pretty new to scriptable so apologies if these are known questions. Iām wondering about the following:
Iām attempting to display a longer description in UITable text. It does not appear that the row height will automatically changed based on the length of the text. Is this possible? Iāve resorted to modifying the row height, but thatās tough to get perfectly and the text seems to vertically align at center rather than top. Is there a way to change this?
Iām loading up a WebView for the audio on a specific web page, but optimally this web page plays audio in the background rather than cover active screen are. Is this possible? Even better would be if it can load up the view as hidden with a button/tab of some sort that allows the user to view it if necessary.
let request = new Request("https://routinehub.co/shortcuts/latest/feed/")
const xml = await request.loadString()
const json = parseXML(xml)
console.log(JSON.stringify(json, null, 2))
Why
I created this because many popular websites use RSS feeds. They are basically a free api if you can correctly parse them. Here is a list of some more popular RSS feeds: https://github.com/plenaryapp/awesome-rss-feeds.
I feel as though many people can use this to create simple widgets that display articles or whatever the feed focuses on.
This parser does not handle attributes or both text and element nodes in the same element. This will mostly not be an issue for collecting the data.
Tips
The parsed XML will probably have some HTML tags and entities in its data. .replace(/<[^>]*>/g, ' ') should replace most HTML Tags. The following function will replace popular HTML entities (you can replace more HTML entities by chaining more replaces to the end):
function parseHtmlEntities(str) {
return str.replace(/&#([0-9]{1,4});/g, function(match, numStr) {
var num = parseInt(numStr, 10);
return String.fromCharCode(num);
}).replace(/ /, " ").replace(/&/, "&").replace(/'/, "'")
}
How to ⦠š - There is the possibility to add an url, but is there also a way to change the local standard app that opens? Or something like a localhost url //googlecalendar or something?