diff --git a/functions/about/index.js b/functions/about/index.js index 463b901..7325a09 100644 --- a/functions/about/index.js +++ b/functions/about/index.js @@ -1,34 +1,43 @@ export async function onRequest(context) { - const { request } = context; - const pageUrl = request.url; + const { request, env } = context; + const userAgent = request.headers.get('User-Agent') || ''; + const isBot = /discordbot|twitterbot|facebookexternalhit|bingbot|googlebot|slurp|whatsapp|pinterest|slackbot|telegrambot|linkedinbot|mastodon|signal|snapchat|redditbot|skypeuripreview|viberbot|linebot|embedly|quora|outbrain|tumblr|duckduckbot|yandexbot|rogerbot|showyoubot|kakaotalk|naverbot|seznambot|mediapartners|adsbot|petalbot|applebot|ia_archiver/i.test(userAgent); - const metaHtml = ` - - - - - Monochrome Music | About - - + if (isBot) { + const pageUrl = request.url; - - - - - + const metaHtml = ` + + + + + Monochrome Music | About + + - - - - - -

Monochrome Music | About

-

A minimalist music streaming application

- - - `; + + + + + - return new Response(metaHtml, { - headers: { 'content-type': 'text/html;charset=UTF-8' }, - }); + + + + + +

Monochrome Music | About

+

A minimalist music streaming application

+ + + `; + + return new Response(metaHtml, { + headers: { 'content-type': 'text/html;charset=UTF-8' }, + }); + } + + const url = new URL(request.url); + url.pathname = '/'; + return env.ASSETS.fetch(new Request(url, request)); } diff --git a/functions/donate/index.js b/functions/donate/index.js index 93e334b..15053d3 100644 --- a/functions/donate/index.js +++ b/functions/donate/index.js @@ -1,34 +1,43 @@ export async function onRequest(context) { - const { request } = context; - const pageUrl = request.url; + const { request, env } = context; + const userAgent = request.headers.get('User-Agent') || ''; + const isBot = /discordbot|twitterbot|facebookexternalhit|bingbot|googlebot|slurp|whatsapp|pinterest|slackbot|telegrambot|linkedinbot|mastodon|signal|snapchat|redditbot|skypeuripreview|viberbot|linebot|embedly|quora|outbrain|tumblr|duckduckbot|yandexbot|rogerbot|showyoubot|kakaotalk|naverbot|seznambot|mediapartners|adsbot|petalbot|applebot|ia_archiver/i.test(userAgent); - const metaHtml = ` - - - - - Monochrome Music | Donate - - + if (isBot) { + const pageUrl = request.url; - - - - - + const metaHtml = ` + + + + + Monochrome Music | Donate + + - - - - - -

Monochrome Music | Donate

-

A minimalist music streaming application

- - - `; + + + + + - return new Response(metaHtml, { - headers: { 'content-type': 'text/html;charset=UTF-8' }, - }); + + + + + +

Monochrome Music | Donate

+

A minimalist music streaming application

+ + + `; + + return new Response(metaHtml, { + headers: { 'content-type': 'text/html;charset=UTF-8' }, + }); + } + + const url = new URL(request.url); + url.pathname = '/'; + return env.ASSETS.fetch(new Request(url, request)); } diff --git a/functions/library/index.js b/functions/library/index.js index 5ed5c78..aef19e8 100644 --- a/functions/library/index.js +++ b/functions/library/index.js @@ -1,34 +1,43 @@ export async function onRequest(context) { - const { request } = context; - const pageUrl = request.url; + const { request, env } = context; + const userAgent = request.headers.get('User-Agent') || ''; + const isBot = /discordbot|twitterbot|facebookexternalhit|bingbot|googlebot|slurp|whatsapp|pinterest|slackbot|telegrambot|linkedinbot|mastodon|signal|snapchat|redditbot|skypeuripreview|viberbot|linebot|embedly|quora|outbrain|tumblr|duckduckbot|yandexbot|rogerbot|showyoubot|kakaotalk|naverbot|seznambot|mediapartners|adsbot|petalbot|applebot|ia_archiver/i.test(userAgent); - const metaHtml = ` - - - - - Monochrome Music | Library - - + if (isBot) { + const pageUrl = request.url; - - - - - + const metaHtml = ` + + + + + Monochrome Music | Library + + - - - - - -

Monochrome Music | Library

-

A minimalist music streaming application

- - - `; + + + + + - return new Response(metaHtml, { - headers: { 'content-type': 'text/html;charset=UTF-8' }, - }); + + + + + +

Monochrome Music | Library

+

A minimalist music streaming application

+ + + `; + + return new Response(metaHtml, { + headers: { 'content-type': 'text/html;charset=UTF-8' }, + }); + } + + const url = new URL(request.url); + url.pathname = '/'; + return env.ASSETS.fetch(new Request(url, request)); } diff --git a/functions/parties/index.js b/functions/parties/index.js index db05542..8df09c6 100644 --- a/functions/parties/index.js +++ b/functions/parties/index.js @@ -1,34 +1,43 @@ export async function onRequest(context) { - const { request } = context; - const pageUrl = request.url; + const { request, env } = context; + const userAgent = request.headers.get('User-Agent') || ''; + const isBot = /discordbot|twitterbot|facebookexternalhit|bingbot|googlebot|slurp|whatsapp|pinterest|slackbot|telegrambot|linkedinbot|mastodon|signal|snapchat|redditbot|skypeuripreview|viberbot|linebot|embedly|quora|outbrain|tumblr|duckduckbot|yandexbot|rogerbot|showyoubot|kakaotalk|naverbot|seznambot|mediapartners|adsbot|petalbot|applebot|ia_archiver/i.test(userAgent); - const metaHtml = ` - - - - - Monochrome Music | Listening Parties - - + if (isBot) { + const pageUrl = request.url; - - - - - + const metaHtml = ` + + + + + Monochrome Music | Listening Parties + + - - - - - -

Monochrome Music | Listening Parties

-

Listen to music with your friends

- - - `; + + + + + - return new Response(metaHtml, { - headers: { 'content-type': 'text/html;charset=UTF-8' }, - }); + + + + + +

Monochrome Music | Listening Parties

+

Listen to music with your friends

+ + + `; + + return new Response(metaHtml, { + headers: { 'content-type': 'text/html;charset=UTF-8' }, + }); + } + + const url = new URL(request.url); + url.pathname = '/'; + return env.ASSETS.fetch(new Request(url, request)); } diff --git a/functions/recent/index.js b/functions/recent/index.js index 48797cc..09040f1 100644 --- a/functions/recent/index.js +++ b/functions/recent/index.js @@ -1,34 +1,43 @@ export async function onRequest(context) { - const { request } = context; - const pageUrl = request.url; + const { request, env } = context; + const userAgent = request.headers.get('User-Agent') || ''; + const isBot = /discordbot|twitterbot|facebookexternalhit|bingbot|googlebot|slurp|whatsapp|pinterest|slackbot|telegrambot|linkedinbot|mastodon|signal|snapchat|redditbot|skypeuripreview|viberbot|linebot|embedly|quora|outbrain|tumblr|duckduckbot|yandexbot|rogerbot|showyoubot|kakaotalk|naverbot|seznambot|mediapartners|adsbot|petalbot|applebot|ia_archiver/i.test(userAgent); - const metaHtml = ` - - - - - Monochrome Music | Recent - - + if (isBot) { + const pageUrl = request.url; - - - - - + const metaHtml = ` + + + + + Monochrome Music | Recent + + - - - - - -

Monochrome Music | Recent

-

A minimalist music streaming application

- - - `; + + + + + - return new Response(metaHtml, { - headers: { 'content-type': 'text/html;charset=UTF-8' }, - }); + + + + + +

Monochrome Music | Recent

+

A minimalist music streaming application

+ + + `; + + return new Response(metaHtml, { + headers: { 'content-type': 'text/html;charset=UTF-8' }, + }); + } + + const url = new URL(request.url); + url.pathname = '/'; + return env.ASSETS.fetch(new Request(url, request)); } diff --git a/functions/settings/index.js b/functions/settings/index.js index 80a81b3..1ee046b 100644 --- a/functions/settings/index.js +++ b/functions/settings/index.js @@ -1,34 +1,43 @@ export async function onRequest(context) { - const { request } = context; - const pageUrl = request.url; + const { request, env } = context; + const userAgent = request.headers.get('User-Agent') || ''; + const isBot = /discordbot|twitterbot|facebookexternalhit|bingbot|googlebot|slurp|whatsapp|pinterest|slackbot|telegrambot|linkedinbot|mastodon|signal|snapchat|redditbot|skypeuripreview|viberbot|linebot|embedly|quora|outbrain|tumblr|duckduckbot|yandexbot|rogerbot|showyoubot|kakaotalk|naverbot|seznambot|mediapartners|adsbot|petalbot|applebot|ia_archiver/i.test(userAgent); - const metaHtml = ` - - - - - Monochrome Music | Settings - - + if (isBot) { + const pageUrl = request.url; - - - - - + const metaHtml = ` + + + + + Monochrome Music | Settings + + - - - - - -

Monochrome Music | Settings

-

A minimalist music streaming application

- - - `; + + + + + - return new Response(metaHtml, { - headers: { 'content-type': 'text/html;charset=UTF-8' }, - }); + + + + + +

Monochrome Music | Settings

+

A minimalist music streaming application

+ + + `; + + return new Response(metaHtml, { + headers: { 'content-type': 'text/html;charset=UTF-8' }, + }); + } + + const url = new URL(request.url); + url.pathname = '/'; + return env.ASSETS.fetch(new Request(url, request)); }