├── LICENSE ├── README.md ├── img └── logo.png └── snippets ├── SFSymbol.js ├── date.js ├── dateManipulation.js ├── dynamicmode.js ├── encoding.js ├── httprequest.js └── parameter.js /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Nico Wickersheim 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Scriptable Hub 4 | > Code snippets, examples and links for all your Scriptable development 5 | 6 | ## Code Snippets 7 | - Direct way to all snippets: https://github.com/wickenico/scriptable-hub/tree/main/snippets 8 | 9 | ## Scriptables 10 | - Bitcoin-USD-Course: https://github.com/wickenico/btc-usd-course.js 11 | - Country Information: https://github.com/wickenico/country-information.js 12 | - Crypto Ticker: https://github.com/wickenico/crypto-ticker-widget.js 13 | - Exchange Rates: https://github.com/wickenico/exchange-rates.js 14 | - Random Meme: https://github.com/wickenico/random-meme.js 15 | - Stock Widget: https://github.com/wickenico/stock-widget.js 16 | 17 | ## Useful links 18 | - Subreddit: https://www.reddit.com/r/Scriptable/ 19 | - Documentation: https://docs.scriptable.app 20 | - Twitter: https://twitter.com/scriptableapp 21 | - Scriptdude: https://scriptdu.de 22 | - Widget Hub: https://widget-hub.app 23 | 24 | ## Want to Contribute? 25 | - Use the issue tab to suggest new snippets 26 | -------------------------------------------------------------------------------- /img/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wickenico/scriptable-hub/761f5bf1f055f71b62e0d35e2ac207a07a044104/img/logo.png -------------------------------------------------------------------------------- /snippets/SFSymbol.js: -------------------------------------------------------------------------------- 1 | //Create Widget 2 | const widget = new ListWidget() 3 | 4 | //Get bolt SF Symbol 5 | let sf = SFSymbol.named("bolt") 6 | 7 | //Add SF Symbol to widget 8 | let widgetImage = widget.addImage(sf.image) 9 | 10 | //Change colour of SF Symbol 11 | widgetImage.tintColor = Color.red() -------------------------------------------------------------------------------- /snippets/date.js: -------------------------------------------------------------------------------- 1 | // Write today's date in variable 2 | let currentDate = new Date(); 3 | 4 | // Add date to widget ui 5 | let lastDate = w.addDate(currentDate); -------------------------------------------------------------------------------- /snippets/dateManipulation.js: -------------------------------------------------------------------------------- 1 | let date = new Date() 2 | date.setHours(date.getMinutes() + 30) -------------------------------------------------------------------------------- /snippets/dynamicmode.js: -------------------------------------------------------------------------------- 1 | // Define a color for day and night 2 | let lightColor = Color.black(); 3 | let darkColor = Color.white(); 4 | 5 | // With Color.dynamic you set the colors for day and night based on the settings of your phone 6 | example.textColor = Color.dynamic(lightColor, darkColor); -------------------------------------------------------------------------------- /snippets/encoding.js: -------------------------------------------------------------------------------- 1 | let url = "https://scriptable.app/assets/appicon.png" 2 | let req = new Request(url) 3 | let image = await req.loadImage() 4 | 5 | let base = Data.fromPNG(image).toBase64String() 6 | 7 | let decodedImage = Image.fromData(Data.fromBase64String(base)) -------------------------------------------------------------------------------- /snippets/httprequest.js: -------------------------------------------------------------------------------- 1 | // Define variable with the url 2 | const url = 'https://example.com' 3 | 4 | // Execute the request 5 | const req = new Request(url); 6 | 7 | // Write the json response to variable res 8 | const res = await req.loadJSON(); -------------------------------------------------------------------------------- /snippets/parameter.js: -------------------------------------------------------------------------------- 1 | let params = null; 2 | 3 | // No parameter are given by input 4 | if (args.widgetParameter == null) { 5 | params = ["p1", "p2", "p3"]; // Default input without parameters 6 | } else { 7 | // Separate input parameters at , 8 | // example input: dog, cat, mouse 9 | params = args.widgetParameter.split(",") 10 | } 11 | 12 | // result: 13 | // params[0] = dog 14 | // params[1] = cat 15 | // params[2] = mouse 16 | --------------------------------------------------------------------------------