This commit is contained in:
dangered wolf 2022-07-23 14:16:22 -04:00
parent bdc233be42
commit 71653d5b1a
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
7 changed files with 26 additions and 14 deletions

View file

@ -1,6 +1,9 @@
import { Constants } from './constants';
export const fetchUsingGuest = async (status: string, event: FetchEvent): Promise<TimelineBlobPartial> => {
export const fetchUsingGuest = async (
status: string,
event: FetchEvent
): Promise<TimelineBlobPartial> => {
let apiAttempts = 0;
let cachedTokenFailed = false;

View file

@ -1,4 +1,4 @@
import { Constants } from "./constants"
import { Constants } from './constants';
export const handleMosaic = async (mediaList: TweetMedia[]): Promise<TweetMedia> => {
let mosaicDomains = Constants.MOSAIC_DOMAIN_LIST;
@ -20,7 +20,11 @@ export const handleMosaic = async (mediaList: TweetMedia[]): Promise<TweetMedia>
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]) {
@ -45,4 +49,4 @@ export const handleMosaic = async (mediaList: TweetMedia[]): Promise<TweetMedia>
type: 'photo'
} as TweetMedia;
}
}
};

View file

@ -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 ||

2
src/types.d.ts vendored
View file

@ -13,5 +13,5 @@ interface StatusResponse {
interface Request {
params: {
[param: string]: string;
}
};
}

View file

@ -34,7 +34,7 @@ module.exports = {
}),
new webpack.DefinePlugin({
MOSAIC_DOMAIN_LIST: `'${process.env.MOSAIC_DOMAIN_LIST}'`
}),
})
],
optimization: {
mangleExports: 'size'