Don Rhummy
Don Rhummy

Reputation: 25810

How do I get the absolute path of the chrome extensions directory?

I'm writing an app that has full access to the file system and I want to be able to get the absolute path of my extension's directory. How would I do this?

My app has permissions to "<all_urls>", {"filesystem": [ "write" ]} and has the "allow access to file urls" checked.

Upvotes: 1

Views: 6316

Answers (2)

mondersky
mondersky

Reputation: 471

chrome.extension.getURL is deprecated now. use this instead:

chrome.runtime.getURL('index.html');

Upvotes: 2

duckbrain
duckbrain

Reputation: 1279

If you mean the file system path, that differs on each operating system. You can find it by doing a file search for your extensions identifier.

If you want a chrome reference, you can use: chrome.extension.getURL(''); You can also provide something in the string and it will give you the path that you would need to reference the file contained in your app.

Example:

chrome.extension.getURL('index.html');

Returns:

"chrome-extension://gbchcmhmhahfdphkhkmpfmihenigjmpp/index.html"

Upvotes: 11

Related Questions