Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
🍋 TermiWidget - Terminal-like Widget for iOS 14, made with Scriptable.
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: orange; icon-glyph: quote-right;
// Change these to your usernames!
const user = "spencer"
const jike = "4DDA0425-FB41-4188-89E4-952CA15E3C5E"
const telegram = "realSpencerWoo"
const github = "spencerwooo"
const sspai = "spencerwoo"
const data = await fetchData()
const widget = createWidget(data)
Script.setWidget(widget)
Script.complete()
function createWidget(data) {
console.log(data)
const w = new ListWidget()
const bgColor = new LinearGradient()
bgColor.colors = [new Color("#29323c"), new Color("#1c1c1c")]
bgColor.locations = [0.0, 1.0]
w.backgroundGradient = bgColor
w.setPadding(12, 15, 15, 12)
w.spacing = 6
const time = new Date()
const dfTime = new DateFormatter()
dfTime.locale = "en"
dfTime.useMediumDateStyle()
dfTime.useNoTimeStyle()
const firstLine = w.addText(`[] ${user} ~$ now`)
firstLine.textColor = Color.white()
firstLine.textOpacity = 0.7
firstLine.font = new Font("Menlo", 11)
const timeLine = w.addText(`[🗓] ${dfTime.string(time)}`)
timeLine.textColor = Color.white()
timeLine.font = new Font("Menlo", 11)
const batteryLine = w.addText(`[🔋] ${renderBattery()}`)
batteryLine.textColor = new Color("#6ef2ae")
batteryLine.font = new Font("Menlo", 11)
const jikeLine = w.addText(`[🍋] Jike: ${data.jikeFollower}`)
jikeLine.textColor = new Color("#ffcc66")
jikeLine.font = new Font("Menlo", 11)
const telegramLine = w.addText(`[️️] Telegram: ${data.telegram}`)
telegramLine.textColor = new Color("#7dbbae")
telegramLine.font = new Font("Menlo", 11)
const githubLine = w.addText(`[📟] GitHub: ${data.github}`)
githubLine.textColor = new Color("#ff9468")
githubLine.font = new Font("Menlo", 11)
const sspaiLine = w.addText(`[] SSPAI: ${data.sspai}`)
sspaiLine.textColor = new Color("#ffa7d3")
sspaiLine.font = new Font("Menlo", 11)
return w
}
async function fetchData() {
const url = `https://api.spencerwoo.com/substats/?source=jikeFollower&queryKey=${jike}`
+ `&source=telegram&queryKey=${telegram}`
+ `&source=github&queryKey=${github}`
+ `&source=sspai&queryKey=${sspai}`
const request = new Request(url)
const res = await request.loadJSON()
return res.data.subsInEachSource
}
function renderBattery() {
const batteryLevel = Device.batteryLevel()
const juice = "#".repeat(Math.floor(batteryLevel * 8))
const used = ".".repeat(8 - juice.length)
const batteryAscii = `[${juice}${used}] ${Math.round(batteryLevel * 100)}%`
return batteryAscii
}
@spencerwooo
Copy link
Author

spencerwooo commented Aug 22, 2020

Intro

  • iOS 14 Custom Widget made possible by Scriptable.
  • Shows the current battery level in ascii art.
  • Fetches my subscribers on multiple platforms with the help of my API: spencerwooo/Substats. Supports many platforms, including Telegram Channels, Twitter, Instagram, Reddit (Karma), and major RSS services (Feedly, Inoreader...).

Requirements

Thanks

@eggsy-t
Copy link

eggsy-t commented Sep 22, 2020

能否写一下scriptable软件界面的使用教程呀?

@skyperkloze
Copy link

skyperkloze commented Oct 29, 2020

能否加上step counter 就精彩了?

@dschulz1227
Copy link

dschulz1227 commented Jan 24, 2021

please reply if you are able to assist with this script

@amirsaam
Copy link

amirsaam commented Mar 7, 2022

I have done quite changes and configured it to work with substats api v2 at here https://gist.github.com/amirsaam/e531b5f1662fa8bdd8a024eefa06a728

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment