diff --git a/addon/background.js b/addon/background.js index 57bb6525..8b1bbfe1 100644 --- a/addon/background.js +++ b/addon/background.js @@ -27,7 +27,21 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { if (sessionCookie) { sendResponse(sessionCookie.domain); } else { - sendResponse(null); + chrome.cookies.getAll({name: "sid", domain: "salesforce.mil", secure: true, storeId: sender.tab.cookieStoreId}, cookies => { + sessionCookie = cookies.find(c => c.value.startsWith(orgId + "!")); + if (sessionCookie) { + sendResponse(sessionCookie.domain); + } else { + chrome.cookies.getAll({name: "sid", domain: "cloudforce.mil", secure: true, storeId: sender.tab.cookieStoreId}, cookies => { + sessionCookie = cookies.find(c => c.value.startsWith(orgId + "!")); + if (sessionCookie) { + sendResponse(sessionCookie.domain); + } else { + sendResponse(null); + } + }); + } + }); } }); } diff --git a/addon/button.js b/addon/button.js index a0714f2b..5a9a9d82 100644 --- a/addon/button.js +++ b/addon/button.js @@ -5,10 +5,9 @@ // sfdcBody = normal Salesforce page // ApexCSIPage = Developer Console // auraLoadingBox = Lightning / Salesforce1 -// location.host.endsWith("visualforce.com") = Visualforce page if (document.querySelector("body.sfdcBody, body.ApexCSIPage, #auraLoadingBox") || location.host.endsWith("visualforce.com")) { // We are in a Salesforce org - chrome.runtime.sendMessage({ message: "getSfHost", url: location.href }, sfHost => { + chrome.runtime.sendMessage({message: "getSfHost", url: location.href}, sfHost => { if (sfHost) { initButton(sfHost, false); } @@ -120,7 +119,7 @@ function initButton(sfHost, inInspector) { }); rootEl.appendChild(popupEl); function openPopup() { - popupEl.contentWindow.postMessage({ insextUpdateRecordId: true, locationHref: location.href }, "*"); + popupEl.contentWindow.postMessage({insextUpdateRecordId: true, locationHref: location.href}, "*"); rootEl.classList.add("insext-active"); // These event listeners are only enabled when the popup is active to avoid interfering with Salesforce when not using the inspector addEventListener("click", outsidePopupClick); diff --git a/addon/manifest-template.json b/addon/manifest-template.json index 10808124..e201f6f0 100644 --- a/addon/manifest-template.json +++ b/addon/manifest-template.json @@ -17,7 +17,12 @@ "https://*.salesforce.com/*", "https://*.force.com/*", "https://*.cloudforce.com/*", - "https://*.visualforce.com/*" + "https://*.visualforce.com/*", + "https://*.salesforce.mil/*", + "https://*.force.mil/*", + "https://*.cloudforce.mil/*", + "https://*.visualforce.mil/*", + "https://*.crmforce.mil/*" ], "content_scripts": [ { @@ -27,7 +32,14 @@ "https://*.vf.force.com/*", "https://*.lightning.force.com/*", "https://*.cloudforce.com/*", - "https://*.visualforce.com/*" + "https://*.visualforce.com/*", + "https://*.salesforce.mil/*", + "https://*.visual.force.mil/*", + "https://*.vf.force.mil/*", + "https://*.lightning.force.mil/*", + "https://*.cloudforce.mil/*", + "https://*.visualforce.mil/*", + "https://*.crmforce.mil/*" ], "all_frames": true, "css": ["button.css", "inspect-inline.css"], diff --git a/addon/manifest.json b/addon/manifest.json index c6a949b6..1737080c 100644 --- a/addon/manifest.json +++ b/addon/manifest.json @@ -11,7 +11,12 @@ "https://*.salesforce.com/*", "https://*.force.com/*", "https://*.cloudforce.com/*", - "https://*.visualforce.com/*" + "https://*.visualforce.com/*", + "https://*.salesforce.mil/*", + "https://*.force.mil/*", + "https://*.cloudforce.mil/*", + "https://*.visualforce.mil/*", + "https://*.crmforce.mil/*" ], "content_scripts": [ { @@ -21,7 +26,14 @@ "https://*.vf.force.com/*", "https://*.lightning.force.com/*", "https://*.cloudforce.com/*", - "https://*.visualforce.com/*" + "https://*.visualforce.com/*", + "https://*.salesforce.mil/*", + "https://*.visual.force.mil/*", + "https://*.vf.force.mil/*", + "https://*.lightning.force.mil/*", + "https://*.cloudforce.mil/*", + "https://*.visualforce.mil/*", + "https://*.crmforce.mil/*" ], "all_frames": true, "css": ["button.css", "inspect-inline.css"], diff --git a/addon/popup.js b/addon/popup.js index 03534050..a14ebec8 100644 --- a/addon/popup.js +++ b/addon/popup.js @@ -1571,7 +1571,7 @@ function getRecordId(href) { // Find record ID from URL let searchParams = new URLSearchParams(url.search.substring(1)); // Salesforce Classic and Console - if (url.hostname.endsWith(".salesforce.com")) { + if (url.hostname.endsWith(".salesforce.com") || url.hostname.endsWith(".salesforce.mil")) { let match = url.pathname.match(/\/([a-zA-Z0-9]{3}|[a-zA-Z0-9]{15}|[a-zA-Z0-9]{18})(?:\/|$)/); if (match) { let res = match[1]; @@ -1582,7 +1582,7 @@ function getRecordId(href) { } // Lightning Experience and Salesforce1 - if (url.hostname.endsWith(".lightning.force.com")) { + if (url.hostname.endsWith(".lightning.force.com") || url.hostname.endsWith(".lightning.force.mil") || url.hostname.endsWith(".lightning.crmforce.mil")) { let match; if (url.pathname == "/one/one.app") {