Javascript 为什么';t jQuery().remove()和unbind()在GreaseMonkey中工作吗?
我试图在greaseMonkey脚本中使用Javascript 为什么';t jQuery().remove()和unbind()在GreaseMonkey中工作吗?,javascript,jquery,greasemonkey,Javascript,Jquery,Greasemonkey,我试图在greaseMonkey脚本中使用jQuery().remove()和jQuery().unbind方法(和类似的函数),但它不起作用。不过,在fireBug中也可以使用相同的调用。我猜这与GM沙箱和范围完全关闭的事实有关 我确实尝试过使用unsafeWindow.jQuery,甚至声明了window=unsafeWindow,但没有任何帮助 所有其他jQuery功能(如克隆附加)都工作正常 有人对此有什么想法或建议吗 编辑:代码: (function($) { var chan
jQuery().remove()
和jQuery().unbind
方法(和类似的函数),但它不起作用。不过,在fireBug中也可以使用相同的调用。我猜这与GM沙箱和范围完全关闭的事实有关
我确实尝试过使用unsafeWindow.jQuery
,甚至声明了window=unsafeWindow
,但没有任何帮助
所有其他jQuery功能(如克隆附加
)都工作正常
有人对此有什么想法或建议吗
编辑:代码:
(function($) {
var changeURLs = function() {
var window = unsafeWindow;
$('.link-results li').each(function() {
var $a = $(this).find('a'), directUrl;
if ($a.hasClass('redirect')) return;
$a.unbind('click'); //!! Not working
if (/sidereel\.com/.test($a[1].href)) { // Megavideo like link
$.get($a[1].href, function(data) {
directUrl = $(data).find('.play-link')[0].innerHTML;
$a[1].href = $a[2].href = directUrl;
$a.each(function() {
unsafeWindow.console.log( $(this).remove() ); //!! Not working
});
});
} else { // Sponsered link
$a[2].href = $a[1].href;
}
$a.addClass('redirect');
});
},
$thickBox = $('.ui-dialog-content');
if ($thickBox.length) $thickBox.dialog('close')
changeURLs();
jQuery('.link-results-container').bind('DOMNodeInserted', changeURLs);
})(unsafeWindow.jQuery);
下面是另一个从google加载JQuery的方法,如果页面上还没有JQuery:
@motionman95:所有的都怎么样?