De-ad Facebook

By diego.devita Last update Nov 26, 2008 — Installed 11,606 times.

Archived Comments (locked)

in
Subscribe to Archived Comments 18 posts, 7 voices



Jesse Andrews Admin

The following is an archive of comments made before threaded discussions was implemented (November 16th, 2008)

 
Avindra V.G. Scriptwright

actually, i looked at your code, and there are some things that aren't possible in CSS.... my fault. but i think you can condense your code a bit. I haven't tested it out, but I believe this should work the same, except a bit faster:

kill=function(x) {if(x) x.parentNode.removeChild(x)};
 kill(document.getElementById('sidebar_ads'));

function killIterator(regex, element, source) {
 var checker = document.evaluate("//"+element,document,null,4,null);    
  while(obj=checker.iterateNext())
   if (regex.test(source ? obj.src : obj.className)) kill(obj);
}

setInterval(function() {
 killIterator(/[^\w]ad[^d]|[^\w]Ad[^d]|[^\w]a.htm|monetize|banner/,"iframe", true);
 killIterator(/social_ad|sidebar_item\ssponsor/,"div", false);
},500);

In case you're wondering what the hell document.evaluate is, it's something called XPath. It's supposed to be a lot faster than getElementsByTagName, and it is a very powerful DOM language. You can read up about it here.

Also, why did you set a half a second interval? Are there ads that refresh themselves? Which page does it happen on, because if I can identify it, I can supply a line that will stop the ads from refreshing.

 
diego.devita Script's Author

true...this scripts only tests for class, src and id attribute and removes or hides such nodes. I don't know the CCS selectors...can I ask you if it's possible to apply regular expressions? because in that case your approach would be much better. It would be really easy to shift this "idea" to that side. I know there's already, but I'd prefer to apply my personal strategy for my own purpose...at least I would try to suggest to remove applications ads too. In that case it would work just like mine. don't you think? or did I miss something?

ps. thank you for your help ;)

 
Avindra V.G. Scriptwright

You're absolutely right that GreaseMonkey is infinitely times more powerful than Stylish. I was recommending Stylish instead because this really just tests attribute values on class names and src urls. The same effect can be achieved with CSS selectors.

ps. sorry if i sound like a giant ass, i'm just trying to help

 
diego.devita Script's Author

it seems a polemic approach, maybe I'm wrong, sorry in that case.
Anyway, I'm open to any kind of criticism, I'm not saying this script will save the world. It's not the best of the best. And no, I'm not a javascript expert. So I don't know all the tricks to make it better. What I usually do, it's spending some minutes of my free time to craft tools with my own hands, tools I need and I searched before without success, and maybe deliver for free to the world if I find them really useful. The hope is to share something that's mine, and get your help to improve it, so everyone, me included, can benefit. If you have a better solution, you tell me and I'll verify by myself. If it's true, I'll surely throw mine away, because what really matters it's solving the problem.

Now about the stylish script...

First let's talk about what I said last time...I prefer the greasemonkey way. Yes I prefer that way because it's more powerful, I can inject javascript code on the original page and take absolute power, match patterns and modify the appearance. This has a bad side as everything, the bumpy effect you were talking about. But what can I do? I prefer paying the price of the bumpy effect instead of keeping the ads where they are. If you have a solution tell me, your stylish script still doesn't remove that ads and yet I didn't hear from you a javascript approach to avoid the bump. What I found in your gm "wrapper" is only a different way of running the main function. It seems better than mine because doesn't run periodically every x seconds. I tried to modify my script using that solution but it didn't work everytime. I'll inspect this later, it could be useful.

when you suggested that script the first time, I tried, but it didn't work as well as now. Now I have to say that's much better, it does quite a good job in a restricted domain. But the problem is that. It still doesn't work as well as I'd like it to. why? It doesn't remove more ads as you say! I don't know what are you talking about, but please if I'm wrong try to explain me better, I'm here to find the best solution to my problem, not only write my name on a loser product. If my script is worst by all means compared to something different I admit it. But I need clear evidence of that, and still I haven't. That stylish stuff doesn't remove the ads on applications. That's the most tricky part, because it's really difficult to find a general pattern to recognize them without doubts. That is why I always need the users help, you have to tell me when the script doesn't work in a specific circumstance so I can solve it. Facebook it's a living creature, it always changes, and we must be there to go along with it. I think the stylish approach alone can't work at all, because it doesn't recognize patterns. The ads container do not always have a unique name, you have to extract them using a strategy to distinguish them from the legitimate ones. So please answer this question, how can a stylish script match patterns? and how does it hide ads inside applications?? I need those answers to move on and change solution.

so to summarize and answer your points:


a) yes you're right, but imho the stylish script doesn't accomplish the job as it's supposed to do while mine does.

b) no it doesn't. I tried it now, when you use an application the ads are still there. If I'm wrong, please tell me in which circumstances.

c) I prefer the GM way, but because with his power can do something more powerful. I'm not forced to use GM if the script does the same exact job. I want to use the powers of GM to do a better job, that's what I'm trying to do. A job that I still consider better than yours. please help me change idea.


p.s.: I really don't like the "widens profile page" feature. I don't want to modify the layout of the page, because it would be worst. I want to see the page exactly as it should be, only without ads. I prefer to have the same layout as my friends, so they see me as I do.

to conclude, I want to say it again, if you (any of you) have a better solution as a whole please tell me, because I wouldn't need to keep mine up to date anymore. If I didn't understand this stylish story explain me, but I need complete details on why it's better than mine. because I still don't think so.

 
Avindra V.G. Scriptwright

also, about the comment i made before:
a) userstyles are loaded before the page is finished loading, so there isn't an awkward "bumpy" effect seeing the ads disappear.
b) that one does in fact remove more ads
c) if you really preferred the "greasemonkey way", which isn't nearly as good for ablocking compared to Stylish, you can install the style as a script.

 
Avindra V.G. Scriptwright

not that it really matters, but i wanted to share this:

	if(obj!=null) obj.style.visibility = 'hidden';	

is exactly equal to:

	if (obj) obj.style.visibility = 'hidden';	

 
CheriePie User

Wow, that was quick! Thanks Diego! Got it reenabled and it's looking good again... will run with it throughout the day and report in anything else I find. :)

 
diego.devita Script's Author

thanks CheriePie for your comment. I really need these ones, because I can't look every application by myself and with your help only I can adjust the script to make it work according to your habits.

Anyway I 've never seen Realm of Empires before so I've just tried it now. You were right, my strategy was way too optimistic before. So I redesigned it. Now I improved it but it could be a bit less adaptable than before, so please! help me and yourself, when you find even the littlest problem let me know writing a comment with some details and I'll try to fix the script as soon as possibile.

Anyway now everything seems to work as it's supposed to do.

 
CheriePie User

Unfortunately, it disabled the entire Realm of Empires game from showing up at all. :( Otherwise it was really looking good there for awhile.

 
dennis3484 User

Thanks diego.devita,
the new version 0.6b works fine for me!

 
diego.devita Script's Author

what i found was the sponsored feeds in that section. it seems like you describe. I uploaded a new version that removes that feeds. let me know if I got it wrong. thanks for the help.

 
dennis3484 User

Is there any chance of removing the ads on the Home site?

Netflix: Only $4.99/month
You've heard of Netflix, now try us for free!

The name of the div class is "feed_item clearfix has_body social_ad social_ad_no_full_clickable".

 
diego.devita Script's Author

that is not the intended scope of this script. I don't even know why you should remove that bar. anyway the div is called scoUITwoColumnLayout_NarrowContent. you should hide the visibility of that object.

 
Mistrio User

Hey, very nice script thank you.. but can someone tell me what do I need to add to this script if I wanted to also hide the sidebar? I mean the "sponsored" tab and "applications" and "people you may know".. etc?

 
diego.devita Script's Author

I'm happy to have a supporter :D thanks Davy.

For avg: I didn't know the script you suggest. anyway it lives in a different world. I don't even know if it works well as you say, but it doesn't matter. I was looking for a greasemonkey(!) script and I couldn't find anything useful. So I did one that worked as it was supposed to do. That's it. I hope someone else will find that stylish script useful for himself, I personally prefer the greasemonkey way.

 
Avindra V.G. Scriptwright

no, this one is better.

 
Davy Jones User

Best anti Facebook ads script out there, not doubt.
Thanks a lot.

Cross
Presentational HTML allowed.
Use <code> for inline code and <pre> for code blocks. Use &lt; and &gt; for literal < and >.
We help break paragraphs and link your links.
or cancel