Using jQuery in Tampermonkey

半世苍凉 提交于 2019-12-03 10:35:28

EDIT: Since Greasemonkey 2.0 you do not (and cannot) use unsafeWindow.jQuery for getting the host page's instance of jQuery. You just use window.jQuery, and // @grant none (or @grant whatever other special APIs you need for non-jQuery things).

Sources: https://github.com/greasemonkey/greasemonkey/issues/1952
http://www.greasespot.net/2014/06/greasemonkey-20-release.html

Tampermonkey currently (Feb 2015) seems to work similarly by default settings: http://tampermonkey.net/faq.php#Q404


old outdated answer below:

Add a directive // @grant unsafeWindow. Also, if you are getting your jQuery reference from the host window object, you won't need the @require line.

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