Using jQuery in Tampermonkey

后端 未结 1 1419
-上瘾入骨i
-上瘾入骨i 2021-01-01 18:05

I\'m using Chrome 27.0.1453.116 m and have enabled \"Experimental Javascript\", however I\'m unable to get jQuery to run on Tampermonkey.

I have tried:



        
1条回答
  •  醉梦人生
    2021-01-01 18:36

    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. (archived on 2015-03-12 from 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.

    0 讨论(0)
提交回复
热议问题