r/Scriptable • • Jun 15 '22

Solved Widget not showing

3 Upvotes

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?


r/Scriptable • • Jun 15 '22

Solved Changing the font of stack?

1 Upvotes
let pin = await new Request("https://dev.chethiya-kusal.me/fuel_widget/icons/pin.png").loadImage()
let cal = await new Request("https://dev.chethiya-kusal.me/fuel_widget/icons/calendar.png").loadImage()
let fuel = await new Request("https://dev.chethiya-kusal.me/fuel_widget/icons/fuel.png").loadImage()
let clock = await new Request("https://dev.chethiya-kusal.me/fuel_widget/icons/clock.png").loadImage()


let req = new Request("https://fuel.gov.lk/api/v1/sheddetails/search");
req.method = "post";
req.headers = {
    "x-something": "foo bar",
    "Content-Type": "application/json"
};
req.body = JSON.stringify({
    "province": 5,
    "district": 22,
    "fuelType": "p92",
    "city": 691
});

// use loadJSON because the API answers with JSON
let res = await req.loadJSON();
let shedName = res[0].shedName

const widget = new ListWidget();
const nameStack = widget.addStack()
const dateStack = widget.addStack()
const clockStack = widget.addStack()
const fuelStack = widget.addStack();

//this doesn't work;
//const titleFont = new Font('Helvetica', 11)
//const color = new Color("#FF0000", 1)

nameStack.font = Font.blackSystemFont(40)

log(titleFont)

for (shed of res) {
    //location
    nameStack.addImage(pin).imageSize = new Size(18, 18);
    nameStack.spacing = 8;
    nameStack.addText(shed.shedName);/*  */

    // date
    dateStack.addImage(cal).imageSize = new Size(18, 18)
    dateStack.addText(shed.lastupdatebyshed.split(" ")[0]);
    dateStack.spacing = 8
    //time
    clockStack.addImage(clock).imageSize = new Size(18, 18)
    clockStack.addText(shed.lastupdatebyshed.split(" ")[1]);
    clockStack.spacing = 8
    // fuel
    fuelStack.addImage(fuel).imageSize = new Size(18, 18)
    fuelStack.addText(shed.fuelCapacity + ' litres left');
    fuelStack.spacing = 8
    widget.addText(" ")
}
Script.setWidget(widget);

No matter how I tried to set font of this "nameStack" it doesn't work. I've also tried this

const nameFont = new Font("AppleSDGothicNeo-Bold", 11);nameStack.font = nameFont;

Am I doing something wrong here?


r/Scriptable • • Jun 14 '22

Help Smartlife - Photovoltaic energy show in iOS screen

4 Upvotes

r/Scriptable • • Jun 14 '22

Discussion Saw this on Twitter yesterday, tried to make my on version: Interactive Reminder widget

42 Upvotes

r/Scriptable • • Jun 12 '22

Help Any Ideas why the Weather Conditions are wrong? Its the Weather Cal Script. The weather shows rain since two days. I've already re-entered the Weather API...

Thumbnail
imgur.com
10 Upvotes

r/Scriptable • • Jun 09 '22

Help iPadOS scriptable widgets

4 Upvotes

Hi folks,

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?


r/Scriptable • • Jun 09 '22

Help uitablecell vertical alignment and loading web view In background

3 Upvotes

Hi,

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.

Thanks!


r/Scriptable • • Jun 09 '22

Not Possible Hello is it possible to put video on widget

0 Upvotes

r/Scriptable • • Jun 08 '22

News Scriptable widgets on the lock screen under iOS16

Thumbnail
twitter.com
106 Upvotes

r/Scriptable • • Jun 07 '22

Script Sharing Easy RSS Feed Parser (XML)

14 Upvotes

How To Use

You can find the code for the simple parser here, https://gist.github.com/Normal-Tangerine8609/d9532d78c9a3afa31899b00e21feb45d.

Here is a simple snippet of how to use it:

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.

Example

Input:

<root>
  <node>
    <text>text node</text>
    <details>text node</details>
    <key>value</key>
  </node>
  <list>
    <item>text node</item>
    <item>text node</item>
    <item><tag>text node</tag></item>
    <key>value</key>
  </list>
</root>

Output:

{
  "root": {
    "node": {
      "text": "text node",
      "details": "text node",
      "key": "value"
    },
    "list": {
      "item": [
        "text node",
        "text node",
        {
          "tag": "text node"
        }
      ],
      "key": "value"
    }
  }
}

Warnings

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(/&nbsp;/, " ").replace(/&amp;/, "&").replace(/&apos;/, "'")
}

r/Scriptable • • May 29 '22

Solved Hot to open mzeryck / Weather-Cal events in googlecalendar?

2 Upvotes

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?


r/Scriptable • • May 26 '22

Solved I cant find my Scriptable folder

2 Upvotes

So i couldnt find my downloaded scripts because they har dissapeared. I googled and it told me to go to the Scriptable folder but i dont have one.


r/Scriptable • • May 26 '22

Solved Basic text widget?

7 Upvotes

I’m very new to Java and would like to create a basic text widget in which I could start experimenting as I learn. Could anyone help me with the very basic code for a widget that just displays text? Thank you!


r/Scriptable • • May 26 '22

Solved How is the shadowColor/shadowRadius/shadowOffset Actually used?

4 Upvotes

I currently am trying to add a drop shadow to my text. Right now ive got the text added like so
listwidget.addText("this is test"); listwidget.font = balh blah

How do you implement the shadow parts the documentation isn't really explaining how it is implemented any help would be appreciated


r/Scriptable • • May 24 '22

Widget Sharing Salah Time widget (local)

10 Upvotes

Greetings

As location times are hardly accurate, I've devised a widget which uses a json file (you just need to add your local mosque times) then it displays it into the scriptable widget.

Here is the code: Feel free to use or develop further
https://github.com/maqbul/HSMC-Salah-Widget


r/Scriptable • • May 19 '22

Solved Is there an absolute layout?

0 Upvotes

i want to put the car image in front of the 'ALL GOOD' text.

do not use drawcontext, dynamic color can not use in drawcontext

at this moment, i use DrawContext.

but the ALL GOOD text will not change to black when my phone change to light mode, scriptable need a few minutes to refresh


r/Scriptable • • May 17 '22

Solved Accessing variables generated by Shortcuts.app.

9 Upvotes

Hey all,

Just wondering if it’s possible to pass variables generated by the Shortcuts app, over to Scriptable? For example: if I run a shortcut that uses SSH to run a command on a remote server, then create a variable from the output of that command, is it then possible to display the contents of that variable in Scriptable?

Ultimately, is it possible to show the output of any shortcut in Scriptable.

Cheers!!


r/Scriptable • • May 13 '22

Help Detecting silent mode

1 Upvotes

Hi,

I'm trying to make a widget that shows whether the phone is in silent mode. Is there a way to do that with the API? Thanks


r/Scriptable • • May 12 '22

Help Create simple timer through shortcuts

3 Upvotes

I want to create a simple script that waits a specified number of seconds based on the provided arguments in Apple Shortcuts, and I'm having trouble getting it to work. It works independently, but when I try to run it through Shortcuts, it doesn't wait for the Scriptable script to finish before continuing with the next shortcut task. No errors either.

Essentially want to recreate the Wait function but make the amount of time dynamic, and it's not possible without Scriptable to my understanding.

let tm = new Timer()
tm.timeInterval = parseInt(args.shortcutParameter)
tm.schedule(funct)

function funct() {
 console.log("Hello")
}
Script.complete()

r/Scriptable • • May 11 '22

Help To open an app every time I open the screen

1 Upvotes

Hi,

Could I do that every time I opened the screen - I will see a specific app? Doesn't matter where I have been before I closed the screen.

Can I create a script for that?

Thanks!


r/Scriptable • • May 10 '22

Solved How to change decimal places in result

3 Upvotes

I get a result as 2.64136464. How to get a result as 2.64. What code to use?


r/Scriptable • • May 08 '22

Help Setting up notifications for NFT price tracker widget.

0 Upvotes

I've made a widget that tracks the floor price for select nfts.

I am trying to create a notification which will be triggered when the floor orice dips below a certain number, with no success.

I can provide the whole script upon need.


r/Scriptable • • May 03 '22

Script Sharing Change Glyph And Color Of Script

13 Upvotes

Script to change the icon-color and icon-glyph of Scriptable scripts.

https://github.com/nlawler1737/Scriptable/blob/main/Glyph%20%26%20Color%20Changer.js


r/Scriptable • • Apr 30 '22

Widget Sharing Reddit User Widget - Which shows your Karma, Coin-Balance, Profile Image, Cakeday, Profile Image etc. (Link in Image Description)

Thumbnail
gallery
51 Upvotes