Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shortcut and default action #149

Merged
merged 1 commit into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions addon/background.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"use strict";
let sfHost = "";
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
// Perform cookie operations in the background page, because not all foreground pages have access to the cookie API.
// Firefox does not support incognito split mode, so we use sender.tab.cookieStoreId to select the right cookie store.
Expand All @@ -15,6 +16,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
chrome.cookies.get({url: request.url, name: "sid", storeId: sender.tab.cookieStoreId}, cookie => {
if (!cookie || currentDomain.endsWith(".mcas.ms")) { //Domain used by Microsoft Defender for Cloud Apps, where sid exists but cannot be read
sendResponse(currentDomain);
sfHost = currentDomain;
return;
}
const [orgId] = cookie.value.split("!");
Expand All @@ -25,6 +27,7 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
let sessionCookie = cookies.find(c => c.value.startsWith(orgId + "!"));
if (sessionCookie) {
sendResponse(sessionCookie.domain);
sfHost = sessionCookie.domain;
}
});
});
Expand All @@ -51,3 +54,14 @@ chrome.runtime.onInstalled.addListener(({reason}) => {
});
}
});
chrome.commands.onCommand.addListener((command) => {
//TODO home to open setup
chrome.tabs.create({
url: `chrome-extension://${chrome.i18n.getMessage("@@extension_id")}/${command}.html?host=${sfHost}`
});
});
chrome.action.onClicked.addListener(() => {
chrome.tabs.create({
url: `chrome-extension://${chrome.i18n.getMessage("@@extension_id")}/data-export.html?host=${sfHost}`
});
});
33 changes: 33 additions & 0 deletions addon/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,39 @@
"permissions": [
"cookies"
],
"action": {
"default_title": "Export data"
},
"commands": {
"apex-runner": {
"suggested_key": {
"default": "Ctrl+Shift+C",
"mac": "Command+Shift+C"
},
"description": "Run apex code"
},
"data-export": {
"suggested_key": {
"default": "Ctrl+Shift+E",
"mac": "Command+Shift+E"
},
"description": "Export data"
},
"data-import": {
"suggested_key": {
"default": "Ctrl+Shift+I",
"mac": "Command+Shift+I"
},
"description": "Import data"
},
"streaming": {
"suggested_key": {
"default": "Ctrl+Shift+T",
"mac": "Command+Shift+T"
},
"description": "Manage streaming"
}
},
"host_permissions": [
"https://*.salesforce.com/*",
"https://*.force.com/*",
Expand Down