11 ŞUBAT 2010, PERŞEMBE
Nasıl Google Chrome Greasemonkey komut jQuery kullanabilir miyim?
Bazılarınızın bildiği gibi, Google Chrome Greasemonkey scriptleri biraz ağır sınırlama getirmiş.
Krom*,
@resource
, , *, *5unsafeWindow
*4@require
, veyaGM_getValue
desteklemiyor.
İhtiyaç olmadan Google Chrome altında Greasemonkey script jQuery Kütüphanesi dahil etmek için bir yol bulamıyorum.
Kimsenin bu konuda bir tavsiye var mı?
CEVAP
23 AĞUSTOS 2010, PAZARTESİ
http://erikvold.com/blog/index.cfm/2010/6/14/using-jquery-with-a-user-script
// ==UserScript==
// @name jQuery For Chrome (A Cross Browser Example)
// @namespace jQueryForChromeExample
// @include *
// @author Erik Vergobbi Vold & Tyler G. Hicks-Wright
// @description This userscript is meant to be an example on how to use jQuery in a userscript on Google Chrome.
// ==/UserScript==
// a function that loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function() {
var script = document.createElement("script");
script.textContent = "window.jQ=jQuery.noConflict(true);(" callback.toString() ")();";
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
// the guts of this userscript
function main() {
// Note, jQ replaces $ to avoid conflicts.
alert("There are " jQ('a').length " links on this page.");
}
// load jQuery and execute the main function
addJQuery(main);
Bunu Paylaş:
Nasıl Greasemonkey jQuery kullanabilir...
Nasıl Google Chrome bir sekme için bir...
Chrome komut dosyası hata ayıklayıcısı...
Nasıl gecikme kullanabilir miyim() sho...
Nasıl bir yönlendirme sayfası jQuery k...