删除服务器端生成的横幅广告 - Greasemonkey
我在飞机上,他们强制每个页面(包括这个 Stack Overflow 页面)顶部都有一个横幅,上面有他们的广告。
这是我在 Firefox 中为 UserScript 编写的代码,但它不起作用:
// ==UserScript==
// @name SW Ad remover
// @namespace seangates.com/sw_ad_remover
// @include *
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js
// ==/UserScript==
$(document).ready(function(){
$('script[src$="swa.py"]').remove();
$('div[id^="__swa"]').hide();
$('body').css('padding',0);
console.log('working');
});
有什么想法为什么这不起作用?即使我将 console.log 放在 read() 块的开头,我什至无法使其工作。
I am on an airplane flight and they are forcing every page (including this Stack Overflow page) to have a banner at the top with their ads on it.
Here is the code I have for my UserScript in Firefox, but it isn't working:
// ==UserScript==
// @name SW Ad remover
// @namespace seangates.com/sw_ad_remover
// @include *
// @require https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js
// ==/UserScript==
$(document).ready(function(){
$('script[src$="swa.py"]').remove();
$('div[id^="__swa"]').hide();
$('body').css('padding',0);
console.log('working');
});
Any thoughts as to why this would not be working? I can't even get a console.log to work even if I put it in the beginning of the ready() block.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Greasemonkey 不适用于 jQuery 1.4.4。
使用 jQuery 1.3.2。
请注意,您必须卸载然后重新安装脚本,以确保将正确的 jQuery 文件复制到您的 PC。
Greasemonkey does not work with jQuery 1.4.4.
Use jQuery 1.3.2.
Note that you will have to uninstall and then reinstall your script to ensure that the correct jQuery file is copied to your PC.
当然,这里总是可以选择不使用 jQuery,因为只有 Greasemonkey 实现了
@require
规则。document.querySelectorAll
仅在 IE8 及更高版本中可用,但在这里没关系。该脚本尚未测试,但应该可以工作。And of course, there's always the option of not using jQuery here, since only Greasemonkey has implemented the
@require
rules.document.querySelectorAll
is only available in IE8 and above, but that's alright here. This script has not tested, but it should work.