diff --git a/src/injected/inject.ts b/src/injected/inject.ts index 7466bcc..9ae022e 100644 --- a/src/injected/inject.ts +++ b/src/injected/inject.ts @@ -2,7 +2,7 @@ (function (xhr) { // TODO: find a way to make this cleaner - const RequestRegex = /^https?:\/\/(?:\w+\.)?twitter.com\/[\w\/\.\-\_\=]+\/(HomeLatestTimeline|HomeTimeline|Followers|Following|SearchTimeline|UserTweets|UserCreatorSubscriptions|FollowersYouKnow|BlueVerifiedFollowers|SearchTimeline|timeline\/home\.json|TweetDetail|search\/typeahead\.json|search\/adaptive\.json|blocks\/destroy\.json|mutes\/users\/destroy\.json)(?:$|\?)/; + const RequestRegex = /^https?:\/\/(?:\w+\.)?(?:twitter|x)\.com\/[\w\/\.\-\_\=]+\/(HomeLatestTimeline|HomeTimeline|Followers|Following|SearchTimeline|UserTweets|UserCreatorSubscriptions|FollowersYouKnow|BlueVerifiedFollowers|SearchTimeline|timeline\/home\.json|TweetDetail|search\/typeahead\.json|search\/adaptive\.json|blocks\/destroy\.json|mutes\/users\/destroy\.json)(?:$|\?)/; let XHR = XMLHttpRequest.prototype; let open = XHR.open; diff --git a/src/manifest.ts b/src/manifest.ts index 03ddb93..5d5ee30 100644 --- a/src/manifest.ts +++ b/src/manifest.ts @@ -18,7 +18,12 @@ export default defineManifest({ }, content_scripts: [ { - matches: ["*://*.twitter.com/*", "*://twitter.com/*"], + matches: [ + "*://*.twitter.com/*", + "*://twitter.com/*", + "*://*.x.com/*", + "*://x.com/*", + ], js: ["src/content/index.ts"], }, ], @@ -30,7 +35,12 @@ export default defineManifest({ "src/injected/*", "icon/*", ], - matches: ["*://*.twitter.com/*", "*://twitter.com/*"], + matches: [ + "*://*.twitter.com/*", + "*://twitter.com/*", + "*://*.x.com/*", + "*://x.com/*", + ], }, ], }); diff --git a/src/shared.ts b/src/shared.ts index 145ce4a..eb542bb 100644 --- a/src/shared.ts +++ b/src/shared.ts @@ -57,6 +57,8 @@ setInterval(blockCache.clear, 10 * 60e3); // clear the cache every 10 minutes // this is just here so we don't double add users unnecessarily (and also overwrite name) setInterval(UnblockCache.clear, 10 * 60e3); +const twitterWindowRegex = /^https?:\/\/(?:\w+\.)?(?:twitter|x)\.com(?=$|\/)/; + function unblockUser( user: { name: string; screen_name: string }, user_id: string, @@ -69,7 +71,7 @@ function unblockUser( api.storage.sync.set(items); }); - const match = window.location.href.match(/^https?:\/\/(?:\w+\.)?twitter.com(?=$|\/)/); + const match = window.location.href.match(twitterWindowRegex); if (!match) { throw new Error('unexpected or incorrectly formatted url'); @@ -375,7 +377,7 @@ consumer.start(); const CsrfTokenRegex = /ct0=\s*(\w+);/; function blockUser(user: BlockUser, attempt = 1) { - const match = window.location.href.match(/^https?:\/\/(?:\w+\.)?twitter.com(?=$|\/)/); + const match = window.location.href.match(twitterWindowRegex); if (!match) { throw new Error('unexpected or incorrectly formatted url');