How to embed additional jQuery plugins into Greasemonkey

爱⌒轻易说出口 提交于 2019-11-30 05:27:33

First, if you are OK with not having Firebug debugging access the easiest way to include jquery is to use the require settings:

// @require        http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js
// @require        http://ajax.googleapis.com/ajax/libs/jqueryui/1.5.2/jquery-ui.min.js 

Following that line you can include other external scripts. Most of the jquery plugins are not available like the jquery api, but you can host it yourself.

Using the require also allows you to dump all the loading code and simply go with:

$(document).ready( function() { ... });

Firebug will report bugs, but you will not be able to step into the debugger.

Additionally, once you have jquery loaded you can load other items to like so:

$('head').append("<link href='http://www.somewebsite.com/styles.css' type='text/css' rel='stylesheet'>"); 

Also checkout the GreaseMonkeyWiki pages on using JQuery in a GreaseMonkey script and on the @require block.

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