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 2,282 times
        
    2
            
            
         
    
    
        Vignesh Raja
        
- 7,927
- 1
- 33
- 42
 
    
    
        Kenya-West
        
- 392
- 2
- 18
- 
                    2You 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
4
            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
        
- 90,639
- 22
- 233
- 295