// ==UserScript== // @name Data Extension Editor UI // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://app.boxever.com/* // @match https://app-ap.boxever.com/* // @match https://app-us.boxever.com/* // @icon https://www.google.com/s2/favicons?domain=boxever.com // @grant none // @require https://cdn.jsdelivr.net/npm/sweetalert2@11 // ==/UserScript== (function () { 'use strict'; const clientKeyMap = { wjtc2eog1lvueo72kts3mn1ean0nentz: 'Boxever Labs (Spinair)', psfu6uh05hsr9c34rptlr06dn864cqrx: 'Partner Sandbox', pqsGAMEJ9jsRlJMQPTrnpk0cGxD4ab70: "Spin Gaming", pqsDATA3lw12v5a9rrHPW1c4hET73GxQ: "Spinair - DC", pqsFinGP4nW3iqC4JzgRMGZMgODLuDVM: "SpinFinance", pqsMedIa6PvIs50quSIOAPHcL0TJTQpk: "SpinMedia", pqsSIOPAxhMC9zJLJSZNFURPNqALIFwd: "SpinShop", pqsHoMeZqwc3fXgLCQs1p21ImhAr6tPL: "SpinHome", dpsbx91fh7b0ve3qbfuoa0f7brme513i: "PLAY! Summit", sise3apsjuzewfkne2rmuuedwflq2ruc: "Sitecore Sales Engineering 3 AP", sise1aprs042qjutf9b9p94lx31bk8n8: "Sitecore Sales Engineering 1 AP", sise2usl84d0ouwq5w7zd4wvq1wn5xkd: "Sitecore Sales Engineering 2 US" } const reverseObject = (obj) => { const newObj = {}; Object.keys(obj).forEach(key => { if (newObj[obj[key]]) { newObj[obj[key]].push(key); } else { newObj[obj[key]] = [key]; } }); return newObj; }; const reverseClientKeyMap = reverseObject(clientKeyMap); const CREATE_DATAEXT_LAMBDA_URL = "https://w1x491x7ik.execute-api.eu-west-1.amazonaws.com/default/createDataExtension"; const CLIENTKEY_LOCALSTORAGE_KEY = "bxDataExtensionEditorClientKey"; if (window.location.href.includes("guests/list")) { console.log('guests/list'); setTimeout(function () { augmentGuestListUI(); addClickListnerToAddGuestBtn(); }, 3500); } let lastUrl = location.href; new MutationObserver(() => { const url = location.href; if (url !== lastUrl) { lastUrl = url; onUrlChange(); } }).observe(document, { subtree: true, childList: true }); function onUrlChange() { if (window.location.href.includes("section=properties")) { setTimeout(function () { augmentUIwithAddAndRmvButtons(); augmentUIForExtDefaultExtension(); }, 1000); } if (window.location.href.includes("guests/list")) { setTimeout(function () { augmentGuestListUI(); addClickListnerToAddGuestBtn(); }, 3500); } } function getGuestRef() { return window.location.href.split("/")[5].split("?")[0]; } function getCurrentClientKey() { return localStorage.getItem(CLIENTKEY_LOCALSTORAGE_KEY); } function setCurrentClientKey(clientKey) { localStorage.setItem(CLIENTKEY_LOCALSTORAGE_KEY, clientKey); } function augmentUIForExtDefaultExtension() { if (true) { var isExtUIAugmented = false; //this selector finds the "details" button next to the "Ext:" extension... $('.ng-star-inserted:contains("Ext:")').filter(function () { return $(this).text() == 'Ext:'; }).next().find("button") .click(function () { setTimeout(function () { if (isExtUIAugmented === false) { makeTableFieldsEditable(); insertAddAndSaveButtons(); insertDeleteButtons(); addExtClickListners(); } isExtUIAugmented = true; }, 1000); }); function addClickListnerToDeleteAttrBtn() { $(".deleteExtAttrBtn").click(function (event) { event.preventDefault(); $(this).parent().parent().prev().remove(); $(this).closest('div').remove(); enableSaveButton(); }); } function camelize(str) { return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) { return index === 0 ? word.toLowerCase() : word.toUpperCase(); }).replace(/\s+/g, ''); } function enableSaveButton() { $('#saveExtBtn').prop("disabled", false); $('#saveExtBtn').text("Save Changes"); } function disableSaveButton() { $('#saveExtBtn').prop("disabled", true); } function makeTableFieldsEditable() { $(".bx-json-as-table-data .ng-star-inserted").attr("contentEditable", true); $(".bx-json-as-table-key").attr("contentEditable", true); } function insertAddAndSaveButtons() { var addAttributeBtnHTML = "