Created
August 22, 2020 00:38
-
-
Save zwithz/c4af5062d346e7c677d35e16dc57de8e to your computer and use it in GitHub Desktop.
A widget to visually show all my social media's followers stats by @scriptable. For more details -> https://twitter.com/zwithz1998/status/1296834411300716544
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use @substats, a open source repo on @Github, to fetch all my social medias' stats | |
const url = "https://api.spencerwoo.com/substats/?source=weibo&queryKey=2028434647&source=twitter&queryKey=zwithz1998&source=jikeFollower&queryKey=e1377acb-40ed-495e-9a73-158273b4090a" | |
const req = new Request(url) | |
const json = await req.loadJSON() | |
const data = json.data.subsInEachSource | |
const twitterFollowers = data.twitter | |
const weiboFollowers = data.weibo | |
// Jike | |
const jikeFollowers = data.jikeFollower | |
if (config.runsInWidget) { | |
let widget = createWidget() | |
Script.setWidget(widget) | |
Script.complete() | |
} | |
function createWidget() { | |
let listWidget = new ListWidget() | |
let backgroundColor = new LinearGradient() | |
backgroundColor.colors = [new Color("a18cd1"), new Color("fbc2eb")] | |
backgroundColor.locations = [0.0, 1] | |
listWidget.backgroundGradient = backgroundColor | |
let emoji = listWidget.addText("📟") | |
emoji.textSize = 37 | |
let title = listWidget.addText("Stats for Nerds") | |
title.applyHeadlineTextStyling() | |
title.textColor = Color.black() | |
addTextToListWidget("Twitter: " + twitterFollowers, listWidget) | |
addTextToListWidget("Weibo: " + weiboFollowers, listWidget) | |
addTextToListWidget("Jike: " + jikeFollowers, listWidget) | |
return listWidget | |
} | |
function addTextToListWidget(text, listWidget) { | |
let item = listWidget.addText(text) | |
item.textColor = Color.black() | |
item.textSize = 14 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment