1-click Pipeline to Cloudwatch

Iterates through child elements of liveDataSamplesDiv

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        1-click Pipeline to Cloudwatch
// @version     1.0
// @description Iterates through child elements of liveDataSamplesDiv
// @author      Syed Shuaib Zaidi (zidisz@)
// @require     https://cdn.jsdelivr.net/npm/jquery@3/dist/jquery.min.js
// @include     https://pipelines.amazon.com/*
// @grant       GM_setClipboard
// @namespace https://greasyfork.org/users/1467838
// ==/UserScript==


$(document).ready(function() {
    'use strict';

    // Select all divs with class naws-detail and title AWS Account
    const awsAccountDivs = document.querySelectorAll('div.naws-detail[title="AWS Account"]');

    awsAccountDivs.forEach(div => {
        const originalLink = div.querySelector('a');
        originalLink.className = "button";
        originalLink.title = "Conduit";

        // Create a fresh div
        const cwDashboardLink = document.createElement('div');
        cwDashboardLink.className = 'naws-detail';
        cwDashboardLink.title = 'Dashboard link';

        // Create a hyperlink for the account
        const hyperlink1 = document.createElement('a');
        hyperlink1.className = "button";
        hyperlink1.href = "https://cw-dashboards.aka.amazon.com/cloudwatch/dashboardInternal?accountId=" + div.textContent.trim();
        hyperlink1.textContent = 'Dashboard link';
        hyperlink1.style.marginLeft = '10px';

        // Append the hyperlink to the new div
        cwDashboardLink.appendChild(hyperlink1);

        // Insert the cloned div after the original
        div.parentNode.insertBefore(cwDashboardLink, div.nextSibling);

        // Create a fresh div
        const cwMetricsLink = document.createElement('div');
        cwMetricsLink.className = 'naws-detail';
        cwMetricsLink.title = 'Metrics link';

        // Create a hyperlink for the account
        const hyperlink2 = document.createElement('a');
        hyperlink2.className = "button";
        hyperlink2.href = "https://cw-dashboards.aka.amazon.com/?accountId=" + div.textContent.trim() + "#metricsV2" ;
        hyperlink2.textContent = 'Metrics link';
        hyperlink2.style.marginLeft = '10px';

        // Append the hyperlink to the new div
        cwMetricsLink.appendChild(hyperlink2);

        // Insert the cloned div after the original
        div.parentNode.insertBefore(cwMetricsLink, div.nextSibling);
    });
})();