Merge pull request #459 from w3irdrobot/rewrite-twitter-to-nitter

add setting for rewriting twitter links to nitter
This commit is contained in:
Kieran 2023-03-27 14:51:01 +01:00 committed by GitHub
commit 1bf6c7031e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 5 deletions

View File

@ -111,12 +111,25 @@ export default function HyperText({ link, creator }: { link: string; creator: He
</a>
);
}
} else if (tweetId) {
} else if (tweetId && !pref.rewriteTwitterPosts) {
return (
<div className="tweet" key={tweetId}>
<TwitterTweetEmbed tweetId={tweetId} />
</div>
);
} else if (pref.rewriteTwitterPosts && url.hostname == "twitter.com") {
url.host = "nitter.net";
return (
<a
key={url.toString()}
href={url.toString()}
onClick={e => e.stopPropagation()}
target="_blank"
rel="noreferrer"
className="ext">
{url.toString()}
</a>
);
} else if (youtubeId) {
return (
<iframe

View File

@ -401,6 +401,23 @@ const PreferencesPage = () => {
/>
</div>
</div>
<div className="card flex">
<div className="flex f-col f-grow">
<div>
<FormattedMessage {...messages.RewriteTwitterPosts} />
</div>
<small>
<FormattedMessage {...messages.RewriteTwitterPostsHelp} />
</small>
</div>
<div>
<input
type="checkbox"
checked={perf.rewriteTwitterPosts}
onChange={e => dispatch(setPreferences({ ...perf, rewriteTwitterPosts: e.target.checked }))}
/>
</div>
</div>
<div className="card flex">
<div className="flex f-col f-grow">
<div>

View File

@ -61,4 +61,6 @@ export default defineMessages({
Nip05: { defaultMessage: "NIP-05" },
ReactionEmoji: { defaultMessage: "Reaction emoji" },
ReactionEmojiHelp: { defaultMessage: "Emoji to send when reactiong to a note" },
RewriteTwitterPosts: { defaultMessage: "Nitter Rewrite" },
RewriteTwitterPostsHelp: { defaultMessage: "Rewrite Twitter links to Nitter links" },
});

View File

@ -51,6 +51,11 @@ export interface UserPreferences {
*/
confirmReposts: boolean;
/**
* Rewrite Twitter links to Nitter links
*/
rewriteTwitterPosts: boolean;
/**
* Automatically show the latests notes
*/
@ -245,6 +250,7 @@ export const InitState = {
confirmReposts: false,
showDebugMenus: false,
autoShowLatest: false,
rewriteTwitterPosts: false,
fileUploader: "void.cat",
imgProxyConfig: DefaultImgProxy,
defaultRootTab: "posts",

View File

@ -75,6 +75,9 @@
"2k0Cv+": {
"defaultMessage": "Dislikes ({n})"
},
"3LAxQH": {
"defaultMessage": "Rewrite Twitter links to Nitter links"
},
"3cc4Ct": {
"defaultMessage": "Light"
},
@ -522,6 +525,9 @@
"X7xU8J": {
"defaultMessage": "nsec, npub, nip-05, hex, mnemonic"
},
"XSoRjZ": {
"defaultMessage": "Nitter Rewrite"
},
"XgWvGA": {
"defaultMessage": "Reactions"
},
@ -666,6 +672,9 @@
"iNWbVV": {
"defaultMessage": "Handle"
},
"iXPL0Z": {
"defaultMessage": "Can't login with private key on an insecure connection, please use a Nostr key manager extension instead"
},
"ieGrWo": {
"defaultMessage": "Follow"
},
@ -855,9 +864,6 @@
"uSV4Ti": {
"defaultMessage": "Reposts need to be manually confirmed"
},
"ubtr9S": {
"defaultMessage": "Can't login with private key on 'http://' connection, please use a Nostr key manager extension instead"
},
"usAvMr": {
"defaultMessage": "Edit Profile"
},

View File

@ -24,6 +24,7 @@
"2LbrkB": "Enter password",
"2a2YiP": "{n} Bookmarks",
"2k0Cv+": "Dislikes ({n})",
"3LAxQH": "Rewrite Twitter links to Nitter links",
"3cc4Ct": "Light",
"3gOsZq": "Translators",
"3t3kok": "{n,plural,=1{{n} new note} other{{n} new notes}}",
@ -169,6 +170,7 @@
"WONP5O": "Find your twitter follows on nostr (Data provided by {provider})",
"WxthCV": "e.g. Jack",
"X7xU8J": "nsec, npub, nip-05, hex, mnemonic",
"XSoRjZ": "Nitter Rewrite",
"XgWvGA": "Reactions",
"XzF0aC": "Key manager extensions are more secure and allow you to easily login to any Nostr client, here are some well known extensions:",
"Y31HTH": "Help fund the development of Snort",
@ -216,6 +218,7 @@
"iDGAbc": "Get a Snort identifier",
"iGT1eE": "Prevent fake accounts from imitating you",
"iNWbVV": "Handle",
"iXPL0Z": "Can't login with private key on an insecure connection, please use a Nostr key manager extension instead",
"ieGrWo": "Follow",
"itPgxd": "Profile",
"izWS4J": "Unfollow",
@ -278,7 +281,6 @@
"u4bHcR": "Check out the code here: {link}",
"uD/N6c": "Zap {target} {n} sats",
"uSV4Ti": "Reposts need to be manually confirmed",
"ubtr9S": "Can't login with private key on 'http://' connection, please use a Nostr key manager extension instead",
"usAvMr": "Edit Profile",
"ut+2Cd": "Get a partner identifier",
"vOKedj": "{n,plural,=1{& {n} other} other{& {n} others}}",