Skip to content

Commit

Permalink
[feat] Skip people retweeted by people you follow (#371)
Browse files Browse the repository at this point in the history
* [chore] bump version string

* [feat] add option to skip users retweeted by people you follow

* [chore] run prettier on changes
  • Loading branch information
rougetimelord authored Nov 1, 2024
1 parent f4097db commit be1b117
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "blue-blocker",
"version": "0.4.11",
"version": "0.4.12",
"author": "DanielleMiu",
"description": "Blocks all Twitter Blue verified users on twitter.com",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const DefaultOptions: Config = {
mute: false,
blockFollowing: false,
blockFollowers: false,
skipFollowingQrts: false,
skipBlueCheckmark: false,
skipVerified: true,
skipAffiliated: true,
Expand Down
3 changes: 2 additions & 1 deletion src/content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function compileConfig(config: Config): CompiledConfig {
mute: config.mute,
blockFollowing: config.blockFollowing,
blockFollowers: config.blockFollowers,
skipFollowingQrts: config.skipFollowingQrts,
skipBlueCheckmark: config.skipBlueCheckmark,
skipVerified: config.skipVerified,
skipAffiliated: config.skipAffiliated,
Expand All @@ -40,7 +41,7 @@ function compileConfig(config: Config): CompiledConfig {
)
.join('|'),
'i',
),
),
} as CompiledConfig;
}

Expand Down
2 changes: 2 additions & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface Config {
mute: boolean;
blockFollowing: boolean;
blockFollowers: boolean;
skipFollowingQrts: boolean;
skipBlueCheckmark: boolean;
skipVerified: boolean;
skipAffiliated: boolean;
Expand All @@ -29,6 +30,7 @@ interface CompiledConfig {
mute: boolean;
blockFollowing: boolean;
blockFollowers: boolean;
skipFollowingQrts: boolean;
skipBlueCheckmark: boolean;
skipVerified: boolean;
skipAffiliated: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineManifest } from '@crxjs/vite-plugin';
export default defineManifest({
name: 'Blue Blocker',
description: 'Blocks all Twitter Blue verified users on twitter.com',
version: '0.4.11',
version: '0.4.12',
manifest_version: 3,
icons: {
'128': 'icon/icon-128.png',
Expand Down
19 changes: 18 additions & 1 deletion src/parsers/instructions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,25 @@ export function ParseTimelineTweet(tweet: any, config: CompiledConfig) {
}

try {
if (
config.skipFollowingQrts &&
tweet?.itemContent?.tweet_results?.result?.core?.user_results?.result?.legacy
?.following &&
(tweet?.itemContent?.tweet_results?.result?.legacy?.is_quote_status ||
tweet?.tweet_results?.result?.legacy?.retweeted_status_result)
) {
const skippedUser =
tweet?.itemContent?.tweet_results?.result?.legacy?.retweeted_status_result?.result
?.core?.user_results?.result ||
tweet?.itemContent?.tweet_results?.result?.quoted_status_result?.result?.core
?.user_results?.result;
console.log(
logstr,
`skipping ${skippedUser.legacy.name} (@${skippedUser.legacy.screen_name}) because they got retweeted by someone you follow`,
);
}
// Handle retweets and quoted tweets (check the retweeted user, too)
if (tweet?.itemContent?.tweet_results?.result?.quoted_status_result?.result) {
else if (tweet?.itemContent?.tweet_results?.result?.quoted_status_result?.result) {
handleTweetObject(
tweet.itemContent.tweet_results.result.quoted_status_result.result,
config,
Expand Down
10 changes: 10 additions & 0 deletions src/popup/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ <h2><img src="/icon/icon-128.png" alt="🅱️" style="height: 1.2em" />lue Bloc
<input type="checkbox" id="block-promoted-tweets" />
<input type="checkbox" id="block-for-use" />
<input type="checkbox" id="blockstrings" />
<input type="checkbox" id="skip-following-qrts">
<div class="tab" id="general">
<div class="option">
<label for="suspend-block-collection" name="suspend-block-collection">
Expand Down Expand Up @@ -120,6 +121,15 @@ <h2><img src="/icon/icon-128.png" alt="🅱️" style="height: 1.2em" />lue Bloc
</label>
<span name="block-followers-status"></span>
</div>
<div class="option">
<label for="skip-following-qrts" name="skip-following-qrts">
<div class="checkmark">
<div></div>
</div>
<p>skip blocking retweets from people I follow</p>
</label>
<span name="skip-following-qrts-status"></span>
</div>
<div>
<div class="option">
<p>
Expand Down
2 changes: 2 additions & 0 deletions src/popup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ document.addEventListener('DOMContentLoaded', () => {
const muteInsteadOfBlock = document.getElementById('mute-instead-of-block') as HTMLInputElement;
const blockFollowing = document.getElementById('block-following') as HTMLInputElement;
const blockFollowers = document.getElementById('block-followers') as HTMLInputElement;
const skipFollowingQrts = document.getElementById('skip-following-qrts') as HTMLInputElement;
const skipVerified = document.getElementById('skip-verified') as HTMLInputElement;
const skipAffiliated = document.getElementById('skip-affiliated') as HTMLInputElement;
const skip1Mplus = document.getElementById('skip-1mplus') as HTMLInputElement;
Expand All @@ -313,6 +314,7 @@ document.addEventListener('DOMContentLoaded', () => {
checkHandler(muteInsteadOfBlock, config, 'mute');
checkHandler(blockFollowing, config, 'blockFollowing');
checkHandler(blockFollowers, config, 'blockFollowers');
checkHandler(skipFollowingQrts, config, 'skipFollowingQrts');
checkHandler(skipVerified, config, 'skipVerified');
checkHandler(skipAffiliated, config, 'skipAffiliated');
checkHandler(skip1Mplus, config, 'skip1Mplus', {
Expand Down

0 comments on commit be1b117

Please sign in to comment.