let sharedCount = 0; // Function to locate and interact with the share button function sharePost() { if (sharedCount >= 100) { console.log("Achievement unlocked: Shared 100 posts!"); observer.disconnect(); // Stop observing return; } // Locate the share button const shareButton = document.querySelector('shreddit-post-share-button:not([data-clicked])'); if (shareButton) { console.log("Found a share button. Clicking it..."); shareButton.setAttribute("data-clicked", "true"); // Mark as processed shareButton.click(); // Open the share popup setTimeout(() => { const copyLinkButton = document.querySelector('div[aria-label="Copy link"]'); if (copyLinkButton) { console.log("Copy Link button found. Clicking it..."); copyLinkButton.click(); // Click "Copy Link" sharedCount++; console.log(`Shared posts: ${sharedCount}`); } else { console.log("Copy Link button not found!"); } window.scrollBy(0, 500); // Scroll to the next post console.log("Scrolled to the next post."); setTimeout(sharePost, 1000); // Retry }, 1000); } else { console.log("Share button not found! Scrolling down..."); window.scrollBy(0, 500); // Scroll to load more posts setTimeout(sharePost, 1000); // Retry } } // MutationObserver to track DOM changes const observer = new MutationObserver((mutations) => { mutations.forEach((mutation) => { const newShareButtons = document.querySelectorAll('shreddit-post-share-button:not([data-clicked])'); if (newShareButtons.length > 0) { console.log(`Found ${newShareButtons.length} new share buttons.`); } else { console.log("No new share buttons found in this mutation."); } }); }); // Start observing the body for added nodes observer.observe(document.body, { childList: true, subtree: true }); console.log("Started observing the DOM for share buttons..."); // Trigger initial scrolling to load posts function scrollToLoadPosts() { console.log("Scrolling to load posts..."); window.scrollBy(0, 500); // Scroll to load more posts setTimeout(scrollToLoadPosts, 1000); // Keep scrolling until achievement is unlocked } scrollToLoadPosts(); sharePost();