Skip to content

Commit

Permalink
chore(Deno): keep functions updated (#9335)
Browse files Browse the repository at this point in the history
  • Loading branch information
LitoMore authored Feb 24, 2025
1 parent 20b761f commit fd79819
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 179 deletions.
11 changes: 4 additions & 7 deletions websites/D/Deno/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@
"nl": "Deno is een runtime voor JavaScript en TypeScript die gebaseerd is op de V8 JavaScript-engine en de programmeertaal Rust. Het is gemaakt door Ryan Dahl, de oorspronkelijke bedenker van Node.js, en is gericht op productiviteit."
},
"url": [
"deno.land",
"doc.deno.land",
"deno.com",
"merch.deno.com",
"denostatus.com",
"deno.news"
"docs.deno.com",
"denostatus.com"
],
"version": "1.1.11",
"logo": "https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/logo.png",
"thumbnail": "https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/thumbnail.png",
"logo": "https://litomore.me/images/deno-512.png",
"thumbnail": "https://litomore.me/images/deno-cover.webp",
"color": "#f9f9f9",
"category": "other",
"tags": [
Expand Down
232 changes: 60 additions & 172 deletions websites/D/Deno/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const presence = new Presence({
const browsingTimestamp = Math.floor(Date.now() / 1000)

enum ActivityAssets {
Logo = 'https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/logo.png',
Logo = 'https://litomore.me/images/deno-512.png',
NewsLogo = 'https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/0.png',
MerchLogo = 'https://cdn.rcd.gg/PreMiD/websites/D/Deno/assets/1.png',
}
Expand All @@ -16,202 +16,90 @@ presence.on('UpdateData', async () => {
largeImageKey: ActivityAssets.Logo,
startTimestamp: browsingTimestamp,
}
const { href, hash, hostname, pathname } = document.location
const { href, hostname, pathname } = document.location
const [privacy, buttons] = await Promise.all([
presence.getSetting<boolean>('privacy'),
presence.getSetting<boolean>('buttons'),
])
const search = document.querySelector<HTMLInputElement>('[id="search-input"]')
const pathnameSplit = pathname.split('/')
const args = pathname.split('/')
if (privacy) {
presenceData.largeImageKey = ActivityAssets.Logo
presenceData.details = 'Browsing'
presence.setActivity(presenceData)
return
}
switch (hostname) {
case 'deno.land': {
if (search?.value) {
presenceData.details = 'Searching for'
presenceData.state = search.value
presenceData.smallImageKey = Assets.Search
}
else if (pathname.includes('/manual')) {
presenceData.buttons = [
{
label: 'Read Manual',
url: href,
},
]
presenceData.state = 'Manual'
presenceData.smallImageKey = Assets.Reading
presenceData.smallImageText = 'Reading'
presenceData.details = document.querySelector('[class="anchor"]')?.parentElement?.textContent
}
else {
switch (pathnameSplit[1]) {
case '': {
presenceData.details = 'Viewing homepage'
break
}
case 'blog': {
presenceData.buttons = [
{
label: 'Read Blog',
url: href,
},
]
presenceData.details = 'Reading the blog'
presenceData.smallImageKey = Assets.Reading
presenceData.smallImageText = 'Reading'
break
}
case 'x': {
presenceData.buttons = [
{
label: 'Explore Modules',
url: href,
},
]

if (document.querySelector('[class="text-default"]')) {
presenceData.details = 'Viewing third party module'
presenceData.state = document
.querySelector('title')
?.textContent
?.split('|')[0]
}
else {
presenceData.smallImageKey = Assets.Reading
presenceData.smallImageText = 'Reading'
presenceData.details = 'Reading about third party modules'
}
break
}
}
}
break
if (hostname === 'deno.com') {
presenceData.details = 'Exlporing deno.com'
if (args[1] === '') {
presenceData.details = 'Viewing homepage'
}
case 'doc.deno.land': {
if (args[1] === 'blog') {
presenceData.buttons = [
{
label: 'View Docs',
label: 'View Blog',
url: href,
},
]
presenceData.details = `Viewing ${
!hash ? 'deno' : `${hash.replace('#', '')}'s`
} (${document.querySelector('[class="truncate"]')?.textContent} version)`
break
}
case 'deno.com': {
switch (pathnameSplit[1]) {
case '': {
presenceData.details = 'Viewing homepage'
break
}
case 'blog': {
presenceData.buttons = [
{
label: 'View Blog',
url: href,
},
]
presenceData.smallImageKey = Assets.Reading
presenceData.smallImageText = 'Reading'
if (document.querySelector('article')) {
presenceData.details = 'Reading an article about'
presenceData.state = document.querySelector('article')?.firstElementChild?.textContent
}
else {
presenceData.details = 'Reading the blog'
}
break
}
case 'deploy': {
switch (pathnameSplit[2]) {
case 'subhosting': {
presenceData.buttons = [
{
label: 'View Subhosting',
url: href,
},
]
presenceData.details = 'Viewing the subhosting page'
break
}
case 'docs': {
presenceData.buttons = [
{
label: 'View Docs',
url: href,
},
]
presenceData.smallImageKey = Assets.Reading
presenceData.smallImageText = 'Reading'
presenceData.details = 'Reading an article about'
presenceData.state = document.querySelector('article')?.firstElementChild?.textContent
break
}
case 'pricing': {
presenceData.buttons = [
{
label: 'View Pricing',
url: href,
},
]
presenceData.details = 'Viewing deno\'s pricing'
break
}
case '':
default: {
presenceData.buttons = [
{
label: 'View The Deploy Page',
url: href,
},
]
presenceData.details = 'Viewing the deploy page'
break
}
}
break
}
presenceData.smallImageKey = Assets.Reading
presenceData.smallImageText = 'Reading'
if (document.querySelector('article')) {
presenceData.details = 'Reading an article about'
presenceData.state = document.title
}
else {
presenceData.details = 'Viewing blog posts list'
}
break
}
case 'deno.news': {
presenceData.buttons = [
{
label: 'View The News',
url: href,
},
]
presenceData.largeImageKey = ActivityAssets.NewsLogo
presenceData.details = 'Viewing the news page'
break
}
case 'denostatus.com': {
if (args[1] === 'deploy') {
presenceData.buttons = [
{
label: 'View Deno\'s Status',
label: 'View The Deploy™ Page',
url: href,
},
]
presenceData.details = 'Viewing deno\'s status'
break
presenceData.details = 'Viewing the Deploy™ page'
if (args[2] === 'subhosting') {
presenceData.buttons = [
{
label: 'View Subhosting',
url: href,
},
]
presenceData.details = 'Viewing the subhosting page'
}
if (args[2] === 'pricing') {
presenceData.buttons = [
{
label: 'View Pricing',
url: href,
},
]
presenceData.details = 'Viewing Deploy™\'s pricing'
}
}
case 'merch.deno.com': {
presenceData.largeImageKey = ActivityAssets.MerchLogo
presenceData.buttons = [
{
label: 'View Merge Store',
url: href,
},
]
presenceData.details = 'Viewing deno\'s merch store'
break
}
if (hostname === 'docs.deno.com') {
presenceData.buttons = [
{
label: 'View Documentation',
url: href,
},
]
presenceData.details = 'Exploring Deno\'s documentation'
if (args[1] === '') {
presenceData.details = 'Viewing the documentation homepage'
}
presenceData.details = 'Viewing a documentation'
presenceData.state = document.title
}
if (hostname === 'denostatus.com') {
presenceData.buttons = [
{
label: 'View Deno\'s Status',
url: href,
},
]
presenceData.details = 'Viewing deno\'s status'
}
if (!buttons)
delete presenceData.buttons
Expand Down

0 comments on commit fd79819

Please sign in to comment.