Skip to content

Instantly share code, notes, and snippets.

@hi94740
hi94740 / Scriptable-chainWidget.js
Last active February 17, 2024 11:04
Chainable widget API for Scriptable App.
// Copy the function below to use in your scripts.
function createWidget() {
const widget = new ListWidget()
const wrap = (view, isWidget) => {
let wrapped
const wrapWith = (key, exec) => [key, (...args) => (exec(...args), wrapped)]
wrapped = Object.fromEntries(Object.keys(view).map(key => {
if (typeof view[key] === "function") {
if (key.startsWith("add")) return wrapWith(key, (...args) => {
let cb
@yoav-lavi
yoav-lavi / requests.js
Created April 20, 2019 20:26
request module for Scriptable
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: green; icon-glyph: file-code;
module.exports = {
post: async ({ url, body, headers = {} }) => {
const request = new Request(url);
request.body = JSON.stringify(body);
request.method = methods.post;
request.headers = {
...defaultHeaders,