Some Improvements on Adblocker

Philipp Hülsdunk philipp_huelsdunk at yahoo.de
Mon Oct 9 17:12:45 BST 2006


Am Sonntag, 8. Oktober 2006 23:41 schrieb David Faure:
> On Sunday 08 October 2006 12:13, Philipp Hülsdunk wrote:
> > I am trying now to make my idea clear.
> > My Idea of ad blocker contains two parts.
> > The first part is a block-list: It contains regular expressions of
> > sources of imgaes. If one regular expression matches to the a source of
> > an image that image will not be shown. This part is already in khtml
> > implemented. It is the current ad blocker.
> > My second part of my idea is to search the html code with regular
> > expressions and to replace it by regular expressions. These find and
> > replace expressions are stored in a list. This part allows to remove java
> > script ads too. It works should wor like Proxomitron or Privoxy.
> > Look here to know about
> > Proxomitron "http://en.wikipedia.org/wiki/Proxomitron".
> > What I need to implement this is to have direct access to the html code
> > and to manipulate. So could somebody tell me how can I do this. I do not
> > know much of khtml and its functions.
>
> The text comes to khtml in KHTMLPart::write() but that's probably too early
> to filter it; it needs to be converted to the right encoding first...
> Better add your hooks into Tokenizer::write which is called by khtmlpart.
> Make sure to make it fast though, this is speed-critical code...

void XMLTokenizer::write( const TokenizerString &str, bool appendData )
{
    if ( !m_noErrors && appendData )
        return;
    if ( appendData ) {
        m_source.appendXML( str.toString() );

    } else {
        m_source.setData( str.toString() );
    }
    // Here will I add my code
    m_noErrors = m_reader.parseContinue();
}

Can I access the string html code with m_source.data?

		
___________________________________________________________ 
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de





More information about the kfm-devel mailing list