Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
AutumnVN committed Oct 31, 2024
0 parents commit 6f9ea51
Show file tree
Hide file tree
Showing 32 changed files with 2,673 additions and 0 deletions.
1 change: 1 addition & 0 deletions .well-known/discord
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dh=1f526289182e6f75ac4606f01aa656ae9b2a14a2
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions _headers
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/
Link: </index.css>; rel=preload; as=style; type=text/css, </bg.avif>; rel=preload; as=image; type=image/avif, </avatar.avif>; rel=preload; as=image; type=image/avif, </count>; rel=preload; as=image; type=image/svg+xml, </index.js>; rel=preload; as=script; type=application/javascript, </min.js>; rel=preload; as=script; type=application/javascript, </font.woff2>; rel=preload; as=font; type=font/woff2; crossorigin, </stats>; rel=preload; as=fetch; type=application/json; crossorigin
23 changes: 23 additions & 0 deletions _redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/akatsuki https://akatsuki.gg/u/102756 301
/anilist https://anilist.co/user/AutumnVN 301
/bsky https://bsky.app/profile/chino.id.vn 301
/bot https://discord.com/oauth2/authorize?client_id=833707580593143841&permissions=8&scope=bot 301
/codeberg https://codeberg.org/AutumnVN 301
/crowdin https://crowdin.com/profile/AutumnVN 301
/discord https://discord.com/users/393694671383166998 301
/dm https://discord.com/users/393694671383166998 301
/facebook https://www.facebook.com/autumnvnchino 301
/genshin https://enka.network/u/829753707 301
/github https://github.com/AutumnVN 301
/lastfm https://www.last.fm/user/AutumnVN 301
/osu https://osu.ppy.sh/users/26086345 301
/pixiv https://www.pixiv.net/users/54279342 301
/reddit https://www.reddit.com/user/AutumnVN 301
/rickroll https://www.youtube.com/watch?v=dQw4w9WgXcQ 301
/ripple https://ripple.moe/u/128582 301
/spotify https://open.spotify.com/user/31x3ktny3mzvdu5kob47r6oceyiq 301
/steam https://steamcommunity.com/id/AutumnVN 301
/twitch https://www.twitch.tv/autumnvn 301
/twitter https://twitter.com/autumnvnchino 301
/youtube https://www.youtube.com/@AutumnVN 301
/wysi https://www.youtube.com/watch?v=AaAF51Gwbxo&t=62s 301
1 change: 1 addition & 0 deletions autumnvn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added avatar.avif
Binary file not shown.
Binary file added bg.avif
Binary file not shown.
Binary file added favicon.ico
Binary file not shown.
Binary file added font.woff2
Binary file not shown.
9 changes: 9 additions & 0 deletions functions/chino.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export async function onRequestGet() {
const max = 267;
return new Response(await fetch(`https://raw.githubusercontent.com/AutumnVN/chino.webp/main/${Math.ceil(Math.random() * max)}.webp`).then(r => r.blob()), {
headers: {
'content-type': 'image/webp',
'cache-control': 'no-cache, no-store, must-revalidate, max-age=0'
}
});
}
25 changes: 25 additions & 0 deletions functions/count.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
export async function onRequestGet({ env, waitUntil }) {
const value = + await env.COUNT.get('count') + 1 || 1;

waitUntil(env.COUNT.put('count', value));

return new Response(generateSvg(String(value).padStart(7, '0')), {
headers: {
'content-type': 'image/svg+xml',
'cache-control': 'no-cache, no-store, must-revalidate, max-age=0'
}
});
}

function generateSvg(str) {
const font = 24;
const size = 29;
const margin = 32;
let text = '';

for (let i = 0; i < str.length; i++) {
text += `<rect x="${i * margin}" y="0.5"/><text><tspan x="${i * margin + 7}" y="22">${str[i]}</tspan></text>`;
}

return `<svg xmlns="http://www.w3.org/2000/svg" width="${margin * str.length}" height="30"><style>rect {fill: #000;width: ${size}px;height: ${size}px;}text {font: ${font}px Courier;fill: #0f1;}</style><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">${text}</g></svg>`;
}
65 changes: 65 additions & 0 deletions functions/fetchanilist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
export async function onRequestGet({ request, waitUntil }) {
let res = await caches.default.match(request.url);

if (res) {
res = await res.json();
waitUntil(fetchData().then(r => caches.default.put(request.url, new Response(JSON.stringify(r), {
headers: {
'content-type': 'application/json',
'cache-control': 'public, max-age=86400'
}
}))));
} else {
res = await fetchData();
waitUntil(caches.default.put(request.url, new Response(JSON.stringify(res), {
headers: {
'content-type': 'application/json',
'cache-control': 'public, max-age=86400'
}
})));
}

return new Response(JSON.stringify(res), {
headers: {
'content-type': 'application/json',
'cache-control': 'no-cache, no-store, must-revalidate, max-age=0'
}
});
}

async function fetchData() {
const query = `query {
Page(page: 1, perPage: 4) {
activities(userId: 6851565, sort: ID_DESC) {
... on ListActivity {
createdAt
status
progress
media {
coverImage {
medium
}
title {
userPreferred
}
siteUrl
}
}
}
}
}`;

const { data } = await fetch('https://graphql.anilist.co', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ query })
}).then(r => r.json());

return data.Page.activities.map(i => ([
i.media.siteUrl,
i.media.coverImage.medium,
`${i.status} ${i.progress}`,
i.media.title.userPreferred,
i.createdAt
]));
}
93 changes: 93 additions & 0 deletions functions/fetchgithub.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
export async function onRequestGet({ env, request, waitUntil }) {
let res = await caches.default.match(request.url);

if (res) {
res = await res.json();
waitUntil(fetchData(env).then(r => caches.default.put(request.url, new Response(JSON.stringify(r), {
headers: {
'content-type': 'application/json',
'cache-control': 'public, max-age=86400'
}
}))));
} else {
res = await fetchData(env);
waitUntil(caches.default.put(request.url, new Response(JSON.stringify(res), {
headers: {
'content-type': 'application/json',
'cache-control': 'public, max-age=86400'
}
})));
}

return new Response(JSON.stringify(res), {
headers: {
'content-type': 'application/json',
'cache-control': 'no-cache, no-store, must-revalidate, max-age=0'
}
});
}

async function fetchData(env) {
const query = `{
a: repository(owner: "AutumnVN", name: "chino.pages.dev") { stargazers { totalCount } forks { totalCount } }
b: repository(owner: "AutumnVN", name: "autumn") { stargazers { totalCount } forks { totalCount } }
c: repository(owner: "AutumnVN", name: "highlight") { stargazers { totalCount } forks { totalCount } }
d: repository(owner: "AutumnVN", name: "osu-igdl") { stargazers { totalCount } forks { totalCount } }
e: repository(owner: "AutumnVN", name: "osu-mpbd") { stargazers { totalCount } forks { totalCount } }
f: repository(owner: "AutumnVN", name: "osu-ubu") { stargazers { totalCount } forks { totalCount } }
g: repository(owner: "AutumnVN", name: "bot") { stargazers { totalCount } forks { totalCount } }
h: repository(owner: "Vendicated", name: "Vencord") { stargazers { totalCount } forks { totalCount } }
z: user(login: "AutumnVN") {
repositories(first: 100, ownerAffiliations: OWNER) {
nodes {
stargazerCount
forkCount
}
}
contributionsCollection {
totalCommitContributions
}
pullRequests(first: 1) {
totalCount
}
issues(first: 1) {
totalCount
}
repositoriesContributedTo(first: 1, contributionTypes: [COMMIT, ISSUE, PULL_REQUEST, REPOSITORY]) {
totalCount
}
}
}`;

const { data } = await fetch('https://api.github.com/graphql', {
method: 'POST',
headers: {
'accept': 'application/json',
'authorization': `bearer ${env.GITHUB_TOKEN}`,
'user-agent': ''
},
body: JSON.stringify({ query })
}).then(r => r.json());

const repos = Object.values(data);
const stats = repos.pop();

const statsArr = [
stats.repositories.nodes.reduce((a, b) => a + b.stargazerCount, 0),
stats.repositories.nodes.reduce((a, b) => a + b.forkCount, 0),
stats.contributionsCollection.totalCommitContributions,
stats.pullRequests.totalCount,
stats.issues.totalCount,
stats.repositoriesContributedTo.totalCount
];

const res = repos.map(i => ([
i.stargazers.totalCount,
i.forks.totalCount
]));

res.push(statsArr);

return res;
}
38 changes: 38 additions & 0 deletions functions/fetchlanyard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
export async function onRequestGet({ request, waitUntil }) {
let res = await caches.default.match(request.url);

if (res) {
res = await res.json();
waitUntil(fetchData().then(r => caches.default.put(request.url, new Response(JSON.stringify(r), {
headers: {
'content-type': 'application/json',
'cache-control': 'public, max-age=86400'
}
}))));
} else {
res = await fetchData();
waitUntil(caches.default.put(request.url, new Response(JSON.stringify(res), {
headers: {
'content-type': 'application/json',
'cache-control': 'public, max-age=86400'
}
})));
}

return new Response(JSON.stringify(res), {
headers: {
'content-type': 'application/json',
'cache-control': 'no-cache, no-store, must-revalidate, max-age=0'
}
});
}

async function fetchData() {
const { data } = await fetch('https://api.lanyard.rest/v1/users/393694671383166998').then(r => r.json());

return {
discord_user: data.discord_user,
discord_status: data.discord_status,
activities: data.activities
}
}
35 changes: 35 additions & 0 deletions functions/lanyard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
export async function onRequestGet({ env, waitUntil }) {
const value = Number((await env.COUNT.get('count')) || 0) + 1;

const originSvg = await fetch('https://lanyard.cnrad.dev/api/393694671383166998?showDisplayName=true&bg=0d1117&idleMessage=https://chino.pages.dev').then(r => r.text());

const newSvg = originSvg.replace(/( width=")410((px)?" )/g, '$1350$2')
.replace(/width: 400px;/g, 'width: 340px;')
.replace(/width: 279px;/, 'width: 219px;')
.replace(/border: solid 0.5px #222;/, '$& object-fit: cover;')
.replace(/height="210px">/, 'height="265px">')
.replace(/<\/svg>/, generateCountSvg(String(value).padStart(7, '0')) + '$&');

waitUntil(env.COUNT.put('count', value));

return new Response(newSvg, {
headers: {
'content-type': 'image/svg+xml',
'cache-control': 'no-cache, no-store, must-revalidate, max-age=0'
}
});
}

function generateCountSvg(str) {
const y = 215;
const font = 37;
const size = 45;
const margin = 50;
let text = '';

for (let i = 0; i < str.length; i++) {
text += `<rect x="${i * margin}" y="0.5"/><text><tspan x="${i * margin + 11}" y="34">${str[i]}</tspan></text>`;
}

return `<g transform="translate(0,${y})"><style>rect {fill: #0d1117;width: ${size}px;height: ${size}px;}text {font: ${font}px Courier;fill: #0f1;}</style><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">${text}</g></g>`;
}
24 changes: 24 additions & 0 deletions functions/osuapiv2/[[osuapiv2]].js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
export async function onRequestGet({ env, request }) {
const { access_token } = await fetch('https://osu.ppy.sh/oauth/token', {
method: 'POST',
headers: {
'accept': 'application/json',
'content-Type': 'application/x-www-form-urlencoded',
},
body: `client_id=23616&client_secret=${env.OSU_CLIENT_SECRET}&grant_type=client_credentials&scope=public`
}).then(res => res.json());

const response = await fetch(`https://osu.ppy.sh/api/v2/${request.url.replace(/^.+?osuapiv2\//, '')}`, {
headers: {
'accept': 'application/json',
'content-type': 'application/json',
'authorization': `Bearer ${access_token}`
},
body: request.body
});

return new Response(await response.text(), {
status: response.status,
headers: response.headers
});
}
Loading

0 comments on commit 6f9ea51

Please sign in to comment.