Skip to content

Commit

Permalink
Process further only when Kibana is detected
Browse files Browse the repository at this point in the history
  • Loading branch information
hyzyla committed Dec 30, 2021
1 parent ef2364e commit 2234ef2
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions source/content.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
console.log("Kibana Clicker is started.");

const KIBANA_CLICKER_INJECTED_ATTRIBUTE = "kibana-clicker-injected";
const FIELD_NAME_REGEXP = /^tableDocViewRow-(?<fieldName>.*)-value$/;
let IS_KIBANA_DETECTED = false;

function getFieldName(element: Element): string | null {
const subjectAttr = element.getAttribute("data-test-subj") ?? "";
Expand All @@ -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) {
Expand Down Expand Up @@ -57,6 +57,10 @@ function handleNewNode(node: Node) {
return handleKibanaDetected();
}

if (!IS_KIBANA_DETECTED) {
return;
}

if (node.classList.contains("kbnDocViewer")) {
return handleDocumentViewer(node);
}
Expand Down

0 comments on commit 2234ef2

Please sign in to comment.