Skip to content

Instantly share code, notes, and snippets.

@mickert
Last active August 12, 2026 19:08
Show Gist options
  • Select an option

  • Save mickert/acb16e532d1cb37ae7ffa89f34fa29b0 to your computer and use it in GitHub Desktop.

Select an option

Save mickert/acb16e532d1cb37ae7ffa89f34fa29b0 to your computer and use it in GitHub Desktop.
JavaScript automation script to bulk‑dismiss Microsoft Defender Family phishing alerts. Supports Dutch and English UI, regex‑based matching, adaptive backoff, and safe DevTools execution. Ideal for clearing repeated “phishing link blocked” notifications automatically. Apache 2.0 License license.
/**
* Bulk-dismiss Microsoft Defender Family phishing alerts automatically using a
* JavaScript automation script that runs safely in your browser's DevTools console.
*
* Features:
* - Clears repeated "phishing link blocked" notifications
* - Supports Dutch and English Defender Family UI
* - Regex-based matching for UI changes
* - Adaptive backoff for rate-limited dismiss actions
*
* Ideal for parents and administrators who want to remove large numbers of
* Microsoft Defender Family alerts quickly and safely.
*
* Alerts page: https://mydefender.microsoft.com/alerts
* Main script URL: https://gists.mickert.dev/acb16e532d1cb37ae7ffa89f34fa29b0
*/
/**
* Copyright 2026 Michel Sijmons - michel.sijmons.net
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
/**
* ---------------------------------------------------------------------------
* HELP / NOTES
* ---------------------------------------------------------------------------
* Microsoft Defender Family frequently updates UI text, button labels, and
* notification wording. If the script stops matching alerts or buttons, update
* the regex patterns in the configuration section below.
*
* This script is safe to run in the browser DevTools console. It automatically:
* - Detects phishing alerts (NL + EN)
* - Finds the "Dismiss" / "Verwijderen" button
* - Clicks one alert at a time
* - Waits for UI rerendering
* - Uses adaptive backoff when rate-limited
* - Stops when no matching alerts remain
*
* Version: 1.0.0 (2026-01-17) - Initial
* Version: 1.0.1 (2026-08-12) - Updated card selector to more generic ms-List-cell class.
*/
(async () => {
// ---------------------------------------------------------------------------
// CONFIGURATION (EDIT THESE IF MICROSOFT CHANGES THE UI)
// ---------------------------------------------------------------------------
// Regex patterns for matching phishing alert titles
const TITLE_REGEXES = [
/phishingkoppeling.*geblokkeerd/i, // Dutch
/phishing.*link.*block(ed)?/i, // English
/block.*phishing.*link/i, // English reversed order
/phishing.*(was|has been).*block(ed)?/i
];
// Regex patterns for matching the dismiss/remove button
const DISMISS_REGEXES = [
/verwijderen/i, // Dutch
/dismiss/i, // English
/remove/i // English variant
];
// Regex patterns for detecting backend/UI errors
const ERROR_REGEXES = [
/iets.*misgegaan/i, // Dutch
/probeer.*opnieuw/i, // Dutch variant
/something.*went.*wrong/i, // English
/try.*again.*later/i // English variant
];
// DOM selector for alert cards (stable across Defender Family builds)
const CARD_SELECTOR = ".ms-List-cell";
// Script behavior
let delayMs = 1100; // Starting delay
const minDelay = 800;
const maxDelay = 3000;
const delayStep = 300;
const dryRun = false; // Set to true to test without clicking
const maxIterations = 500;
// ---------------------------------------------------------------------------
// HELPERS
// ---------------------------------------------------------------------------
const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
const increaseDelay = () => {
delayMs = Math.min(delayMs + delayStep, maxDelay);
console.log(`⚠️ Increasing delay to ${delayMs}ms`);
};
const resetDelay = () => {
delayMs = Math.max(minDelay, 1100);
};
const errorDetected = () => {
const body = document.body.textContent;
return ERROR_REGEXES.some(rx => rx.test(body));
};
const findNextMatchingCard = () => {
const cards = Array.from(document.querySelectorAll(CARD_SELECTOR));
for (const card of cards) {
const title = card.querySelector("h3")?.textContent || "";
if (!TITLE_REGEXES.some(rx => rx.test(title))) continue;
const dismissBtn = Array.from(card.querySelectorAll("button"))
.find(b => DISMISS_REGEXES.some(rx => rx.test(b.textContent)));
if (dismissBtn) return { card, dismissBtn };
}
return null;
};
// ---------------------------------------------------------------------------
// MAIN LOOP
// ---------------------------------------------------------------------------
console.log("🚀 Starting Defender Family bulk-dismiss automation…");
let iteration = 0;
while (iteration < maxIterations) {
const target = findNextMatchingCard();
if (!target) {
console.log("🎉 No more matching alerts found. Finished.");
break;
}
const { dismissBtn } = target;
console.log(`🗑️ Dismissing alert #${iteration + 1}…`);
if (!dryRun) {
dismissBtn.click();
} else {
console.log("Dry run: would click", dismissBtn);
}
await delay(delayMs);
if (errorDetected()) {
console.log("❌ Error detected: backend/UI reported a failure.");
increaseDelay();
} else {
resetDelay();
}
iteration++;
}
console.log("🏁 Script completed.");
/**
* ---------------------------------------------------------------------------
* USAGE INSTRUCTIONS
* ---------------------------------------------------------------------------
* 1. Open the Microsoft Defender Family web console - https://mydefender.microsoft.com/alerts
* 2. Navigate to the "Alerts & History" section
* 3. Open your browser's Developer Tools → Console
* 4. Paste this script and press Enter
*
* The script will:
* - Automatically detect phishing alerts (Dutch + English)
* - Click the "Dismiss" / "Verwijderen" button one at a time
* - Wait for UI rerendering
* - Use adaptive backoff if rate-limited
* - Stop when no matching alerts remain
*
* ---------------------------------------------------------------------------
* TROUBLESHOOTING
* ---------------------------------------------------------------------------
* If the script stops matching alerts or buttons:
* - Microsoft may have changed the UI wording
* - Edit the regex patterns at the top of the script to match new phrasing
*
* Main download URL of this script: https://gist.github.com/mickert/acb16e532d1cb37ae7ffa89f34fa29b0
*
* ### FAQ
*
* **Does this work with Dutch and English Defender Family consoles?**
* Yes - the script includes regex patterns for both languages.
*
* **Is this safe to run?**
* Yes - it only interacts with the current browser page and does not send data anywhere.
*
* **Why does the script use regex matching?**
* Microsoft frequently changes UI text, so regexes make the script more resilient.
*
* ---------------------------------------------------------------------------
* 👋 Hey visitor — Michel here
* ---------------------------------------------------------------------------
*
* If any of my tools, gists, or guides helped you out — saved you time or money,
* solved a headache, or taught you something useful — I’d love it if you:
*
* • Explore my work (Gists + GitHub projects) and maybe drop a ⭐ or follow:
* https://gists.mickert.dev/
* https://github.mickert.dev/
*
* • Support my work on Ko-fi:
* https://support.mickert.dev/
* https://ko-fi.com/michelsprojects
*
* Your support helps me create more tools, templates, and deep-dives like this.
* Happy building!
*
* ---------------------------------------------------------------------------
*
* Main download URL of this script:
* https://gists.mickert.dev/acb16e532d1cb37ae7ffa89f34fa29b0
*
* For licensing details, see the Apache 2.0 header at the top of this file.
*/
})();
@mickert

mickert commented Jan 17, 2026 •

Copy link
Copy Markdown
Author

Pinned Comment — Important Notes, Quick Start & License

This script automatically bulk-dismisses repeated “phishing link blocked” alerts in Microsoft Defender Family using a safe JavaScript automation loop that runs directly in your browser’s DevTools console.

📄 Main script URL:
https://gists.mickert.dev/acb16e532d1cb37ae7ffa89f34fa29b0


🔧 Quick Start

  1. Open the Microsoft Defender Family alerts page:
    https://mydefender.microsoft.com/alerts
  2. Open your browser’s Developer Tools → Console
  3. Paste the script from this gist
  4. Press Enter

The script detects phishing alerts (Dutch + English), finds the correct Dismiss / Verwijderen button, dismisses alerts one at a time, waits for UI updates, and stops automatically when all matching alerts are cleared.


🔍 If the script stops matching alerts

Microsoft occasionally updates UI text or button labels.
If detection breaks, update the regex patterns in the configuration section at the top of the script.


👋 Hey visitor - Michel here

If any of my tools, gists, or guides helped you out - saved you time or money, solved a headache, or taught you something useful - I’d love it if you:

Your support helps me do more tests and create more tools, templates, and deep-dives like this.
Happy building!


📋Changelog

  • 2026‑01‑17 - v1.0.0 : Initial public release with regex-based NL/EN matching, adaptive backoff
  • 2026‑08‑12 - v1.0.1 : Updated card selector to more generic ms-List-cell class.

📜 License & Attribution

Copyright © 2026 Michel Sijmons - michel.sijmons.net
Licensed under the Apache License, Version 2.0.
See the full license header inside the script.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment