Skip to content

Commit

Permalink
Merge pull request #22 from timkoopmans/master
Browse files Browse the repository at this point in the history
Filter "You might like" content
  • Loading branch information
Ryan Kulp authored Aug 16, 2022
2 parents 80cb4e6 + cbc6a91 commit 9e98d72
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ Free tool (Chrome extension) that hides promoted Tweets while you browse Twitter

No signup and it doesn't track anything you do.

Blocks promoted Tweets, promoted Topics (What's happening), and promoted Users (Who to follow) in [all languages](https://github.com/ryanckulp/twitter_ad_blocker/pull/18).
Blocks promoted Tweets, promoted Topics (What's happening), suggested Articles (You might like) and promoted Users (Who to follow) in [all languages](https://github.com/ryanckulp/twitter_ad_blocker/pull/18).

https://chrome.google.com/webstore/detail/hide-twitter-ads-block-pr/bapmhjebfdbdpjjfafnkfidijkjlkakf?hl=en
7 changes: 7 additions & 0 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@ var adsHidden = 0;
var adSelector = "div[data-testid=placementTracking]";
var trendSelector = "div[data-testid=trend]";
var userSelector = "div[data-testid=UserCell]";
var articleSelector = "article[data-testid=tweet]";
var sponsoredSvgPath = 'M20.75 2H3.25C2.007 2 1 3.007 1 4.25v15.5C1 20.993 2.007 22 3.25 22h17.5c1.243 0 2.25-1.007 2.25-2.25V4.25C23 3.007 21.993 2 20.75 2zM17.5 13.504c0 .483-.392.875-.875.875s-.875-.393-.875-.876V9.967l-7.547 7.546c-.17.17-.395.256-.62.256s-.447-.086-.618-.257c-.342-.342-.342-.896 0-1.237l7.547-7.547h-3.54c-.482 0-.874-.393-.874-.876s.392-.875.875-.875h5.65c.483 0 .875.39.875.874v5.65z';
var youMightLikeSvgPath = 'M18.265 3.314c-3.45-3.45-9.07-3.45-12.52 0-3.45 3.44-3.45 9.06 0 12.51 1.5 1.49 3.43 2.38 5.51 2.56v4.14c0 .31.2.6.5.7.08.03.17.05.25.05.22 0 .44-.1.59-.29l6.49-8.11c2.63-3.49 2.27-8.47-.82-11.56zm-10.56 7.87c0-.41.33-.75.75-.75h4.05c.41 0 .75.34.75.75s-.34.75-.75.75h-4.05c-.42 0-.75-.34-.75-.75zm8.6-3.24c0 .42-.34.75-.75.75h-7.1c-.42 0-.75-.33-.75-.75 0-.41.33-.75.75-.75h7.1c.41 0 .75.34.75.75z';

function getAds() {
return Array.from(document.querySelectorAll('div')).filter(function(el) {
var filteredAd;

if (el.getInnerHTML().includes(sponsoredSvgPath)) {
filteredAd = el;
} else if (el.getInnerHTML().includes(youMightLikeSvgPath)) {
filteredAd = el;
}

return filteredAd;
Expand All @@ -26,6 +30,9 @@ function hideAd(ad) {
} else if (ad.closest(userSelector) !== null) {
ad.closest(userSelector).remove();
adsHidden += 1;
} else if (ad.closest(articleSelector) !== null) {
ad.closest(articleSelector).remove();
adsHidden += 1;
}
console.log('Twitter ads hidden: ', adsHidden.toString());
}
Expand Down

0 comments on commit 9e98d72

Please sign in to comment.