Ad Blocker usually blocks the browser to load remote scripts and it causes error on the browser. In this case, we may able to count the number of errors when the page does not load the javascript as designed. Ad Blocker Extension blocks loading remote script in the browser based on its filtering logic, so we can assume if the Ad Blocker is installed or not by counting number of scripts blocked.

Below example enables you to monitor errors in case that you can't load remote script, and you may able to add your idea to check the required JS is correctly loaded as designed.

// Create a counter to keep track of script loading errors
let errorCount = 0;

// Function to handle script loading errors
function handleScriptError(event) {
  // Increment the error count
  errorCount++;

  // Get the URL of the script that caused the error
  const scriptUrl = event.target.src || "Inline script";

  // Log the error count and the script URL
  console.error(`Error loading script from: ${scriptUrl}`);
  console.error(`Total script loading errors: ${errorCount}`);
}

// Add error event listener to all script elements
const scriptElements = document.querySelectorAll("script");
scriptElements.forEach((script) => {
  script.addEventListener("error", handleScriptError);
});