Last active
February 6, 2023 16:26
-
-
Save syoichi/3747507 to your computer and use it in GitHub Desktop.
Chrome拡張で自身のIDを取得する方法
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ref. http://stackoverflow.com/questions/12471316/what-is-the-best-way-to-retrieve-a-google-chrome-extension-id | |
// https://plus.google.com/100132233764003563318/posts/Ct39rw4DWGE | |
chrome.i18n.getMessage('@@extension_id'); | |
// via https://github.com/Constellation/taberareloo/blob/d1299f052f14a3dfcb212eda0e3428c5f5c8a027/src/lib/content.js#L79 | |
chrome.extension.getURL('').match(/chrome-extension:\/\/([^\/]+)\//)[1]; | |
// Content Scriptでは動作しない | |
chrome.app.getDetails().id; | |
// via https://developer.chrome.com/extensions/runtime.html | |
// バージョン22より使用可能 | |
chrome.runtime.id; | |
chrome.runtime.getURL('').match(/chrome-extension:\/\/([^\/]+)\//)[1]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment