问题
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...
回答1:
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.
来源:https://stackoverflow.com/questions/52497039/can-tampermonkey-userscript-access-chrome-api