Is it possible to query salesforce through its REST-API using a greasemonkey/tampermonkey script only ?

If yes, can someone give me a hint on howw to achieve that. I have been going through jsforce.js documentation but could not find any substantial results.

If it is not possible thorugh a standalone greasemonkey script, what else can I do to enable the use of gresemonkey script to query salesforce.

I do know the details of making a connected app and usage of OAUTH 2.0 to get access token.I will preferably want to use User-Agent Flow for authentication.

Any sort of help will be great.

*Edit: Presently I am using jsforce.js to try and achieve this. I am able to get to the pop-up window that ask for user-credentials and returns the access-token and refresh-token via the callback-url. But, since all this is in a pop-up window, I am not able to access this from a script running in another window. Is there some way to achieve this ? (since I am using purely a client side script, there is no intermediate server running. I am using https://login.salesforce.com/services/oauth2/success as the call back URL)

2 Answers 2


Assuming you're already logged in to salesforce, you can use the sid from the document's cookie variable. At this point, you just need to call the API, as normal. See the REST API documentation for general usage.

  • Thanks for your consideration. I'm sorry I was not clear enough in the question. While using greasemonkey script,catching the access token is the major problem. The pop-up window to get salaesforce authentication and returning the access-token along with the callback url is not accessible from the greasemonkey script running in another window. Is there some way I can do this ? (presently I am using jsforce.js to achieve this. Do you suggest any alternative way ?)
    – Starney
    May 16, 2015 at 5:07

You should save the sid in a variable in JS, then pass this back to the parent using a script.

There's a little example here where it explains how to write the code and how to pass it back etc...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .