0

I am having an interesting doubt.

In a Chrome extension, can I directly access sforce js file using content script of Chrome extension or any other ways?

So my Chrome extension manifest is -

{
  "manifest_version": 2,

  "name": "GTmetrix Analyzer Plugin",
  "description": "This extension will analyze a page using GTmetrix",
  "version": "1.0",
  "page_action": {
   "default_icon": "icon.png"
  },
  "content_scripts": [
    {
      "matches": ["*://*.salesforce.com/*"],
      "js": ["jquery-1.12.1.min.js","contentscript.js"]
    }
  ],
  "permissions": [
   "tabs", "*://*.salesforce.com/*"
   ],
   "background": {
    "page": "popup.html"
  }
}

Here you can see I have a content script which will be embedded inside the html page. I understand my content script can access the DOM but it is not able to use any of the SF default global variables.

My content script code -

console.log('Hello world from content script');
console.log('SF Session id -->' + '{!$Api.Session_Id}');

second console log is always undefined.

My final intention is to be able to use sforce.connection to be able to query on SF database, but can add that to a different question

Thanks, Ray

  • Of course you can. I think you're asking the wrong question. Could you post some code? – sfdcfox Feb 28 '16 at 22:22
  • Directly accessing sforce.js is not supported, so should not be relied upon for anything used in production apps or functionality. – pchittum Feb 28 '16 at 23:29
  • @sfdcfox , Added code base and further details – Kaushik Ray Feb 29 '16 at 4:44
  • @Peter, any way that content script may use the sforce.js? may be Oauth in JS ? – Kaushik Ray Feb 29 '16 at 4:45
  • Did you find any answer for that? I am interested to know this. when I googled I found, ForceTK (using Rest) can help. But not tried. Please let me know, if you have achieved the same. – Ysr Shk Nov 23 '16 at 7:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.