// Select all buttons with a child span element with text content equal to "Following"
var buttons = document.querySelectorAll("button span");
// Loop through the buttons and simulate a click event on each one
buttons.forEach(function(span) {
if(span.textContent.trim() === "Following") {
var button = span.closest("button");
button.click();
// Wait for the dialog to appear
setTimeout(function() {
// Select the button with a child span element with text content containing "Unfollow"
var unfollowButton = document.querySelector("dialog button span");
if(unfollowButton && unfollowButton.textContent.trim().includes("Unfollow")) {
var unfollowButtonParent = unfollowButton.closest("button");
unfollowButtonParent.click();
// Wait for the "Unfollow" request to complete and then close the dialog
setTimeout(function() {
var closeButton = document.querySelector("dialog [data-testid='close-modal']");
closeButton.click();
// Wait for the dialog to close
setTimeout(function() {
console.log("Dialog closed.");
}, 1000);
}, 3000);
} else {
console.log("Unfollow button not found or has incorrect text content.");
}
}, 1000);
}
});
Post #640
374