gpt4 book ai didi

javascript - 为什么 jQuery().remove() 和 unbind() 在 GreaseMonkey 中不起作用?

转载 作者:行者123 更新时间:2023-11-28 10:59:53 25 4
gpt4 key购买 nike

我尝试在 GreaseMonkey 脚本中使用 jQuery().remove()jQuery().unbind 方法(以及类似的函数),但事实并非如此在职的。不过,同样的调用在 fireBug 中也有效。我猜测这与 GM 沙箱以及范围完全关闭的事实有关。

我确实尝试使用unsafeWindow.jQuery,甚至声明window = unsafeWindow,但它没有帮助。

所有其他 jQuery 东西(例如 clone append )都工作完美。

大家对此有什么想法或建议吗?

编辑:代码:

(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(如果页面上尚未存在)的方法: http://joanpiedra.com/jquery/greasemonkey/

关于javascript - 为什么 jQuery().remove() 和 unbind() 在 GreaseMonkey 中不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5355350/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com