Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Disable Flash ads in Mozilla-based browsers Web Browsers
I received the following hint via email from Dan, which repeats a hint he posted on his blog. Here's how Dan removed Flash banner ads in Chimera (and Mozilla and probably Netscape as well). Please note that "I" in the following section refers to Dan, not me!

I managed to disable those annoying Flash banner ads in Chimera (I most often see them on Wired.com). Since you probably don't have one, create a file called userContent.css in your Chimera user chrome directory, which is located at ~/Library -> Application Support -> Chimera -> Profiles -> default -> random -> chrome. Replace 'random' with the name of the directory, which is usually a string of random characters followed by '.slt'. In the new userContent.css file, enter the following:
/* this hides the usual 468x60 Flash banner ads */
embed[type="application/x-shockwave-flash"][width="468"][height="60"] {
display: none !important;
visibility: hidden !important;
}
/* this hides the not so usual but very annoying 728x90 Flash banner ads */
embed[type="application/x-shockwave-flash"][width="728"][height="90"] {
display: none !important;
visibility: hidden !important;
}
Now restart Chimera and it should work.

I (Rob again now) have shortened and slightly edited Dan's email; you can read the full text of the original post on his blog site. I tested this hint with Chimera and cnn.com, which runs a highly annoying vertical Flash ad down the side of the main page, and it worked perfectly! Thanks Dan!
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[46,778 views]  

Disable Flash ads in Mozilla-based browsers | 24 comments | Create New Account
Click here to return to the 'Disable Flash ads in Mozilla-based browsers' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Slick
Authored by: jgmanning on Nov 27, '02 01:14:42PM

Good way to target ads. I just disable Flash altogether by moving the plugins out of /Library/Internet Plug-ins. Any site that depends on Flash for user navigation or content doesn't get my views.

For the occasional site where I want to view the Flash stuff (i.e., Icebox.com), I just drag the plugins into the folder and relaunch the browser.



[ Reply to This | # ]
blocking img ads
Authored by: mkoz on Nov 27, '02 02:50:08PM

i took a guess and added the following to the userContent.css file to try and block image ads.

img[width="468"][height="60"] {
display: none !important;
visibility: hidden !important;
}
img[width="125"][height="125"] {
display: none !important;
visibility: hidden !important;
}

and it seems to work. the only thing i noticed was that the images still show up if the height and width are not set in the img tag. so it doesn't matter what size the image really is as long as the height and width attributes match.

does anyone know of a way to have a gray box or something drawn in place of the image, or put another image there? so i could see that and image was removed/blocked.



[ Reply to This | # ]
creating css files...
Authored by: r duke on Nov 27, '02 07:06:58PM

How does one "create" a css file? Any help would be 'preciated...



[ Reply to This | # ]
some aswers
Authored by: ceebee on Nov 27, '02 08:21:14PM
>How does one "create" a css file?
Its a Plain Text file whose name ends with ".css" use any text editor to make it.

>does anyone know of a way to have a gray box or something drawn in place of the image
Not with CSS alone -- you've told the element not to display at all so any effect would also not be displayed (although would love to be proved wrong!)

Also the line visibility: hidden !important; in the examples is redundant (except in some rare circumstances), the image has already been instructed not to display itself so it's visibilty is irrelevent.You only need to use either one or the other rules depending on the rendering effect that you prefer...

display: none !important; means "don't render the contents of this element -- its effect is to flow the HTML onto the page as thought the element was not present.
visibility: hidden !important; means make the element invisible -- its effect is to flow the HTML onto the page as thought the element IS there but makes it invisible. ie. in this case it would appear as though there was a transparent image in place of the "original"

... also for those interested this is what the CSS Selector img[width="125"][height="125"] means ; choose all the IMG tags that have an Attribute width="125" and an Attribute height="125"' -- the square brackets are Attribute Selectors, in a sense the actual image is irrelevent to the CSS it only cares about the HTML element (the tag not the image) which is why it ignores the Ads with no height or width defined by the HTML.


[ Reply to This | # ]
image blocking from server AND CERTAIN PATH
Authored by: cynikal on Nov 28, '02 12:18:24AM

I put CERTAIN PATH in emphasis because I've been looking a way to do this for a while..

We all know mozilla can block images from certain servers but what happens if the website both the images and the ads from the server? You will block both the images you want to see and the ads also if you 'block images from server'.

Well i did some research and it turns out, you can use userContent.css to block IMG's with the SRC attribute beginning with a certain URL.

Here's an example i'm using to block images from the www.nytimes.com web site. Since all the images are served from graphics7.nytimes.com but ONLY ads begin with the /adx/images or /ads/ path.. here is what i added to my userContent.css:

/* block NYTimes banner ads */
IMG[src^="http://graphics7.nytimes.com/adx/images/"] {
display: none !important;
visibility: hidden !important;
}
/* block NYTimes banner ads */
IMG[src^="http://graphics7.nytimes.com/ads/"] {
display: none !important;
visibility: hidden !important;
}

The trick here is using SRC^= instead of just SRC= so that you match whatever it begins with, instead of an exact match. This is somewhat similar to regular expressions. You can also use use SRC*="/banners/" to match all url that contains /banners/ in the URL. Also there's SRC$='.gif' to match all gif images. I believe this is the extent of CSS3 selector pattern matching. if there's more pattern matching capabilities, please let me know.



[ Reply to This | # ]
image blocking from server AND CERTAIN PATH
Authored by: Johnny_B on Nov 28, '02 01:43:19AM

Is it possible to do this with flash banners as well. If so, how ?



[ Reply to This | # ]
image blocking from server AND CERTAIN PATH
Authored by: cynikal on Nov 29, '02 12:10:26PM

you have to make sure you're putting the file, userContent.css in the right path.. it should be something like

/Users/<yourUserName>/Library/Applications_Support/Chimera/Profiles/default/<randomstring>.slt/chrome/userContent.css

the _ should be a space and the stuff in < > should be changed (but not include the brackets < >).

Also you need to be using a netscape/mozilla/chimera flavor browser of course (the above only applies to Chimera, the paths are different for the other two browsers).



[ Reply to This | # ]
image blocking from server AND CERTAIN PATH
Authored by: cynikal on Nov 29, '02 12:11:44PM

oops, the above reply was meant for the guy who said he couldn't get it to work.



[ Reply to This | # ]
image blocking from server AND CERTAIN PATH
Authored by: cynikal on Nov 29, '02 12:42:34PM

this hint is ABOUT flash banners! Your flash banner is probably a different size.. the original hint is size-dependant.

Look at the html source and determine the dimensions of the flash banner. Then take the sample code from the original hint and change the dimensions listed.

Note that css applies to html definitions, meaning it only works if in the html the dimensions are specified (i.e. for an image), but if the dimensions aren't specified then the dimensions of an image are irrelevant.



[ Reply to This | # ]
image blocking from server AND CERTAIN PATH
Authored by: whoadoggy on Nov 28, '02 03:35:02AM

I have tried these hints with no success yet. It looks like the userContent.css file doesn't get loaded even after a quit/restart. Is there some cache that could need to be dumped in order for this to function?
Thanks



[ Reply to This | # ]
image blocking from server AND CERTAIN PATH
Authored by: cynikal on Nov 29, '02 12:37:30PM

Sorry i meant to reply to you here:

http://www.macosxhints.com/comment.php?mode=display&sid=20021127061854547&title=image+blocking+from+server+AND+CERTAIN+PATH&type=article&order=&pid=14894



[ Reply to This | # ]
CSS just hide items, but...
Authored by: gabble on Nov 28, '02 04:43:27AM

If you set a diplay rule to 'none' and/or visibility to 'hidden', you just hide items, but they still get loaded along with the page. What's the point, then? This trick does not reduce page loading time at all...

There should be a way to skip HTTP requests of specified (by name, path, or both) page elements...



[ Reply to This | # ]
CSS just hide items, but...
Authored by: metiure on Nov 28, '02 11:12:46AM

the solution is to use commercial filters like NetBarrier, which can easily be configured to deny requests to most ads servers. This way, connection speed improves amazingly!

vic



[ Reply to This | # ]
works great -- thanks
Authored by: kwalker on Nov 28, '02 02:29:29PM

This works great for me. I had been looking for a way to block only certain paths from a server (something iCab was very good at). Thanks!



[ Reply to This | # ]
You don't need both display and visibility
Authored by: endquote on Nov 30, '02 01:28:05AM
There's no need to set both the display and visibility properties. If you set display to none, the object will not appear, and will not take up space. So, for example, if you had a flash ad at the top of the page and set the display to none, the content of the page would start up higher.

If instead, you set the visibility to hidden, the space would still be taken up, but you wouldn't see it. So that would help in telling when things were being filtered.

Either way, though, it doesn't really solve the problem. You are still using bandwidth to download the ad, and in the case of Flash ads, using considerable CPU time to render them. A better solution would be an ad-filtering proxy - Webwasher is a good one, but is unfortunately only availble for OS 9. Has someone else made one for X?

[ Reply to This | # ]

Privoxy to the rescue...
Authored by: osax on Nov 30, '02 12:33:59PM

Instead of waiting for WebWasher to get X native, head over to sourceforge.net and grab privoxy 3. It will block ads and protect your privacy (http://www.privoxy.org/).



[ Reply to This | # ]
Privoxy to the rescue...
Authored by: cynikal on Dec 02, '02 01:50:13PM

been there, done that.. the problem i have with privoxy is that it removes the browser's default behaviour of auto-completing urls. i.e.. you type in cnn and it adds www. and .com, it's a lot more convenient than typing out the whole address.

sure it might seem like a minor thing, but it bugs me enough to not use it (since i have set up my chimera/mozilla browsers to pretty much filter out 95% of advertisements anyway).

and i've looked into gettting privoxy to do the url auto completition but the privoxy developers even admitted this is a bug and said they hope to have it fixed "soon".



[ Reply to This | # ]
Thanks!
Authored by: asxless on Dec 02, '02 11:32:17PM

Thanks for this tip.

I had grown so tired of seeing the same heavily animated adds on the WSJ web site that I was about to cancel my subscription. But
embed[type="application/x-shockwave-flash"][width="120"][height="600"] {
display: none !important;
visibility: hidden !important;
}
got rid of the HP ad on the left hand "nav bar" and normal ad blocking in Moz killed the animated gif BMW ad on the right:)

The irony is that I own 2 BMWs and a couple of HP printers. But these heavily animated ads are so annoying that I could not stand to see them one more time. I wonder if these advertisers realize that heavily animated ads can actually _detract_ from their company's/product's image with some customers. Animation is a two edged sword. It gets my attention. But after I've seen the same Flash or animated gif for the 10th time I don't see any real difference between a tastefully done animated ad and a dancing monkey ad. And more importantly I find the companies who ask me to view their heavily animated ads equally annoying.

asxless in iLand



[ Reply to This | # ]
Wish it used Image Blocking list
Authored by: frankie1969 on Jan 17, '03 12:26:01PM

Even better would be if Mozilla.org implemented OBJECT and SCRIPT blocking in the same way that it currently has Image and Cookie blocking.

There are plenty of sites that I want to see Flash from, and a whole bunch of others that I don't. For starters, I never want to see Flash from 3rd parties.



[ Reply to This | # ]
Currently not working
Authored by: banfiz on Apr 14, '03 06:37:45PM

Well I copied and pasted this code into my userContents.css file
but in the lastest version of Safari (Beta 2 v73), flash ads are
still being displayed on www.nzoom.com.



[ Reply to This | # ]
Disable Flash ads in Mozilla-based browsers
Authored by: JongAm on Jun 29, '03 12:59:12PM

Can this be applied to the Safari? I think it can be.
The Safari has a preference pane for choosing stylesheet.. so...
Is there anyone who tried?



[ Reply to This | # ]
Disable Flash ads in Mozilla-based browsers
Authored by: pecosbill on Mar 11, '04 02:18:27PM
I tried the above css code in Safari and it didn't kill the offending ad though I'm still working on it. I obtained the following elsewhere (wish I could attribute it) and it does work in Safari:

/*
 * turns off "blink" element blinking
 */
blink { text-decoration: none ! important; }

/*
 * hides many ads by preventing display of images that are inside
 * links when the link HREF contans certain substrings.
 */

A:link[HREF*="ad."] IMG { display: none ! important }
A:link[HREF*="ads."] IMG { display: none ! important }
A:link[HREF*="Ad."] IMG { display: none ! important }
A:link[HREF*="Ads."] IMG { display: none ! important }
A:link[HREF*="/ad"] IMG { display: none ! important }
A:link[HREF*="/A="] IMG { display: none ! important }
A:link[HREF*="/click"] IMG { display: none ! important }
A:link[HREF*="?click"] IMG { display: none ! important }
A:link[HREF*="?banner"] IMG { display: none ! important }
A:link[HREF*="=click"] IMG { display: none ! important }
A:link[HREF*="/ar.atwo"] IMG { display: none ! important }
A:link[HREF*="spinbox."] IMG { display: none ! important }
A:link[HREF*="transfer.go"] IMG { display: none ! important }
A:link[HREF*="adfarm"] IMG { display: none ! important }
A:link[HREF*="bluestreak"] IMG { display: none ! important }
A:link[HREF*="doubleclick"] IMG { display: none ! important }
A:link[HREF*="backbeatmedia.com"] IMG { display: none ! important }
A:link[HREF*="houseads"] IMG { display: none ! important }
A:link[HREF*="/sponsor"] IMG { display: none ! important }
A:link[HREF*="tribalfusion.com"] IMG { display: none ! important }
A:link[HREF*="mediaplex"] IMG { display: none ! important }
A:link[HREF*="bluestreak"] IMG { display: none ! important }
A:link[HREF*="adserver"] IMG { display: none ! important }

/* disable ad iframes */
IFRAME[SRC*="ad."]  { display: none ! important }
IFRAME[SRC*="ads."]  { display: none ! important }
IFRAME[SRC*="Ad."]  { display: none ! important }
IFRAME[SRC*="Ads."]  { display: none ! important }
IFRAME[SRC*="/ad"]  { display: none ! important }
IFRAME[SRC*="/A="]  { display: none ! important }
IFRAME[SRC*="/click"]  { display: none ! important }
IFRAME[SRC*="?click"]  { display: none ! important }
IFRAME[SRC*="?banner"]  { display: none ! important }
IFRAME[SRC*="=click"]  { display: none ! important }
IFRAME[SRC*="/ar.atwo"]  { display: none ! important }
IFRAME[SRC*="spinbox."]  { display: none ! important }
IFRAME[SRC*="transfer.go"]  { display: none ! important }
IFRAME[SRC*="adfarm"]  { display: none ! important }
IFRAME[SRC*="bluestreak"]  { display: none ! important }
IFRAME[SRC*="doubleclick"]  { display: none ! important }
IFRAME[SRC*="tribalfusion"]  { display: none ! important }
IFRAME[SRC*="vibrantmedia"]  { display: none ! important }
IFRAME[SRC*="mediaplex"]  { display: none ! important }
IFRAME[SRC*="bluestreak"]  { display: none ! important }
IFRAME[SRC*="adserver"]  { display: none ! important }

xIMG[usemap] { display: none ! important }

/* turning some false positives back off */

A:link[HREF*="download."] IMG { display: inline ! important }
A:link[HREF*="click.mp3"] IMG { display: inline ! important }

---
Pecos Bill

[ Reply to This | # ]

Block not just Flash, but (almost) every kind of ad
Authored by: TrumpetPower! on Aug 02, '04 11:58:56PM

The Firefox help document here:

http://texturizer.net/firefox/adblock.html

Works just as well for Safari. But, instead of just blocking Flash ads, the CSS blocks almost all advertisements.

Cheers,

b&



[ Reply to This | # ]
Block not just Flash, but (almost) every kind of ad
Authored by: johnrchang on Jul 06, '06 02:09:00PM
For what it's worth, I wrote a plug-in for Safari that blocks Flash ads.

http://web.mac.com/jrc/SafariPlus/

It's free.

[ Reply to This | # ]