我相信 jQuery 的 :nth-child 选择器在 GreaseMonkey 0.8 中不起作用。(底部是一个快速的 GM 脚本来测试它。)这是为什么?这是在 GreaseMonkey 内部工作的已知限制吗?任何人都可以推荐一种解决方法吗?
另外,为什么一些(绝对不是全部)jQuery 查询在 GreaseMonkey 中运行得慢得多,我现在没有快速的基准测试,但我经常注意到它,因为我正在构建一个非常复杂的依赖于 GM 脚本重度在通用汽车。我会在 GM 之外,在 Firebug 中运行我的代码,事情会变得很敏捷,而在 GM 内部,浏览器就会瘫痪。我知道这很模糊,但我想知道在 GM 或 jQuery 中是否存在一些广泛的架构原因,为什么会出现这种情况。
谢谢!
// ==UserScript==
// @name Test of nth-child
// @namespace http://elzr.com
// @description nth-child doesn't work in jQuery within GreaseMonkey
// @include http://en.wikipedia.org/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js
// @author Eliazar Parra elzr.com
// ==/UserScript==
//
// For detailed info and screenshots see http://elzr.com/posts/wikipedia-backbars
$(document).ready(function() {
console.log($('a:nth-child(1)').length)
});