I am developing a userscript that requiers chrome object, but I can't access it. How to access to chrome object inside tampermonkey's userscript? Maybe, some permissions in manifest or what...
Asked
Active
Viewed 1,636 times
0
Vignesh Raja
- 6,851
- 1
- 28
- 39
Kenya-West
- 332
- 2
- 17
-
1You can only access the web-exposed `unsafeWindow.chrome` object but *only if it's defined for that page, which is not guaranteed*. It has just a few basic methods like chrome.runtime.sendMessage. – wOxxOm Sep 25 '18 at 11:39
1 Answers
2
Refer to Chrome extension code vs Content scripts vs Injected scripts.
Chrome extensions can access Chrome APIs and Tampermonkey is an extension.
However, Tampermonkey must make a given API's functionality to a userscript via GM_ functions.
If there is not a GM_ function for what you want, then you must find another way or write a Chrome extension instead of a Tampermonkey script.
Brock Adams
- 86,878
- 22
- 220
- 282