From 4061fadb3a3112242221fea356fa102eb6d8c9d7 Mon Sep 17 00:00:00 2001 From: Sebastian Thulin Date: Mon, 2 Dec 2024 14:32:53 +0100 Subject: [PATCH] fix: add event dispatch when client is classified. --- source/js/context-detector.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/source/js/context-detector.ts b/source/js/context-detector.ts index 24af520..b256f59 100644 --- a/source/js/context-detector.ts +++ b/source/js/context-detector.ts @@ -62,26 +62,22 @@ class ClientTypeChecker { // Mark as internal client private setInternalClient(): void { - console.log('Internal client'); + document.dispatchEvent(new CustomEvent('brokenLinkContextDetectionInternal')); document.body.classList.add(this.config.successClass); } // Mark as external client private setExternalClient(): void { + // Execute custom event + document.dispatchEvent(new CustomEvent('brokenLinkContextDetectionExternal')); document.body.classList.add(this.config.failedClass); this.applyDomainRestrictions(); } - // Log messages only if DevTools is open - private log(message: string): void { - console.log(message); - } - // Apply domain restrictions to domains in the domain list private applyDomainRestrictions(): void { this.config.domains.forEach(domain => { const elements = document.querySelectorAll(`a[href*="${domain}"]`); - console.log(elements); elements.forEach(element => { element.classList.add('broken-link-detector-link-is-unavabile'); element.setAttribute("data-tooltip", this.config.tooltip);