chinchang / chinchang/web-maker
The Chrome extension Always shows warning: the first argument to getMessage should be type "string"
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 323
- PR merge metrics
- No merged PRs in 30d
Description
## Meta info
lkfkkhfhhdkiemehlpkgjeojomhpccnh: the first argument to getMessage should be type "string", was undefined (type "undefined")
- Is this a bug or suggestion?:
Bug.
- Version (click on help icon in footer):
3.6.0
- Context - Web app, Chrome extension or both?:
Chrome extension only.
When you open the extension, it always show a warning message in the console.
````
lkfkkhfhhdkiemehlpkgjeojomhpccnh: the first argument to getMessage should be type "string", was undefined (type "undefined")
````
## Analysis
This warning is caused by the following code (in two places):
````
var origin = chrome.i18n.getMessage()
? `chrome-extension://${chrome.i18n.getMessage('@@extension_id')}`
: `${location.origin}`;
````
## Solution
The warning can be fixed by remove the "()" as the intention (I suppose) was to check if the function presents.
## Question
While the fix is simple, I have found that in my browser `location.origin` always return the same value as `chrome-extension://${chrome.i18n.getMessage('@@extension_id')}`.
So I have a question, why not just use `var origin = '' + location.origin`?
If we need the extension's id, `chrome.runtime.id` might be a better way according to the [documentation](https://chrome-apps-doc2.appspot.com/trunk/extensions/runtime.html)
Contributor guide
Assessment
This issue has not been assessed yet.