Link to home
Create AccountLog in
Avatar of sticks2u
sticks2u

asked on

Adding code to css file to block add(s)

Hello

I am looking to add a string to my css sheet to block the newiest add that has appeared on my MFL, NEWS, page. I have attached the strings I added to my css to block adds up to this point, however MFL just released some new adds, and I havent had luck blocking them via css yet.

I do not want to use FireFox and add blocker to block the adds, rather have css block them for all browsers.

Please review the current code that removes adds, and then the new page link I want removed.

Here is the area (NEWS) then players name, that has the NEW adds at the bottom of the page, they are BING adds.

http://football10.myfantasyleague.com/2010/view_news_article?L=39492&ID=680928KFFL

 adremoval-1-.css Newiest-MFL-add-source-code..txt
Avatar of scrathcyboy
scrathcyboy
Flag of United States of America image

Strangest use of CSS I have ever seen.  Perhaps the new code is not working because you are using javascript rather than CSS -- at least that looks like what the second file does.  Why not stick to CSS?

BTW, I think you mean ADS  in your description.  ADD is a verb, not a noun.  AD = advertisement

You are aware that the AdBlock data file can be imported and exported to other browsers, which is what I do between Mozilla and Firefox.  That doesn't help IE, but then nothing much can, it is too quirky.
Avatar of sticks2u
sticks2u

ASKER

That CSS snippet is part of a larger CSS file.

Not looking for add blockers via add-INS, per my post.

The second file is the source code I want to block by CSS, it might be a java add I don't know, but my code is CSS..I can assure that.

If you don't know CSS, thanks I will keep post alive.
From your second file, THIS is javascript --

<script> document.write('<scr' + 'ipt src=http://ad.doubleclick.net/adj/myfantasyleague.fsv;kw=bing;sz=1x1;ord=' + Math.floor(Math.random()*9999999999+1) + '?></scr' + 'ipt>'); </SCRIPT>

Ok all I know that it's a bing add, it might be java, like I said I don't know.

I want to block the add, via CSS, attached is my CSS string that I am using to block most adds already, but this new BING add I just can't get it blocked.
bump
Avatar of remorina
Hi sticks2u,
I can't seem to find any adds on the link you have posted, I presume you have already worked it out ?

Let me know if you still need any help

Cheers!
No sir the new ADD is still present, if you click on the top URL link, player news, you will see the BING ADD at the bottom page, it is that ADD I want CSS to block ..any help appreciate
sticks2u:
Pardon my ignorance, I've revisited the link and I still can't seem to find a BING link, I'm sure I'm missing something so bear with me.

I've attached the screen capture for the the result I'm getting below.


capture.gif
Hey Remorina:

I dont know if your using ADD BLOCK add on for FF, but my IE 8 and FF (without addblock) shows the add.

See my attachment.

Add block FF plug in will kill the add...however I am trying the css kill route and it has been great for all the adds so far, up till this new one. User generated image
@ sticks2u:
I am not using any Ad blocker and this was driving me crazy since I've tried it on all borwsers (IE6,7,8,FF, Safari, Chrome and Even Opera) till I figured out that it doesn't show except for United States and since I'm in Australia it simply didn't come up until I used a US proxy, very interesting.

Now to achieve what you need, it won't be easy and I'm still not sure if it would be possible for you or not, but the Ad seems to render without any IDs or Class names, so in order to disable it we will try the following

The row in which has the AD is rendered inside a table that has a class report, that table seems to have only 2 other rows, one which has the class "oddtablerow" and the 1st one which has no class, I presume this is done for the Alternate row styling.

If you are able to assign a class name for the 1st row which has the date as I've done in the attached image below, I gave it the classname "newstitle" it can be "newsdate" or anything else you like, this would leave us with only 1 table row which doesn't have a classname and that is the one we want to get rid of.

We can then hide all the cells of the table class="report" then show back the ones with the classes we have assigned which are "newstitle" and "oddtablerow" using the below CSS
table.report tr.oddtablerow td, table.report tr.newstitle td {
display:table-cell;
}
table.report tr td {
display:none;
}

Open in new window


However, you might need to make sure this table class is not used elsewhere or this would affect all pages using the table with class="report", also if additional rows were to be present additional handling might be required.

I understand that in this particular situation it might not be possible to easily add classes or modify the structure, but unfortunately that will be the only way to handle it since there is no way we can specifically target the Ad row.

Alternatively you can sacrifice the news publishing date which is in the 1st row, and the above CSS will still hide the ad row along with the 1st row containing the Publishing date.

Hope this helps

Cheers!   User generated image
Hey Remorina:

I dont know much css but I pasted your code above to my section of the css that I have labeled BLOCK ADDS, and when i uploaded it to my site, it basically shut my site down...it wouldnt display any content (blocked the whole site LOL)

had a heck of a time getting the old css back uploaded because it was blocking some text for me to see...

Here is what I pasted.

table.report tr.oddtablerow td, table.report tr.newstitle td {
display:table-cell;
}
table.report tr td {
display:none;
}


I do not understand your image code-capture or if I was to do anything with that or not. What you can do is go to myfantasyleague.com and make a league, they are free...upload my css section above (notepad) that blocks most the ADDS and try to add your new string of css to finalize this BING block if you have time to mess with it.

It is late here and I will be back at it tomorrow monday.

Thanks for your work so far, and using the proxy to see the ADD itself....

I think I am finding little support from all my friends by css because like you said it doesnt call out in CSS ID or class names.....

ok will talk later.
Hi sticks2u:
Apologies about that, didn't realize most of the site would be using the same table class!

From your post above it would appear that you don't have any control over the code of the site since you just have an account on the portal, I have tried to quickly set up one, but it's seems it's a long process and it reequires a lot of info that I have no clue about.

However, taking another quick look, it seems that the site is basically built on table structure, and I haven't found any divs within the table report except those ones for the Ads.

I have tried the below CSS which seemed to work, but again you might need to double check if it affects any other section of the site, as what we're doing is hit and cross your fingers since there's still no way we can specifically target only the section of the Ad but this one might seem a bit more promising, hopefully  :-)

try adding the below and check it out.

table.report td > div {
display:none;
}

Open in new window


I'm also off duty now and probably won't be back before around 6pm your time

Cheers!
Remorina: Ok tried your latest code, and it did remove the ADDS.....I went to check out the rest of the site for other new erros....All looked ok....but now the front page scoreboard is NOT working.

I have included a shot of it, the code that goes in the home page module....and the handshake code for the CSS so you can see if your code is clashing with it.

Good work so far!!! User generated image css-scoreboard-code.txt scoreboard-script.txt
ASKER CERTIFIED SOLUTION
Avatar of remorina
remorina
Flag of Australia image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Remorina: Your efforts are relentless, your attention to detail is spot on!!!

YES IT WORKED  :) YEPPIE....and my scoreboard works also.

I would like to have you work on my css issue that pop up from time to time, your the best!

I will continue to watch the site for any clashes in code, but as far as I can tell we are golden.

Thank you
Sticks2u
Remorina understands and listens, then he focuses on the main issue for a resolution.

What an asset to Expert Exchange!!!

Thank you again.
Sticks
Awesome, and I'm glad it worked, I was in doubt at some stage :-)

Thank you very much Sticks for the encouraging words.

It's rewarding to see someone happy after giving a hand.

All the best,
Ray
No thank you!....u got mail also  :)