diff --git a/src/env.d.ts b/src/env.d.ts index f0140ec..fbea9d2 100644 --- a/src/env.d.ts +++ b/src/env.d.ts @@ -3,4 +3,4 @@ declare const BRANDING_NAME_DISCORD: string; declare const DIRECT_MEDIA_DOMAINS: string; declare const HOST_URL: string; declare const REDIRECT_URL: string; -declare const MOSAIC_DOMAIN_LIST: string; \ No newline at end of file +declare const MOSAIC_DOMAIN_LIST: string; diff --git a/src/fetch.ts b/src/fetch.ts index e4735f8..86c7619 100644 --- a/src/fetch.ts +++ b/src/fetch.ts @@ -1,6 +1,9 @@ import { Constants } from './constants'; -export const fetchUsingGuest = async (status: string, event: FetchEvent): Promise => { +export const fetchUsingGuest = async ( + status: string, + event: FetchEvent +): Promise => { let apiAttempts = 0; let cachedTokenFailed = false; @@ -54,7 +57,7 @@ export const fetchUsingGuest = async (status: string, event: FetchEvent): Promis This can effectively mean virtually unlimited (read) access to Twitter's API, which is very funny. */ - activate = await fetch(guestTokenRequest); + activate = await fetch(guestTokenRequest); } /* Let's grab that guest_token so we can use it */ diff --git a/src/mosaic.ts b/src/mosaic.ts index d3fc66b..250432f 100644 --- a/src/mosaic.ts +++ b/src/mosaic.ts @@ -1,4 +1,4 @@ -import { Constants } from "./constants" +import { Constants } from './constants'; export const handleMosaic = async (mediaList: TweetMedia[]): Promise => { let mosaicDomains = Constants.MOSAIC_DOMAIN_LIST; @@ -8,7 +8,7 @@ export const handleMosaic = async (mediaList: TweetMedia[]): Promise let domain = mosaicDomains[Math.floor(Math.random() * mosaicDomains.length)]; // let response = await fetch(`https://${domain}/ping`); // if (response.status === 200) { - selectedDomain = domain; + selectedDomain = domain; // } else { // mosaicDomains = mosaicDomains.filter(d => d !== domain); // console.log(`${domain} is not available, removing from list`); @@ -20,7 +20,11 @@ export const handleMosaic = async (mediaList: TweetMedia[]): Promise return mediaList[0]; } else { console.log('mediaList', mediaList); - let mosaicMedia = mediaList.map(media => media.media_url_https?.match(/(?<=\/media\/)[a-zA-Z0-9_\-]+(?=[\.\?])/g)?.[0] || ''); + let mosaicMedia = mediaList.map( + media => + media.media_url_https?.match(/(?<=\/media\/)[a-zA-Z0-9_\-]+(?=[\.\?])/g)?.[0] || + '' + ); console.log('mosaicMedia', mosaicMedia); let constructUrl = `https://${selectedDomain}/1`; if (mosaicMedia[0]) { @@ -35,7 +39,7 @@ export const handleMosaic = async (mediaList: TweetMedia[]): Promise if (mosaicMedia[3]) { constructUrl += `/${mosaicMedia[3]}`; } - + return { media_url_https: constructUrl, original_info: { @@ -45,4 +49,4 @@ export const handleMosaic = async (mediaList: TweetMedia[]): Promise type: 'photo' } as TweetMedia; } -} \ No newline at end of file +}; diff --git a/src/server.ts b/src/server.ts index f38ebd5..63b40ad 100644 --- a/src/server.ts +++ b/src/server.ts @@ -5,12 +5,17 @@ import { Strings } from './strings'; const router = Router(); -const statusRequest = async (request: Request, event: FetchEvent, flags: InputFlags = {}) => { +const statusRequest = async ( + request: Request, + event: FetchEvent, + flags: InputFlags = {} +) => { const { handle, id, mediaNumber } = request.params; const url = new URL(request.url); const userAgent = request.headers.get('User-Agent') || ''; - let isBotUA = userAgent.match(/bot|facebook|embed|got|Firefox\/92|curl|wget/gi) !== null; + let isBotUA = + userAgent.match(/bot|facebook|embed|got|Firefox\/92|curl|wget/gi) !== null; if ( url.pathname.match(/\/status(es)?\/\d+\.(mp4|png|jpg)/g) !== null || diff --git a/src/status.ts b/src/status.ts index 04b28a1..098453d 100644 --- a/src/status.ts +++ b/src/status.ts @@ -344,4 +344,4 @@ export const handleStatus = async ( headers: headers.join('') }) }; -}; \ No newline at end of file +}; diff --git a/src/types.d.ts b/src/types.d.ts index 755ff6b..d196cc4 100644 --- a/src/types.d.ts +++ b/src/types.d.ts @@ -13,5 +13,5 @@ interface StatusResponse { interface Request { params: { [param: string]: string; - } -} \ No newline at end of file + }; +} diff --git a/webpack.config.js b/webpack.config.js index 411f834..563806f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -34,7 +34,7 @@ module.exports = { }), new webpack.DefinePlugin({ MOSAIC_DOMAIN_LIST: `'${process.env.MOSAIC_DOMAIN_LIST}'` - }), + }) ], optimization: { mangleExports: 'size'