The Adblock Project Forum Index The Adblock Project
Pull up a seat ...stay a while.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How does AdBlock intercept URL requests?

 
Post new topic   Reply to topic    The Adblock Project Forum Index -> Main
View previous topic :: View next topic  
Author Message
devhed



Joined: 22 Apr 2006
Posts: 3

PostPosted: Sat Apr 22, 2006    Post subject: How does AdBlock intercept URL requests? Reply with quote

I hope you don't mind me asking this question here as it is to help me build another filtering extension (based on an entirely different mechanism).

I unpacked adblock.rar but I couldn't pinpoint where adblack attaches to FireFox's URI requests...

I thought it might have something to do with
http://www.xulplanet.com/references/xpcomref/ifaces/nsIRequestObserver.html

any help would be greatly appreciated.
Back to top
View user's profile Send private message
mcm_ham



Joined: 17 Dec 2004
Posts: 310

PostPosted: Mon Apr 24, 2006    Post subject: Reply with quote

It actually hooks into Firefox's content policy which all images are checked against to see if they are allowed to load. You can see how Adblock hooks into this service in the nsAdblock.js file under the components directory. The shouldLoad function is implemented at the top of the component.js file.

http://www.xulplanet.com/references/xpcomref/comps/c_layoutcontentpolicy1.html
Back to top
View user's profile Send private message Visit poster's website
devhed



Joined: 22 Apr 2006
Posts: 3

PostPosted: Tue Apr 25, 2006    Post subject: thanks! Reply with quote

Thanks muchly for the pointer. It's a great place for me to start my investigations. nsIContentPolicy looks straight forward enough, but I have no experience with comonents in general. This will be interesting...

Looks like I can learn a lot from AdBlock.
Back to top
View user's profile Send private message
devhed



Joined: 22 Apr 2006
Posts: 3

PostPosted: Tue Apr 25, 2006    Post subject: #10 ??? Reply with quote

In the object definition below, I'm puzzled by the #10 assignments and #10# references. I've never seen this before, what does it mean?

Code:
   
<snip>
// nsIContentPolicy (placeholder)
   policy: {
      count: 0,
      loadFromProfile: #10=function(){ 
         if (typeof policy == 'undefined') {
            try{
               var SubScriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].createInstance(Components.interfaces.mozIJSSubScriptLoader);
               SubScriptLoader.loadSubScript("chrome://adblock/content/component.js");
               this.shouldLoad = policy.shouldLoad, this.shouldProcess=policy.shouldProcess;
            }catch(e){
               //if (++this.count<10||(100%this.count==0 && this.count<2000))
               //   module.log('typeof policy: '+(typeof(policy))+" -> "+this.count+"\n"+e+'\n\ncaller: '+arguments.callee.caller);
            }
         }
         return 1;
      },
      shouldLoad: #10#,  shouldProcess: #10#,
      QueryInterface: function(iid) {
         return (typeof policy !='undefined') ? policy : this;
      }
   },
</snip>
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The Adblock Project Forum Index -> Main All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group