async function loadImage(imgUrl) {
const req = new Request(imgUrl)
return await req.loadImage()
}
async function loadPoints(params) {
const url = https://www.degen.tips/api/airdrop2/season3/points?address=${params}
const req = new Request(url)
req.method = 'GET'
req.headers = { 'Content-Type': 'application/json' }
const res = await req.loadJSON()
return res
}
async function loadAllowance(params) {
const url = https://www.degen.tips/api/airdrop2/tip-allowance?address=${params}
const req = new Request(url)
req.method = 'GET'
req.headers = { 'Content-Type': 'application/json' }
const res = await req.loadJSON()
return res
}
async function update() {
let req = new Request(${urlPath}/versions.json);
let versions = await req.loadJSON();
if (versions.latestVersion > version) {
fileManager = FileManager.iCloud()
documentsDirectory = fileManager.documentsDirectory()
let req = new Request(`${urlPath}/script.js`);
let code = await req.loadString();
let codeToStore = Data.fromString(`// Variables used by Scriptable.\n// These must be at the very top of the file. Do not edit.\n// icon-color: ${color}; icon-glyph: ${icon};\n// Created by: ng\n// Support: @iamng_eth\n\nconst urlPath = '${urlPath}'\nconst icon = '${icon}'\nconst color = '${color}'\n\n${code}`);
let selfFilePath = fileManager.joinPath(documentsDirectory, Script.name() + '.js');
fileManager.write(selfFilePath, codeToStore);
let callback = new CallbackURL("scriptable:///run");
callback.addParameter("scriptName", Script.name());
callback.open();
}
}
function timeUntilReset() {
// Get the current date and time in UTC
const now = new Date();
const nowUtc = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
// Create a Date object for today's reset event at 8:10 AM UTC
const todayResetUtc = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), 8, 10, 0));
// Check if the reset time has already passed for today
let nextResetUtc;
if (nowUtc > todayResetUtc) {
// If the reset time has passed, set the next reset to tomorrow at 8:10 AM UTC
nextResetUtc = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() + 1, 8, 10, 0));
} else {
// If the reset time has not passed, set the next reset to today at 8:10 AM UTC
nextResetUtc = todayResetUtc;
}
// Calculate the time remaining until the next reset in milliseconds
const timeUntilResetMs = nextResetUtc - nowUtc;
// Convert milliseconds to hours, minutes, and seconds
const hours = Math.floor(timeUntilResetMs / (1000 * 60 * 60));
const minutes = Math.floor((timeUntilResetMs % (1000 * 60 * 60)) / (1000 * 60));
// Return the time remaining as a string
return `${hours}h ${minutes}m`;
// Created by: ng // Support: @iamng_eth
const urlPath = 'https://iamng.wtf/scripts/fc-degen/points' const icon = 'user' const color = 'purple'
const version = 7
await update()
const params = args.widgetParameter
const textColor = new Color('#cdd5e0') const lableColor = new Color('#cdd5e0') const green = new Color('#b1e457') const purple = new Color('#c951e7')
const w = new ListWidget() w.backgroundColor = new Color('#161a30')
if (!params) { const errorTxt = w.addText(
Please provide your address
) errorTxt.textColor = Color.red() errorTxt.font = Font.boldRoundedSystemFont(12); } else { const pointsData = await loadPoints(params) const allowanceData = await loadAllowance(params)}
w.url =
https://www.degen.tips/
Script.setWidget(w) Script.complete() w.presentSmall()
async function loadImage(imgUrl) { const req = new Request(imgUrl) return await req.loadImage() }
async function loadPoints(params) { const url =
https://www.degen.tips/api/airdrop2/season3/points?address=${params}
const req = new Request(url) req.method = 'GET' req.headers = { 'Content-Type': 'application/json' } const res = await req.loadJSON()}
async function loadAllowance(params) { const url =
https://www.degen.tips/api/airdrop2/tip-allowance?address=${params}
const req = new Request(url) req.method = 'GET' req.headers = { 'Content-Type': 'application/json' } const res = await req.loadJSON()}
async function update() { let req = new Request(
${urlPath}/versions.json
); let versions = await req.loadJSON(); if (versions.latestVersion > version) { fileManager = FileManager.iCloud() documentsDirectory = fileManager.documentsDirectory()}
function timeUntilReset() { // Get the current date and time in UTC const now = new Date(); const nowUtc = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds());
}