Author Topic: DOM filter by Scott  (Read 4567 times)

Arne

  • Administrator
  • Hero Member
  • *****
  • Posts: 778
    • ICQ Messenger - 1448105
    • AOL Instant Messenger - aflaaten
    • Yahoo Instant Messenger - arneflaa
    • View Profile
    • http://
    • Email
DOM filter by Scott
« on: July 08, 2002, 06:09:09 AM »
Taken from the prox-list at Yahoo.

Hi all,

I've uploaded a new version of the DOM banner blaster to the file area...


You can simply merge this into your current config to try them out (they'll add two new web filters).

I've changed the script so it looks at a count of the total children a node has (including all sub-children) to guess if it's empty enough to be considered part of the ad. This could be made much better though. For example instead of just a count, it could return a weighted score that would give some types of elements more or less "weight". Long text nodes might count against it being part of the ad while other elements might be neutral or count towards it being part of the ad.

The "aggressiveness" of the filter could then be adjusted by just setting what score value to consider low enough to remove the parent element.

-Scott-

http://www.flaaten.dk/forum/attachments/DOM.zip

Best wishes
Arne
Imici username= Arne
Best wishes
Arne
Imici username= Arne

dave1006

  • Full Member
  • ***
  • Posts: 113
    • ICQ Messenger - 92066376
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • Email
DOM filter by Scott
« Reply #1 on: July 08, 2002, 12:49:59 PM »
I've been following the 'evolution' of the DOM Blaster over at ygroups, and it's a little over my head right now :) Not ever having used JS in my pages (or at least since it first 'came out'), as i prefer server based scripts, the DOM/JS implimentation is a little beyond most of my understanding.

However, one thing i noticed was that the DOM blaster can sometimes consume too much - to counter this, edit the 'DOM Container Killer' fourth line and change the variable to a lesser value... I changed from the default 6 to 5 - as 6 blocked a whole forum I like to visit :)

Also worth noting is that this filter won't work in Opera (any version <= 6.04), but it is supported by Mozilla and IE (DOM complient versions). If you're a avid Opera fan (as I am) you may want to try out Mozilla (www.mozilla.org), as it contains a lot of similar features - infact the only downside over opera that I can find is poor(er) support of 'tabs' for websites within the same window. Oh, and Flash for some reason uses mad CPU time, don't know if that's Mozilla or me though :)

dave
dave at smokeajay.co.uk
dave
dave at smokeajay.co.uk

Arne

  • Administrator
  • Hero Member
  • *****
  • Posts: 778
    • ICQ Messenger - 1448105
    • AOL Instant Messenger - aflaaten
    • Yahoo Instant Messenger - arneflaa
    • View Profile
    • http://
    • Email
DOM filter by Scott
« Reply #2 on: July 11, 2002, 08:47:16 PM »
Form the prox-list by Scott: (version 0.006)

I've just been playing with IE5.0 and found it might of been the
onload that was causing the trouble. It seems to work if I use a
different method of calling the script. The one below takes a page
from ScoJo's book and gives each element to be killed a unique name.
Then PDOMhide() is called just once at the bottom of the page and uses
getElementsByName() to find all the tagged items. (the way the while
loop works is a bit interesting - seems that when you call removeChild
on an element it actually removes it from the result array too. The
loop just keeps deleting the first item till none are left).

IE users should try it out -


Attachment: dom1a.zip   1,17?KB

Best wishes
Arne
Imici username= Arne
Best wishes
Arne
Imici username= Arne

Arne

  • Administrator
  • Hero Member
  • *****
  • Posts: 778
    • ICQ Messenger - 1448105
    • AOL Instant Messenger - aflaaten
    • Yahoo Instant Messenger - arneflaa
    • View Profile
    • http://
    • Email
DOM filter by Scott
« Reply #3 on: July 12, 2002, 03:28:55 PM »
The last version works best on my system when using IE 6.0.2600.000 First version gives lots of ? pages.


Best wishes
Arne
Imici username= Arne
Best wishes
Arne
Imici username= Arne

Multiproxomatrix

  • Newbie
  • *
  • Posts: 9
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger - ethixstudent
    • View Profile
    • Email
DOM filter by Scott
« Reply #4 on: July 16, 2002, 01:17:06 PM »
There is a problem with the .006 container killer IE version cfg in the dom1a zip. The problem is at the "if(x &&
tag.match(/^(TD|TR|TABLE|TBODY|FONT|IFRAME|A|DIV|P|SPAN)$/)){" part of the script. You have to place the "&&" and "tag" on the same line, or it won't be loaded correctly. I caught this by looking at the .005 version, trying to figure out way the empty spaces weren't going away.

 
Here's the fixed version:
--------------------copy below------
[Patterns]

Name = "DOM container killer v0.006"
Active = TRUE
Limit = 256
Match = "<end>"
Replace = "<script>"
"function PDOMhide(){"
" var a=document.getElementsByName("PrxDOMtarget");"
" while(a[0]){"
" var x=a[0].parentNode;"
" a[0].parentNode.removeChild(a[0]);"
" var d=6;"
" while(d-- && x){"
" var y=x;"
" var tag=y.nodeName;"
" x=x.parentNode;"
" if(x && tag.match(/^(TD|TR|TABLE|TBODY|FONT|IFRAME|A|DIV|P|SPAN)$/)){"
" var sz=PDomSize(y);"
" if(sz>12){d=0;}"
" else{"
" if(0){alert(tag + ":" + sz + "\n" + y.innerHTML);}"
" y.parentNode.removeChild(y);"
" }"
" }"
" }"
" }"
"}"
""
"function PDomSize(t){"
" var k=t.childNodes;"
" var pl=k.length;"
" var tot=pl;"
" while(pl--){tot+=PDomSize(k[pl]);}"
" return(tot);"
"}"
""
"PDOMhide();"
"</script>
"
-----------------------copy above------
Hope this helps.

M.P.M.

 
M.P.M.

Arne

  • Administrator
  • Hero Member
  • *****
  • Posts: 778
    • ICQ Messenger - 1448105
    • AOL Instant Messenger - aflaaten
    • Yahoo Instant Messenger - arneflaa
    • View Profile
    • http://
    • Email
DOM filter by Scott
« Reply #5 on: July 16, 2002, 01:36:36 PM »
Nice catch! The download file has been updated.

Best wishes
Arne
Imici username= Arne
Best wishes
Arne
Imici username= Arne

Multiproxomatrix

  • Newbie
  • *
  • Posts: 9
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger - ethixstudent
    • View Profile
    • Email
DOM filter by Scott
« Reply #6 on: July 16, 2002, 09:07:07 PM »
Glad that I could help. I believe this problem began in the Yahoo forum, so could you please tell them, incase they haven't already caught it. I don't post there, I just pop in now and then. This is the forum for me.

M.P.M.



Edited by - Multiproxomatrix on 16 Jul 2002  22:13:04
M.P.M.