diff --git a/source/content.ts b/source/content.ts index fb2a876..4ff12e9 100644 --- a/source/content.ts +++ b/source/content.ts @@ -1,7 +1,6 @@ -console.log("Kibana Clicker is started."); - const KIBANA_CLICKER_INJECTED_ATTRIBUTE = "kibana-clicker-injected"; const FIELD_NAME_REGEXP = /^tableDocViewRow-(?.*)-value$/; +let IS_KIBANA_DETECTED = false; function getFieldName(element: Element): string | null { const subjectAttr = element.getAttribute("data-test-subj") ?? ""; @@ -27,6 +26,7 @@ function createLink(name: string, value: string): Element { function handleKibanaDetected() { console.log("Kibana detected"); + IS_KIBANA_DETECTED = true; } function handleDocumentViewer(viewer: Element) { @@ -57,6 +57,10 @@ function handleNewNode(node: Node) { return handleKibanaDetected(); } + if (!IS_KIBANA_DETECTED) { + return; + } + if (node.classList.contains("kbnDocViewer")) { return handleDocumentViewer(node); }