Update README & Prettier

This commit is contained in:
dangered wolf 2022-11-17 00:57:04 -05:00
parent 2aefeea0c3
commit fee9bd1c43
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
4 changed files with 23 additions and 16 deletions

View file

@ -114,7 +114,7 @@ In many ways, FixTweet has richer embeds and does more. Here's a table comparing
| Embed profile pictures on text Tweets | :heavy_check_mark: | :x: | :heavy_check_mark: | :heavy_check_mark: |
| Embed Twitter Videos | :heavy_check_mark: | :x:¹ | :heavy_check_mark: | :heavy_check_mark: |
| Embed External Videos (YouTube, etc.) | :heavy_check_mark:⁵ | :x: | :x:⁴ | :x: |
| Embed Poll results | :heavy_check_mark: | :x: | :x: | :x: |
| Embed Poll results | :heavy_check_mark: | :x: | [:x:][polladd] | :x: |
| Embed Quote Tweets | :heavy_check_mark: | :x: | :ballot_box_with_check: Without Media | :ballot_box_with_check: Without Media |
| Embed Multiple Images | :heavy_check_mark: | :heavy_minus_sign: Discord Only³ | :ballot_box_with_check: c.vxtwitter.com | :x: |
| Translate Tweets | :heavy_check_mark: | :x: | :x: | :x: |
@ -135,6 +135,7 @@ In many ways, FixTweet has richer embeds and does more. Here's a table comparing
[fc]: https://github.com/FixTweet/FixTweet/commits
[vc]: https://github.com/dylanpdx/BetterTwitFix/commits
[sc]: https://github.com/Twxtter/Twxtter-main/commits
[polladd]: https://github.com/dylanpdx/BetterTwitFix/issues/17
¹ Discord will attempt to embed Twitter's video player, but it is unreliable

View file

@ -45,7 +45,7 @@ const statusRequest = async (
Also note that all we're doing here is setting the direct flag. If someone
links a video and ends it with .jpg, it will still redirect to a .mp4! */
if ( url.pathname.match(/\/status(es)?\/\d{2,20}\.(mp4|png|jpe?g)/g)) {
if (url.pathname.match(/\/status(es)?\/\d{2,20}\.(mp4|png|jpe?g)/g)) {
console.log('Direct media request by extension');
flags.direct = true;
} else if (Constants.DIRECT_MEDIA_DOMAINS.includes(url.hostname)) {
@ -151,7 +151,7 @@ const profileRequest = async (request: Request) => {
const genericTwitterRedirect = async (request: Request) => {
const url = new URL(request.url);
return Response.redirect(`${Constants.TWITTER_ROOT}${url.pathname}`, 302);
}
};
const versionRequest = async (request: Request) => {
return new Response(

View file

@ -172,7 +172,9 @@ export const handleStatus = async (
/* Push the raw video-related headers */
headers.push(
`<meta property="twitter:player:stream:content_type" content="${video.format}"/>`,
`<meta property="twitter:player:height" content="${video.height * sizeMultiplier}"/>`,
`<meta property="twitter:player:height" content="${
video.height * sizeMultiplier
}"/>`,
`<meta property="twitter:player:width" content="${video.width * sizeMultiplier}"/>`,
`<meta property="og:video" content="${video.url}"/>`,
`<meta property="og:video:secure_url" content="${video.url}"/>`,
@ -309,7 +311,10 @@ export const handleStatus = async (
if (tweet.replying_to && authorText === Strings.DEFAULT_AUTHOR_TEXT) {
authorText = `↪ Replying to @${tweet.replying_to}`;
/* We'll assume it's a thread if it's a reply to themselves */
} else if (tweet.replying_to === tweet.author.screen_name && authorText === Strings.DEFAULT_AUTHOR_TEXT) {
} else if (
tweet.replying_to === tweet.author.screen_name &&
authorText === Strings.DEFAULT_AUTHOR_TEXT
) {
authorText = `↪ A part of @${tweet.author.screen_name}'s thread`;
}

View file

@ -39,13 +39,18 @@ test('Tweet redirect human', async () => {
test('Twitter moment redirect', async () => {
const result = await cacheWrapper(
new Request('https://fxtwitter.com/i/events/1572638642127966214?t=0UK7Ny-Jnsp-dUGzlb-M8w&s=35', {
method: 'GET',
headers: botHeaders
})
new Request(
'https://fxtwitter.com/i/events/1572638642127966214?t=0UK7Ny-Jnsp-dUGzlb-M8w&s=35',
{
method: 'GET',
headers: botHeaders
}
)
);
expect(result.status).toEqual(302);
expect(result.headers.get('location')).toEqual('https://twitter.com/i/events/1572638642127966214');
expect(result.headers.get('location')).toEqual(
'https://twitter.com/i/events/1572638642127966214'
);
});
test('Tweet response robot', async () => {
@ -152,9 +157,7 @@ test('API fetch multi-photo Tweet', async () => {
const tweet = response.tweet as APITweet;
expect(tweet).toBeTruthy();
expect(tweet.url).toEqual(
'https://twitter.com/Twitter/status/1445094085593866246'
);
expect(tweet.url).toEqual('https://twitter.com/Twitter/status/1445094085593866246');
expect(tweet.id).toEqual('1445094085593866246');
expect(tweet.text).toEqual('@netflix');
expect(tweet.author.screen_name?.toLowerCase()).toEqual('twitter');
@ -276,9 +279,7 @@ test('API fetch poll Tweet', async () => {
const tweet = response.tweet as APITweet;
expect(tweet).toBeTruthy();
expect(tweet.url).toEqual(
'https://twitter.com/Twitter/status/1055475950543167488'
);
expect(tweet.url).toEqual('https://twitter.com/Twitter/status/1055475950543167488');
expect(tweet.id).toEqual('1055475950543167488');
expect(tweet.text).toEqual('A poll:');
expect(tweet.author.screen_name?.toLowerCase()).toEqual('twitter');