Created
June 29, 2021 16:44
-
-
Save BlueFalconHD/6621415885bc7477860bfba228327dde to your computer and use it in GitHub Desktop.
A widget for scriptable! YoloTerm ✌️
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
/* | |
_| _| _| _|_|_|_|_| | |
_| _| _|_| _| _|_| _| _|_| _| _|_| _|_|_| _|_| | |
_| _| _| _| _| _| _| _|_|_|_| _|_| _| _| _| | |
_| _| _| _| _| _| _| _| _| _| _| _| | |
_| _|_| _| _|_| _| _|_|_| _| _| _| _| | |
Made By: BlueFalconHD | |
*/ | |
// ____ ____ ___ ___ _ _ _ ____ ____ | |
// [__ |___ | | | |\ | | __ [__ | |
// ___] |___ | | | | \| |__] ___] | |
// Social | |
const showGhFollows = true; | |
const githubUsername = 'bluefalconhd'; | |
//Name | |
const name = "Hayes Dombroski"; | |
// . . _ | |
// | | | | |
// |__| | | |
// Overall | |
const padding = [15, 15, 15, 15] | |
// Top, Leading. Bottom, Trailing | |
// Name | |
const nameFontSize = 30; | |
// PX | |
const nameValue = name; | |
// String | |
const nameColor = '#00ffff'; | |
// Hex color | |
// Time | |
const timeFontSize = 15; | |
// PX | |
const timeMilitary = false; | |
// Specifies if time is in military time format. | |
// NOT WORKING | |
const timeColor = '#00ffff' | |
// Hex color | |
// Console Text | |
const csFontSize = 11; | |
// PX | |
const batCalc = Math.round(Device.batteryLevel() * 100); | |
// NOT CONFIG VARIABLE - CALCULATE BATTERY | |
const customText = [ | |
[ | |
'#b5953c', | |
'[💻] OS: IOS 15 DB 2', | |
], | |
[ | |
'#228ce3', | |
'[🔋] Battery: ' + batCalc + '%', | |
], | |
[ | |
'#ffffff', | |
'[📨] Email: [email protected]' | |
] | |
] | |
// each sublist on newline. [[hex color, text]] | |
const outputInConsole = false; | |
// Outputs console text to log. | |
// _ _ ____ _ _ _ ____ ____ ___ ____ | |
// |\/| |__| | |\ | | | | | \ |___ | |
// | | | | | | \| |___ |__| |__/ |___ | |
// BE CAREFUL WHEN EDITING | |
// Fetch Github Follow Count | |
const getUrl = 'https://api.spencerwoo.com/substatsGET?source=github&queryKey=' + githubUsername | |
const request = new Request(getUrl) | |
const res = await request.loadJSON() | |
const out = res.data.subsInEachSource | |
// Output | |
console.warn('Github Follow Count Raw') | |
console.log(res) | |
console.warn('Github Follow Count', 'color: green; font-family: system-ui;') | |
console.log(out.github) | |
const ghfc = out.github | |
// END | |
// Widget | |
let yoloterm = new ListWidget() | |
yoloterm.setPadding(padding[0], padding[1], padding[2], padding[3]) | |
// Make Gradient BG | |
bgColor = new LinearGradient() | |
bgColor.colors = [new Color("#29323c"), new Color("#1c1c1c")] | |
bgColor.locations = [0.0, 1.0] | |
yoloterm.backgroundGradient = bgColor | |
// Add items | |
const title = yoloterm.addText('Title') | |
title.text = nameValue | |
title.font = new Font('menlo-bold', nameFontSize) | |
title.textColor = new Color(nameColor) | |
const time = yoloterm.addDate(new Date()) | |
time.applyTimeStyle() | |
time.font = new Font('menlo-bold', timeFontSize) | |
time.textColor = new Color(timeColor) | |
yoloterm.addSpacer(15) | |
function generateCT() { | |
if (showGhFollows == true) { | |
main = '[📟] Github Followers: ' + ghfc | |
console.log(main) | |
const gh = yoloterm.addText(main) | |
gh.font = new Font('menlo-regular', csFontSize) | |
gh.textColor = new Color('#b5953c') | |
yoloterm.addSpacer(3) | |
} | |
for (let i = 0; i < customText.length; i++) { | |
let color = customText[i][0] | |
let text = customText[i][1] | |
const ctext = yoloterm.addText(text) | |
ctext.font = new Font('menlo-regular', csFontSize) | |
ctext.textColor = new Color(color) | |
yoloterm.addSpacer(3) | |
if (outputInConsole == true) { | |
console.log(text) | |
} | |
} | |
} | |
generateCT() | |
const ws = yoloterm.addStack() | |
console.log('\n---\n') | |
yoloterm.widgetFamily = 'medium' | |
yoloterm.presentMedium() | |
Script.setWidget(yoloterm) | |
console.log('Widget Complete!') | |
Script.complete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment