Created
November 21, 2025 15:37
-
-
Save mems/5ea85f32a12732ced149c20e9374e1d5 to your computer and use it in GitHub Desktop.
Search in Adobe Tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Aka launch search, search launch, search in adobe launch | |
| const term = prompt("What are you looking for?"); | |
| // React store is exposed, see webpack://lens/app/utils/storeUtils.js | |
| // By "Main Content" frame (exc-app-sandbox-*) ...?lens_env=prod&_mr=p_cf_runtime.252c2090&shell_domain=experience.adobe.com&appId=launchDataCollection&reactor-lens_version=prod20250718203054 | |
| // It allow us to access some data | |
| const state = ( | |
| window.getStore?.() ?? | |
| document | |
| .querySelector("iframe[name='Main Content']") | |
| ?.contentWindow?.getStore() ?? | |
| (() => { | |
| throw new TypeError( | |
| "window.getStore() not found! Try with an other window context", | |
| ); | |
| })() | |
| ).getState(); | |
| const propertyID = state.api.property.id; | |
| const companyID = state.company.companyMatchingActiveOrg.id; | |
| const orgID = state.api.profile.attributes.activeOrg; //userData.profile.attributes.activeOrg;// window.corpId | |
| const accessToken = state.ims.imsAccessToken; //window.userData.imsAccessToken; | |
| const clientID = state.ims.clientId; //userData.clientId;//"Activation-DTM"; | |
| const openedPromise = new Promise((resolve) => { | |
| const opened = window.open( | |
| URL.createObjectURL( | |
| new Blob( | |
| [ | |
| document.implementation.createHTMLDocument( | |
| `Search result for ${term}`, | |
| ).documentElement.outerHTML, | |
| ], | |
| { type: "text/html" }, | |
| ), | |
| ), | |
| ); | |
| opened.addEventListener("load", () => resolve(opened)); | |
| }); | |
| openedPromise.then( | |
| ({ document }) => | |
| (document.body.innerHTML = ` | |
| <div id="content" aria-busy="true" aria-describedby="progress"></div> | |
| <progress id="progress" aria-label="Content loading…"></progress> | |
| `), | |
| ); | |
| let resources = []; | |
| // loop over pages | |
| for (let from = 0; ; ) { | |
| const { | |
| data, | |
| meta: { total_hits: totalHits }, | |
| } = await ( | |
| await fetch("https://reactor.adobe.io/search", { | |
| method: "POST", | |
| headers: { | |
| accept: "application/vnd.api+json;revision=1", | |
| authorization: `Bearer ${accessToken}`, | |
| "x-api-key": clientID, | |
| "content-type": "application/vnd.api+json", | |
| "x-gw-ims-org-id": orgID, | |
| }, | |
| mode: "cors", | |
| body: JSON.stringify({ | |
| data: { | |
| from: from, | |
| size: 100, | |
| query: { | |
| "attributes.*": { value: term }, | |
| "relationships.property.data.id": { | |
| value: propertyID, | |
| }, | |
| "attributes.revision_number": { value: 0 }, // get the latest revision. | |
| "attributes.deleted_at": { exists: false }, // only get resources that have not been deleted | |
| }, | |
| resource_types: [ | |
| "rules", | |
| "rule_components", | |
| "data_elements", | |
| //"extensions", | |
| ], | |
| }, | |
| }), | |
| }) | |
| ).json(); | |
| resources = resources.concat(data); | |
| if (totalHits <= from + data.length) break; | |
| } | |
| const urls = await Promise.all( | |
| resources.map(async ({ id, type, relationships }) => { | |
| switch (type) { | |
| case "rules": | |
| return `https://experience.adobe.com/solutions/reactor-lens/tags/companies/${companyID}/properties/${propertyID}/rules/${id}`; | |
| case "data_elements": | |
| return `https://experience.adobe.com/solutions/reactor-lens/tags/companies/${companyID}/properties/${propertyID}/dataElements/${id}`; | |
| case "rule_components": | |
| const { | |
| data: [{ id: ruleID }], | |
| } = await ( | |
| await fetch( | |
| relationships.rules.links.related /* + "?page[size]=999"*/, | |
| { | |
| method: "GET", | |
| headers: { | |
| accept: "application/vnd.api+json;revision=1", | |
| authorization: `Bearer ${accessToken}`, | |
| "x-api-key": clientID, | |
| "content-type": "application/vnd.api+json", | |
| "x-gw-ims-org-id": orgID, | |
| }, | |
| mode: "cors", | |
| }, | |
| ) | |
| ).json(); | |
| return `https://experience.adobe.com/solutions/reactor-lens/tags/companies/${companyID}/properties/${propertyID}/rules/${ruleID}/ruleComponent/${id}`; | |
| } | |
| }), | |
| ); | |
| const opened = await openedPromise; | |
| const content = opened.document.getElementById("content"); | |
| content.ariaDescribedByElements = []; | |
| opened.document.getElementById("progress").remove(); | |
| const list = opened.document.createElement("ul"); | |
| list.append( | |
| ...urls.map((url) => { | |
| const a = opened.document.createElement("a"); | |
| a.href = url; | |
| a.textContent = url; | |
| const li = opened.document.createElement("li"); | |
| li.append(a); | |
| return li; | |
| }), | |
| ); | |
| content.append(list); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment