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开发者_JAVA技巧==
$(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.
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.
And of course, there's always the option of not using jQuery here, since only Greasemonkey has implemented the @require
rules.
var s = document.querySelectorAll('script[src$="swa.py"]'),
d = document.querySelectorAll('div[id^="__swa"]');
for(var i = 0; i < s.length; i++){
s[i].parentNode.removeChild(s[i]);
}
for(i = 0; i < d.length; i++){
d[i].style.display = 'none';
}
document.body.style.padding = '0px';
document.querySelectorAll
is only available in IE8 and above, but that's alright here. This script has not tested, but it should work.
精彩评论