Created
September 17, 2022 22:10
-
-
Save catgirlinspace/a3160b92b491b2d9d9cc65546fc98398 to your computer and use it in GitHub Desktop.
Splatoon 3 Lock Screen Widget
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
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: yellow; icon-glyph: gamepad; | |
const getRuleImageUrl = (rule) => { | |
// reupload images from https://github.com/misenhower/splatoon3.ink/tree/main/src/assets/img/rules | |
// as png to your own host and link below | |
switch (rule) { | |
// Splat Zones | |
case 'AREA': return ""; | |
// Clam Blitz | |
case 'CLAM': return ""; | |
// Rainmaker | |
case 'GOAL': return ""; | |
// Tower Control | |
case 'LOFT': return ""; | |
// Turf War | |
default: return ""; | |
} | |
} | |
const getRuleImage = async (rule) => { | |
const url = getRuleImageUrl(rule) | |
const imageRequest = new Request(url) | |
const image = await imageRequest.loadImage() | |
return image | |
} | |
const widget = new ListWidget() | |
widget.addAccessoryWidgetBackground = false | |
widget.url = "com.nintendo.znca://znca/game/4834290508791808?p=%2Fschedule%2Fbankara" // opens the anarchy schedule | |
const dataRequest = new Request("https://splatoon3.ink/data/schedules.json") | |
const data = (await dataRequest.loadJSON()).data | |
const anarchySchedule = data.bankaraSchedules | |
const now = anarchySchedule.nodes[0] | |
widget.refreshAfterDate = new Date(now.endTime) | |
const series = now.bankaraMatchSettings[0] | |
const open = now.bankaraMatchSettings[1] | |
const seriesStack = widget.addStack() | |
seriesStack.addImage(await getRuleImage(series.vsRule.rule)) | |
const seriesText = seriesStack.addText(`${series.vsStages[0].name}, ${series.vsStages[1].name}`) | |
seriesText.minimumScaleFactor = 0.5 | |
const openStack = widget.addStack() | |
openStack.addImage(await getRuleImage(open.vsRule.rule)) | |
const openText = openStack.addText(`${open.vsStages[0].name}, ${open.vsStages[1].name}`) | |
openText.minimumScaleFactor = 0.5 | |
widget.presentAccessoryRectangular() | |
Script.setWidget(widget) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment