View previous topic :: View next topic |
Author |
Message |
Bethrezen Guest
|
Posted: Sun Dec 07, 2003 Post subject: adblock trouble - collapsation |
|
|
Hi. I just tried the latest version of adblock, and something's not right. When set to collapse images, it's removing things it shouldn't. For instance, with WildersSecurity.com, I have this filter set to block the images -- so the forum loads faster, but the buttons remain intact: wilderssecurity.com/YaBBImages/*.jpg
However when I set adblock to collapse the blocked images, it also removes the forum titles. What I should see is something like thisNew Members and Help
-Test Forum
-FAQs But what I actually see is this:-Test Forum
-FAQs Note the forum title has vanished
This is an easily re-creatable bug. Just go to that site, set adblock to collapse blocked images and add the filter. The thing that is really annoying me is that the same filter in the v.3 didn't cause this behaviour. The page loaded, the images collapsed and that was it.
Originally, I posted here, and the response I got was basically that this is expected functionality.
However, this is causing EXTREMELY ANNOYING PROBLEMS. The issue above isn't limited to that site -- its happening everywhere I go, messing up pages' functionality. For example: buttons you need to operate a page vanish.
[edited for clarity - rue] |
|
Back to top |
|
 |
Bethrezen Guest
|
Posted: Sun Dec 07, 2003 Post subject: |
|
|
Quote: | Per the parent-post: you've set a filter to block all jpg-files from a certain directory on that site. But the main table for the page in question has header-cells using those very images for backgrounds. With Adblock set to "Collapse Blocked Items", the header-cells using the images are rightly collapsed. |
Ok now correct me if I'm wrong I just want to make sure I understand what you are telling me correctly
A table is kind of like a directory tree and header-cells is kind of like the main directory in that tree and each of the blockable elements are like sub directories now when collapse is on instead of collapsing just the designated sub directory it collapses the whole directory and everything in it correct ??? |
|
Back to top |
|
 |
rue Developer
Joined: 22 Oct 2003 Posts: 752
|
Posted: Sun Dec 07, 2003 Post subject: |
|
|
Bethrezen:
When it comes to creating filters, the user takes the full burden of properly restricting. If a filter is too general, it blocks desired content.
.
Adblock isn't doing anything wrong. Your filter just isn't specific enough. Here's one that is:
/wilderssecurity\.com\/yabbimages\/(.(?!bg))*\.jpg/
.
(tip: click the "adblock" status-element to see all blockable elements in a page.) |
|
Back to top |
|
 |
Bethrezen Guest
|
Posted: Tue Dec 09, 2003 Post subject: |
|
|
hi
well if its the case that its just my filters that ain't good enough would you care to educate me coz i read that page on regular expressions and its all double dutch to me
and please keep it simple
in-fact while I'm on the subject isn't there an easer way to get the same results rarther than using regular expressions because regular expressions are beyond the capability of most novice users like my self
maybe its all very easy to people that understand all this stuff but ya need to keep in mind that not all users are wiz kid programmers and like me they probably got no idea how to use regular expressions
so is there any chance of simplifying things a lil bit to make it easer for the non technical user |
|
Back to top |
|
 |
rue Developer
Joined: 22 Oct 2003 Posts: 752
|
Posted: Tue Dec 09, 2003 Post subject: RegExp Tutorial - pt.i |
|
|
Bethrezen:
After reading this, go back to the RegExp page and "see with new eyes." Here we go. All patterns must begin and end with the forward-slash "/". This is so that javascript can distinguish them as patterns. Pattern matching works by using special characters, whose meanings you must memorize. These special characters only match positive on certain kinds of text. The two we'll cover here are the word-character match "\w" and the digit-character match "\d".
.
Example-I: I have a string containing a number: "3".
Using the digit-character /\d/, results in a positive match.
.
Example-II: I have the same string: "3".
Using the word-character /\w/, results in a negative match.
.
Example-III: Finally, I have a string containing a letter: "c".
Using the word-character /\w/, I now have a positive match.
.
Real-world Example: A website I frequent has banner-ads with their banner-size spelled out in the source: "http://coolsite.com/notabanner183x64.gif"
"http://coolsite.com/innocentpic123x72.jpg" Since I'd rather not block the whole site, what can I do? The answer: use a pattern. This simple RegExp will match true on their "size"-string: /\d\d\dx\d\d/ -- that is: three digits, followed by a lowercase 'x', and two more digits. |
|
Back to top |
|
 |
Guest
|
Posted: Thu Dec 11, 2003 Post subject: |
|
|
hi
Ok i read your explanation and i understood besicley you are telling the computer to match anything in the url that is formulated like this 183x64
but that still don't really help because it doesn't really tell me how to properly formulate filters
take for instance the one you posted for wilders even after reading i still cant figure out how or why that works and how to replicate thoughts resultes on other sights
like i asked before isn't there a way to make this any easer because this is frustratingly complicated and i'm still not getting how the hell this regular expressions thing works and i'm sure i'm not the only one
even after reading its still double dutch to me |
|
Back to top |
|
 |
cardinal Guest
|
Posted: Thu Dec 11, 2003 Post subject: |
|
|
Guest/Bethrezen,
Your frustration with regexps is understandable. But, regexps are extremely powerful when it comes to pattern matching, and so the effort to learn them is well worth it, IMHO.
As rue said above, you need to memorize the special codes, or keep a bookmark to a page that has them. Or, just buy a book. The so-called "camel book" on Perl programming actually has a very good list of simple regexps for beginners, and is worth buying. The full citation is "Programming Perl", by Larry Wall et al., published by O'Reilly and Associates, Inc.
As for the specific filter rue gave that you didn't understand? Here's a brief explanation, although I'm not sure it'll do you much good.
/wilderssecurity\.com\/yabbimages\/(.(?!bg))*\.jpg/
The forward-slashes at the beginning and end are to indicate that the filter is a regexp. That's all they do.
The period (.) is a special character (a.k.a. "metacharacter" in regexp lingo), the ultimate wildcard in regexps that matches absolutely anything (even blank space). So, if you just want to match on a plain old period, you need to precede it with a backslash. This is a general rule in regexps - any metacharacters (there are like a dozen or so metacharacters, including slashes, parentheses, asterisk (*), exclamation (!), question (?), the backslash itself, obviously, and others) need to be preceded by a backslash to keep their literal, as opposed to special, meaning.
The * in regexps means something different than you might think - it matches 0 to infinite occurences of whatever immediately precedes it. So, the regexp /\d*/ would match any number of digits in a row (including no digits at all! This is why using * in regexps is somewhat tricky), since "\d" is the code for a numerical digit.
So consider the expression /.*/ This means to match on 0 to infinite occurences of any character at all. In other words, absolutely everything! I don't recommend using this as an Adblock filter
Rue's filter above simply uses a lot of "\." to implement a literal period in the web address, and "\/" to implement literal forward-slashes. The real guts of the filter is the part near the end:
(.(?!bg))*\.jpg
This uses a special construct called a "zero-width negative lookahead", which is made by an open parentheses, question mark, exclamation point, <stuff>, close parentheses. In other words, "(?! stuff )". What this does is match on anything except phrases that end in "stuff". So, in rue's filter, he uses /(.(?!bg))*\.jpg/ to match on all .jpg files, except those that have names ending in the letters "bg". This is because if you look at the wilderssecurity web site source code, all of the images that you want to preserve on the page seem to end in "bg.jpg".
So, that's it! It looks very complicated, but it's not that bad, really, once you learn to see past all the spurious backslashes
Hope that helps. Trust me, regexps can get a lot more complicated (and more simple!) than this, but, once again, are well worth learning. |
|
Back to top |
|
 |
Guest
|
Posted: Thu Dec 11, 2003 Post subject: |
|
|
From an Adblock-marketing standpoint, it might be better to emphasize wildcard blocking before regexps. I've pitched Adblock to my friends many times and they seem to respond more positively to "block ads with wildcards, and by the way it has regexps" than to "block ads with regexps, and by the way it has a simplified wildcard system".
Just my two cents,
James |
|
Back to top |
|
 |
rue Developer
Joined: 22 Oct 2003 Posts: 752
|
Posted: Thu Dec 11, 2003 Post subject: RegExp Tutorial - pt.ii |
|
|
Bethrezen:
Alright, so now we understand how to accomplish basic matching. What about more complex stuff -- like "oneThing" OR "another"; and how can I exclude certain matches, so not everything is caught? The answer involves two, related concepts: conditionals, and sets.
-Conditionals are special characters that insert logic into your pattern.
Example-IV: I have three strings: "place", "placed", "placard"
Using the OR-conditional /place|placed/, results in positive matches on the first two, but not the third.
-Sets are simply the arrangement of one-or-more conditionals inside a parenthesis.
Example-V: I have the same strings: "place", "placed", "placard"
Using the OR-conditional, this time inside a set /plac(e|ed)/, results in positive matches on the first two, but not the third.
-Now, let's make the pattern explicitly exclude the third string, instead of spelling-out the first two.
Example-VI: again: "place", "placed", "placard"
Using the negative-lookahead /plac(?!ard)/, results in positive matches on the first two, but not the third.
Ah- so this is pretty easy. Is there any way to make whole sets conditional?- so that, maybe, nothing in them has to match? Yes- for this, we use multipliers.
-Multipliers allow items to be matched multiple-times -- with precision. Whatever directly precedes the multplier is affected. The most common multiplier is the "wildcard" (*). It matches zero or more times.
Example-VII: I have three strings: "/YaBBImages/wild.jpg", "/YaBBImages/wilders.jpg", "/YaBBImages/catbg.jpg"
Using the word-character and wildcard multiplier /wild(ers)*\.jpg/, results in positive matches on the first two, but not the third.
[Note: the period and forward-slash are special-characters in regexp. To access their "literal" meaning, we precede them with a back-slash. This is called literalizing.]
-Finally, let's bring it all together:
Example-VIII: the same strings: "/YaBBImages/wild.jpg", "/YaBBImages/wilders.jpg", "/YaBBImages/catbg.jpg"
Combining everything we know /YaBBImages\/(\w(?!bg))*\.jpg/, results in positive matches on the first two, but not the third.
Last edited by rue on Thu Dec 11, 2003; edited 1 time in total |
|
Back to top |
|
 |
rue Developer
Joined: 22 Oct 2003 Posts: 752
|
Posted: Thu Dec 11, 2003 Post subject: |
|
|
Cardinal's post is spot-on, but Bethrezen stressed the need for simplicity.
.
Between our three posts, I think everything's been covered, now. |
|
Back to top |
|
 |
Melon Guest
|
Posted: Thu Dec 11, 2003 Post subject: |
|
|
Not sure about Bethrezen, but superb explainations Rue and Cardinal. I know absolutely no RegEx, but those 2 posts were very helpful.
Actually makes RegEx look somewhat less daunting, well, only slightly. Though I'll still probably be tearing my hair out once I actually try to construct my own filter
Kudos to you two. |
|
Back to top |
|
 |
Melon Guest
|
Posted: Thu Dec 11, 2003 Post subject: |
|
|
Heh, told you I'd need help. Right I've modified a filter you posted on another thread Rue:
/[\W\d]banner(s|id\=)[\W\d]/
By my understanding, the first bit in the square brackets are a set and it matches any non-word character and a digit character. Followed by the main part, matching banner or banners or bannerid. Not quite sure what the \= is but I thought maybe it also covers banner= . Then the non-word and digit set again.
So there's an image with the name tnbanner I was thinking I could just use \w within the first set, i.e. [\w\W\d], but that doesn't seem to work.
Is that because \w (or \W\d) only match a single character? So zbanner would return a positive result but tnbanner wouldn't? Well I presumed that's what it was so tried to include a wildcard to broaden the range.
/[\W\d]*banner(s|id\=)[\W\d]/ or /[\W\d*]banner(s|id\=)[\W\d]/ doesn't work either. Urgh RegExp is baffling, don't have the kind of logical mind to do this kind of stuff. |
|
Back to top |
|
 |
rue Developer
Joined: 22 Oct 2003 Posts: 752
|
Posted: Thu Dec 11, 2003 Post subject: |
|
|
Melon:
banner(s|id\=) - matches only "banners" and "bannerid="
.
The string you're testing -- "tnbanner" -- doesn't end in either "s" or "id=". It would be easy to zero-multiply that final OR-set ...except the whole point was to prevent false-positives on "banner". Instead, just add your unique term as a conditional:
/[\W\d](tnbanner|banner(s|id\=))[\W\d]/ |
|
Back to top |
|
 |
Melon Guest
|
Posted: Thu Dec 11, 2003 Post subject: |
|
|
Ahh so it doesn't match banner on it's own then? Interesting.
Oh and yeah, I was thining of adding the tnbanner as a conditional, but that was just an example. Guess I'll stick with my original wildcard happy version.
Cheers for the help. |
|
Back to top |
|
 |
Org
Joined: 23 Oct 2003 Posts: 349
|
Posted: Thu Dec 11, 2003 Post subject: |
|
|
Melon wrote: | Ahh so it doesn't match banner on it's own then? Interesting. |
The RegExp of rue is very careful in avoiding false positives.
If you want to match "banner" on it's own, you can easily do what rue said ("It would be easy to zero-multiply that final OR-set"), like this:
/[\W\d]banner(s|id\=)*[\W\d]/
If it's acceptable to match several variants of banner and tnbanner, then this might work:
/[\W\d](tn)*banner(s|id\=)*[\W\d]/
This would match: "tnbanner", "tnbanners", "tnbannerid=", "banner", "banners" and "bannerid=", all surrounded by non-word characters or numbers (e.g. "/tnbanner/" or "www.banners.site"). |
|
Back to top |
|
 |
Melon Guest
|
Posted: Thu Dec 11, 2003 Post subject: |
|
|
Right I see, I was under the initial impression that the filter encapsulated things like banners, bannerid, banner and also go96banner3f.jpg for example.
But upon closer inspection, I must have totally missed the whole point of the string.
Thanks for the explaination Org. |
|
Back to top |
|
 |
Guest
|
Posted: Fri Dec 12, 2003 Post subject: |
|
|
i think my head will explode....lol |
|
Back to top |
|
 |
Org
Joined: 23 Oct 2003 Posts: 349
|
|
Back to top |
|
 |
Guest
|
Posted: Sat Dec 13, 2003 Post subject: |
|
|
thanks for those thinks... |
|
Back to top |
|
 |
Guest
|
Posted: Sat Dec 13, 2003 Post subject: |
|
|
teaches me to spellcheck, i meant LINKS...hehe |
|
Back to top |
|
 |
Bethrezen Guest
|
|
Back to top |
|
 |
rue Developer
Joined: 22 Oct 2003 Posts: 752
|
Posted: Tue Dec 16, 2003 Post subject: |
|
|
Bethrezen:
/wilderssecurity\.com\/yabbimages\/(wilders|off|open|xx|guest|info|online|php|mysql|vhtml|vcss)\.gif/
.
And, here's the breakdown of that pattern:/wilderssecurity\.com\/yabbimages\/(wilders|off|open|xx|guest|info|online|php|mysql|vhtml|vcss)\.gif/
/wilderssecurity\.com\/yabbimages\/(wilders|off|open|xx|guest|info|online|php|mysql|vhtml|vcss)\.gif/
/wilderssecurity\.com\/yabbimages\/(wilders|off|open|xx|guest|info|online|php|mysql|vhtml|vcss)\.gif/
/wilderssecurity\.com\/yabbimages\/(wilders|off|open|xx|guest|info|online|php|mysql|vhtml|vcss)\.gif/
/wilderssecurity\.com\/yabbimages\/(wilders|off|open|xx|guest|info|online|php|mysql|vhtml|vcss)\.gif/ The vertical-line is the "OR" conditional. It means any one of the items in parenthesis can match. Forward-slashes (/) and periods (.) have special meanings, just like the OR-conditional (|). To use them as regular characters in the pattern, they must be preceeded with a back-slash (\) -- that's why you see "\/" and "\." in the pattern.
.
Regarding the OR-conditional and its enclosing parenthesis, see pt.ii of the tutorial. |
|
Back to top |
|
 |
Guest
|
Posted: Wed Dec 17, 2003 Post subject: |
|
|
believe or not i'm beginning to comprehend.....my exploding head is slowly rematerializing.....
Many thanks  |
|
Back to top |
|
 |
Bethrezen Guest
|
Posted: Mon Dec 29, 2003 Post subject: |
|
|
????? err ok im really not geting this that just looks like alot of nonsence to me ?????
i know you are doin ya best to try and help me out but im geting nowhere i havnt got clue could this be any tougher to understand *sigh* there has to be a simpler way to aproch this coz this is compleatley over my head and as hard as i try im geting nowhere |
|
Back to top |
|
 |
rue Developer
Joined: 22 Oct 2003 Posts: 752
|
Posted: Wed Dec 31, 2003 Post subject: |
|
|
Bethrezen:
Sorry- we did our best :P |
|
Back to top |
|
 |
MW Guest
|
|
Back to top |
|
 |
MW Guest
|
Posted: Thu Jan 01, 2004 Post subject: |
|
|
perhaps this thread should be sticky and topic changed to "A Quick Giude to REGEXP (regular Expressions)" |
|
Back to top |
|
 |
rue Developer
Joined: 22 Oct 2003 Posts: 752
|
Posted: Fri Jan 02, 2004 Post subject: |
|
|
MW:
The "helpful threads" sticky links here.
.
Multiple stickies made it difficult to locate new posts at-a-glance. |
|
Back to top |
|
 |
kp Guest
|
Posted: Sun Jan 11, 2004 Post subject: regexp |
|
|
I've read most of the replies and as a programmer myself find that the average user will have problems with regular expressions. Although they are powerful they present a rather large learning curve for the 'average user'.
As Mozilla Firebird is aiming for the end user which accomodates the 'average user' is it not possible at least to have some sort of wizard that helps the user to build the regular expression? and/or have a list of basic filters (which I see is the discussion in another topic) ship with adblock.
I do find adblock very useful but something like this may hinder it's take-up.  |
|
Back to top |
|
 |
kstahl Support
Joined: 02 Jan 2004 Posts: 1202 Location: Stockholm, Sweden
|
Posted: Sun Jan 11, 2004 Post subject: |
|
|
Well, an average user could always add filters the "traditional way.
*/ad.*
*/ads/*
*/banner/*
*.doubleclick.net
etc.
(The wildcards are not needed any longer I think?)
That's what I did. When I started with adblock I had no idea how to use regular expressions. |
|
Back to top |
|
 |
rue Developer
Joined: 22 Oct 2003 Posts: 752
|
Posted: Mon Jan 12, 2004 Post subject: |
|
|
kp:
some sort of wizard that helps the user to build the regular expression
You mean like... this?
.
(discovered in a bannerblind bug, oddly enough.) |
|
Back to top |
|
 |
kp Guest
|
Posted: Tue Jan 13, 2004 Post subject: |
|
|
rue wrote: | kp:
some sort of wizard that helps the user to build the regular expression
You mean like... this?
.
(discovered in a bannerblind bug, oddly enough.) |
Yes  |
|
Back to top |
|
 |
kp Guest
|
Posted: Tue Jan 13, 2004 Post subject: |
|
|
Just a note on my post above:
Although the option chosen by rue is good, we must consider the fact that:
1. Having "string" in the menu's text isn't a good idea and
2. Maybe to build a good regular expression takes many menus which could clutter the screen and make it even more confusing for the user.  |
|
Back to top |
|
 |
time2read
Joined: 18 Jul 2004 Posts: 5
|
Posted: Sun Jul 18, 2004 Post subject: |
|
|
have you seen the RegEx Coach?
http://www.weitz.de/regex-coach/
Quote: | The Regex Coach is a graphical application for Linux and Windows which can be used to experiment with (Perl-compatible) regular expressions interactively. It has the following features:
* It shows whether a regular expression matches a particular target string.
* It can also show which parts of the target string correspond to captured register groups or to arbitrary parts of the regular expression.
* It can "walk" through the target string one match at a time. |
(limited quote.. there are other features) |
|
Back to top |
|
 |
zero ant
Joined: 14 Aug 2004 Posts: 3
|
Posted: Sat Aug 14, 2004 Post subject: eh, subject? what do you mean with er... sup'jack? |
|
|
I'm sorry for bringing this old topic up, but I just want to clarify (and fix) something.
----------------------------------------------------------------------------------------------------
rue wrote: | Posted: Sun Dec 07, 2003
Code: | /wilderssecurity\.com\/yabbimages\/(.(?!bg))*\.jpg/ |
|
Correct me if I'm wrong (because I just tried Firefox yesterfay and learned regexp today). If my knowledge serve me well, the above code would also block images like:
http://www.wilderssecurity.com/YaBBImages/bobgoof.jpeg (this is an imaginary link)
This is because of the bobgoof.jpg you see? The (.(?!bg))* part is the problem. It kills any files in that directory that contains bg in it. I think it should be something like:
Code: | /wilderssecurity\.com\/yabbimages\/(.(?!bg\.))*(jpe?g|gif)/ |
----------------------------------------------------------------------------------------------------
Next one,
rue wrote: | Posted: Tue Dec 16, 2003 Code: | /wilderssecurity\.com\/yabbimages\/(wilders|off|open|xx|guest|info|online|php|mysql|vhtml|vcss)\.gif/ |
|
don't forget the jpg part, it should be...
Code: | /wilderssecurity\.com\/yabbimages\/(wilders|off|open|xx|guest|info|online|php|mysql|vhtml|vcss)\.(gif|jpe?g)/ |
--------------------------------------------------
Thank you so much , this tool is very much helping me! |
|
Back to top |
|
 |
guest Guest
|
Posted: Wed Nov 03, 2004 Post subject: refused entry to devedge.netscape.com |
|
|
I'm not allowed entry to devedge.netscape.com. What's up?? I need the syntax info.
Remember that there are a lot of slightly different rexexp dialects out there. You can learn the basic use from any of these tutorials and help pages, but for exact syntax you should check the JavaScript documentation:
http://devedge.netscape.com/library/manuals/2000/javascript/1.5/guide/regexp.html#1010689
Learning the basics of regexps is more than worth the trouble. And Adblock is not alone, there are lots of programs and tools that use regexps.[/quote] |
|
Back to top |
|
 |
kstahl Support
Joined: 02 Jan 2004 Posts: 1202 Location: Stockholm, Sweden
|
Posted: Wed Nov 03, 2004 Post subject: |
|
|
Unfortunately, Netscape took Devedge offline. I think efforts are underway by Mozilla to save the contents. _________________ Adblock 0.5.3.042
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1. Gecko/20051111 Firefox/1.5 |
|
Back to top |
|
 |
wonkothesane The Other Developer
Joined: 22 May 2004 Posts: 210
|
|
Back to top |
|
 |
Zachariah

Joined: 21 Jul 2004 Posts: 703 Location: Earth
|
|
Back to top |
|
 |
cell1527

Joined: 16 Jul 2004 Posts: 44
|
|
Back to top |
|
 |
Guest
|
Posted: Sat May 14, 2005 Post subject: Re: RegExp Tutorial - pt.i |
|
|
rue wrote: | Bethrezen:
After reading this, go back to the RegExp page and "see with new eyes." |
Is this a correct hyperlink?
I would like to learn a bit more about RegEx
As far as my use of the [Adblock] filter. I only have two items in the [AdBlock] filters and it gets rid of all that I want. Maybe, I don't use or need it for any more than those two.
Oh well, I am rambling |
|
Back to top |
|
 |
wonkothesane The Other Developer
Joined: 22 May 2004 Posts: 210
|
|
Back to top |
|
 |
RejZoR Guest
|
Posted: Fri Jul 08, 2005 Post subject: |
|
|
Ok,i'm still examing syntaxes (hard stuff for now ).
All i need for now is to exclude specific URL from already used AdBlock filter (since there is no whitelist option).
I'm using */affiliates/* and it's working great. Problem is that this one also blocks Firefox logos/buttons from: http://www.spreadfirefox.com/?q=affiliates/homepage
Now what do i have to do to exclude:
http://sfx-images.mozilla.org/affiliates/*
from this filter:
*/affiliates/*
How do i do this?
Many thanks! |
|
Back to top |
|
 |
Henk Guest
|
Posted: Tue Jul 26, 2005 Post subject: Keep up the good work (ant the patience) |
|
|
Rue and cardinal,
Keep up the good work and especialy your endless patience!
As with anything, regex are complex until understood.
Thank you for your clear explaination, for you made it simple for me.
Thanks again! |
|
Back to top |
|
 |
jefree Guest
|
|
Back to top |
|
 |
mcm_ham

Joined: 17 Dec 2004 Posts: 310
|
|
Back to top |
|
 |
|