mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-05 10:30:55 +01:00
Prettier
This commit is contained in:
parent
bdc233be42
commit
71653d5b1a
7 changed files with 26 additions and 14 deletions
2
src/env.d.ts
vendored
2
src/env.d.ts
vendored
|
@ -3,4 +3,4 @@ declare const BRANDING_NAME_DISCORD: string;
|
||||||
declare const DIRECT_MEDIA_DOMAINS: string;
|
declare const DIRECT_MEDIA_DOMAINS: string;
|
||||||
declare const HOST_URL: string;
|
declare const HOST_URL: string;
|
||||||
declare const REDIRECT_URL: string;
|
declare const REDIRECT_URL: string;
|
||||||
declare const MOSAIC_DOMAIN_LIST: string;
|
declare const MOSAIC_DOMAIN_LIST: string;
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
import { Constants } from './constants';
|
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 apiAttempts = 0;
|
||||||
let cachedTokenFailed = false;
|
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,
|
This can effectively mean virtually unlimited (read) access to Twitter's API,
|
||||||
which is very funny. */
|
which is very funny. */
|
||||||
activate = await fetch(guestTokenRequest);
|
activate = await fetch(guestTokenRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Let's grab that guest_token so we can use it */
|
/* Let's grab that guest_token so we can use it */
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { Constants } from "./constants"
|
import { Constants } from './constants';
|
||||||
|
|
||||||
export const handleMosaic = async (mediaList: TweetMedia[]): Promise<TweetMedia> => {
|
export const handleMosaic = async (mediaList: TweetMedia[]): Promise<TweetMedia> => {
|
||||||
let mosaicDomains = Constants.MOSAIC_DOMAIN_LIST;
|
let mosaicDomains = Constants.MOSAIC_DOMAIN_LIST;
|
||||||
|
@ -8,7 +8,7 @@ export const handleMosaic = async (mediaList: TweetMedia[]): Promise<TweetMedia>
|
||||||
let domain = mosaicDomains[Math.floor(Math.random() * mosaicDomains.length)];
|
let domain = mosaicDomains[Math.floor(Math.random() * mosaicDomains.length)];
|
||||||
// let response = await fetch(`https://${domain}/ping`);
|
// let response = await fetch(`https://${domain}/ping`);
|
||||||
// if (response.status === 200) {
|
// if (response.status === 200) {
|
||||||
selectedDomain = domain;
|
selectedDomain = domain;
|
||||||
// } else {
|
// } else {
|
||||||
// mosaicDomains = mosaicDomains.filter(d => d !== domain);
|
// mosaicDomains = mosaicDomains.filter(d => d !== domain);
|
||||||
// console.log(`${domain} is not available, removing from list`);
|
// console.log(`${domain} is not available, removing from list`);
|
||||||
|
@ -20,7 +20,11 @@ export const handleMosaic = async (mediaList: TweetMedia[]): Promise<TweetMedia>
|
||||||
return mediaList[0];
|
return mediaList[0];
|
||||||
} else {
|
} else {
|
||||||
console.log('mediaList', mediaList);
|
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);
|
console.log('mosaicMedia', mosaicMedia);
|
||||||
let constructUrl = `https://${selectedDomain}/1`;
|
let constructUrl = `https://${selectedDomain}/1`;
|
||||||
if (mosaicMedia[0]) {
|
if (mosaicMedia[0]) {
|
||||||
|
@ -35,7 +39,7 @@ export const handleMosaic = async (mediaList: TweetMedia[]): Promise<TweetMedia>
|
||||||
if (mosaicMedia[3]) {
|
if (mosaicMedia[3]) {
|
||||||
constructUrl += `/${mosaicMedia[3]}`;
|
constructUrl += `/${mosaicMedia[3]}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
media_url_https: constructUrl,
|
media_url_https: constructUrl,
|
||||||
original_info: {
|
original_info: {
|
||||||
|
@ -45,4 +49,4 @@ export const handleMosaic = async (mediaList: TweetMedia[]): Promise<TweetMedia>
|
||||||
type: 'photo'
|
type: 'photo'
|
||||||
} as TweetMedia;
|
} as TweetMedia;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
@ -5,12 +5,17 @@ import { Strings } from './strings';
|
||||||
|
|
||||||
const router = Router();
|
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 { handle, id, mediaNumber } = request.params;
|
||||||
const url = new URL(request.url);
|
const url = new URL(request.url);
|
||||||
const userAgent = request.headers.get('User-Agent') || '';
|
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 (
|
if (
|
||||||
url.pathname.match(/\/status(es)?\/\d+\.(mp4|png|jpg)/g) !== null ||
|
url.pathname.match(/\/status(es)?\/\d+\.(mp4|png|jpg)/g) !== null ||
|
||||||
|
|
|
@ -344,4 +344,4 @@ export const handleStatus = async (
|
||||||
headers: headers.join('')
|
headers: headers.join('')
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
4
src/types.d.ts
vendored
4
src/types.d.ts
vendored
|
@ -13,5 +13,5 @@ interface StatusResponse {
|
||||||
interface Request {
|
interface Request {
|
||||||
params: {
|
params: {
|
||||||
[param: string]: string;
|
[param: string]: string;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ module.exports = {
|
||||||
}),
|
}),
|
||||||
new webpack.DefinePlugin({
|
new webpack.DefinePlugin({
|
||||||
MOSAIC_DOMAIN_LIST: `'${process.env.MOSAIC_DOMAIN_LIST}'`
|
MOSAIC_DOMAIN_LIST: `'${process.env.MOSAIC_DOMAIN_LIST}'`
|
||||||
}),
|
})
|
||||||
],
|
],
|
||||||
optimization: {
|
optimization: {
|
||||||
mangleExports: 'size'
|
mangleExports: 'size'
|
||||||
|
|
Loading…
Add table
Reference in a new issue