Skip to content

Commit

Permalink
Hide twitter blue users tweets and recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
toni-santos committed Apr 3, 2023
1 parent 5173d86 commit 20e1d9c
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
1 change: 1 addition & 0 deletions content.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const defaultConfig = {
twitterBlueLabel: "Paid",
enableBorder: true,
},
removeTweets: false,
};

function createSettingsDomNode(items) {
Expand Down
6 changes: 6 additions & 0 deletions options/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ <h1>Settings</h1>
search</label
>
</div>
<div class="option checkboxes">
<input type="checkbox" id="removeTweets" />
<label for="removeTweets">
<strong>Remove Tweets</strong><br />
Remove tweets by Twitter Blue users</label>
</div>
<div class="savecontainer">
<div id="status">
Options Saved. Refresh your page to see changes.
Expand Down
4 changes: 4 additions & 0 deletions options/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ function saveOptions() {
"removeBlueVerification"
).checked;
const advancedSearch = document.getElementById("advancedSearch").checked;
const removeTweets = document.getElementById("removeTweets").checked;
chrome.storage.local.set(
{
advancedSearch,
Expand All @@ -30,6 +31,7 @@ function saveOptions() {
twitterBlueLabel: textEnabled ? twitterBlueVerifiedLabel : "",
enableBorder: textEnabled ? textEnableBorder : true,
},
removeTweets,
},
function () {
const status = document.getElementById("status");
Expand All @@ -56,6 +58,7 @@ function restoreOptions() {
twitterBlueLabel: "Paid",
enableBorder: true,
},
removeTweets: false,
},
function (items) {
document.getElementById("memeMode").checked = items.memeMode;
Expand All @@ -69,6 +72,7 @@ function restoreOptions() {
document.getElementById("removeBlueVerification").checked =
items.removeBlueVerification;
document.getElementById("advancedSearch").checked = items.advancedSearch;
document.getElementById("removeTweets").checked = items.removeTweets;
onTextEnabledChange();
}
);
Expand Down
37 changes: 37 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const config = document.getElementById("eight-dollars-settings");
const data = JSON.parse(config.innerText);

const MEME_MODE = data.memeMode;
const REMOVE_TWEETS = data.removeTweets;
const TEXT_ENABLED = data.textEnabled;
const REMOVE_TWITTER_BLUE_VERIFICATION = data.removeBlueVerification;
const TEXT_VERIFIED_LABEL = data.textOptions?.verifiedLabel || "";
Expand Down Expand Up @@ -178,6 +179,42 @@ function changeBlueVerified(prependHTML, elm, isSmall) {
return
}


if (REMOVE_TWEETS) {
element = elm;

// deepest rooted checkmark = 18 levels
let level = 15;

// constant classNames to be checked when traversing the 18 levels
const sidebarAccountClassName = "css-18t94o4 css-1dbjc4n r-1ny4l3l r-ymttw5 r-1f1sjgu r-o7ynqc r-6416eg";
const QRT = "css-1dbjc4n r-1kqtdi0 r-1867qdf r-rs99b7 r-1loqt21 r-adacv r-1ny4l3l r-1udh08x r-o7ynqc r-6416eg";
const profileHeader = "css-1dbjc4n r-6gpygo r-14gqq1x"
const searchBar = "css-1dbjc4n r-150rngu r-kemksi r-1xfd6ze r-qo02w8 r-1d2f490 r-8fhv3p r-h3f8nf r-1rnoaur r-1r851ge r-u8s1d r-zchlnj r-ipm5af"

while (level-- > 0) {
element = element.parentNode;
if (!element) return null;

if (element.className == sidebarAccountClassName) {
break;
} else if (element.className == QRT) {
break;
} else if (element.className == profileHeader) {
console.log("FOUND IT AAAAAAAAAAAAAA")
break;
} else if (element.className == searchBar) {
break;
}
}

if (element.className == profileHeader || element.className == QRT || element.className == searchBar) {
} else {
element.remove()
}

}

if (REMOVE_TWITTER_BLUE_VERIFICATION) {
elm.style.display = 'none';
elm.setAttribute('data-eight-dollars-status', 'blueVerified');
Expand Down

0 comments on commit 20e1d9c

Please sign in to comment.