Can Tampermonkey Userscript access Chrome API?

大憨熊 提交于 2021-01-29 14:13:44

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!