// Function to simulate a click event function simulateClick(element) { const event = new MouseEvent('click', { view: window, bubbles: true, cancelable: true }); element.dispatchEvent(event); } // Function to perform actions on rmdown.com function performRmdownActions() { console.log("Performing actions on rmdown.com"); // Check if the page contains the rate limit message if (document.body.innerText.includes("Your IP downloads reached the site limit")) { console.log("Rate limit reached. Stopping actions."); // Optionally, you can display a notification to the user here return; } // Random delay between 2 to 5 seconds before starting actions const initialDelay = 2000 + Math.random() * 3000; setTimeout(() => { const copyButton = document.getElementById('cbtn'); if (copyButton) { console.log("Copy button found, clicking..."); simulateClick(copyButton); // Random delay between 1 to 3 seconds before next action const downloadDelay = 1000 + Math.random() * 2000; setTimeout(() => { const downloadButton = document.querySelector('button[title="Download file"]'); if (downloadButton) { console.log("Download button found, clicking..."); simulateClick(downloadButton); } else { console.log("Download button not found"); } }, downloadDelay); } else { console.log("Copy button not found"); } }, initialDelay); } // Listen for messages from the popup script chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { console.log("Message received in content script:", request); if (request.action === "initiateDownload") { // Find the link on the page const link = document.querySelector('a[href*="rmdown.com/link.php?hash="]'); if (link) { console.log("Link found:", link); // Open the link in a new tab chrome.runtime.sendMessage({ action: "openLink", url: link.href }); sendResponse({ success: true }); } else { console.log("Link not found"); sendResponse({ success: false }); } return true; // Indicates that the response is sent asynchronously } else if (request.action === "performActions") { performRmdownActions(); sendResponse({ success: true }); return true; } }); // Automatically perform actions if on rmdown.com if (window.location.hostname === "rmdown.com") { performRmdownActions(); }