The Un-Official Proxomitron Forum

Full Version: Google Filter
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Would it be possible to make a filter that can filter some of Google's searches out? I want to make one so that when it sees a link that is in the HOSTS file, it will change the color to red or something so I know it's a bad link. Can this be done with Proxo or is it too over-the-top and needs to be done with an external program?
I'm guessing that your HOSTS file would first need copied into a Proxo "list"...

Once the HOSTS entries are in a list, it's pretty easy to highlight them within Google...
OK, but I'm just learning how to write filters and too good at it. Could one fo you guys start me out? And, if it's going to read from a list, wouldn't we have to remove the 127.0.0.1 from all the HOSTS entries?
For starters, yes, you'd need to make a .txt file out of your HOSTS file that does not contain the 127.0.0.1's...

Let's say you have a list and saved it as c:\<your directory>\Proxomitron\Lists\Hosts.txt...

You would then add List.Hosts = "..\Lists\Hosts.txt" to your Proxo config's Blocklists section...

Then try something like (just a stab, haven't tested):
Code:
Name = "Highlight: &nbsp;Links Contained within HOSTS File"
Active = TRUE
URL = "$TYPE(htm)"
Bounds = "<a\s*>"
Limit = 512
Match = "\0 (href=$AV(*$LST(Hosts)*))\1 \2"
Replace = "\0 class='javascript' title='Warning: &nbsp;HOSTS Link...' \1 \2"

Note that class='javascript' is to use a style highlight already defined by both sidki's and JD's config sets... You could also just as easily create a new class in the respective config's .css file...


Hope that helps to get you started...
Thanx ProxRocks! I'll test that filter or modify it to work. I think that will give me enough foundation to make it work.
Cool, let us know what you come up with...
It kind of works. The message when you hover over it works, but I'm trying to get the link to be highlighted. Any ideas?
Here's the ending filters, I've come up with. I couldn't figure out how to implement the CSS into one filter so I made separate ones.

Code:
[Patterns]
Name = "Highlight: Change CSS - [Shea]"
Active = TRUE
Multi = TRUE
URL = "$TYPE(htm)"
Limit = 512
Match = "<head>"
Replace = "<head><style>.javascript{background-color:#FF0000;color:#000000;}.javascript:link, .javascript:hover, .javascript:active, .javascript:visited{color:#000000}</style>

Name = "Highlight:  Links Contained within HOSTS File - [ProxRocks & Shea]"
Active = TRUE
URL = "$TYPE(htm)"
Bounds = "<a\s*>"
Limit = 512
Match = "\0 (href=$AV(*$LST(Hosts)*))\1 \2"
Replace = "\0 class='javascript' title='Warning:  HOSTS Link...' \1 \2<font color='#000000'>!!! - </font> "

You can edit them all you want, but they work fine for me!
If the destination of a link is in a Hosts file, clicking the link should not result in a connection, anyway, so why bother with a warning?
Why not? I just wanted it to tell me if it's in the HOSTS file so I don't bother clicking on it or consider going to it.
Shea;

I like your idea. Now, instead of highlighting in red, how 'bout making the link a light gray, so that it "looks" like it's unavailable, like the rest of the Windows world - 'grayed out' equals 'not currently available'.

Or, if you're really feeling frisky, you can make the link truly unavailable. Do that by re-writing the link itself to remove the "href=" within the <a> tag. You can safely leave the source name itself - if it doesn't have the "href=" in front of it, the browser will just ignore it. What you'll see on the page won't be an underlined link, just regular text (which you can still color as you wish). You could even preface the link text with additional text - "HOSTS File Entry - ....", or something like that, so that you don't get frustrated trying to click what "should" be a link! [rolleyes]

That'll tell you that you can't go there! Big Teeth


BTW, guys, I'm wondering about something here. This list of over 22,000 entries long - won't that slow Proxo down somewhat? As I see it, the list will be consulted every time a Port 80 request is made. If that happens many times per page, I should think that Proxo would slow your browsing experience, no? What's the consensus here - am I overly worried about nothing, or what?

Oddysey
Seems like a valid concern to me...

Personally, I use hpguru's HOSTS file and have NEVER bumped into a Google Search link that was contained within the HOSTS file... But I imagine that if you used the HOSTS file for other purposes, oh I don't know, like blocking porn or gambling sites, then, well, I could see the benefits of such a filter...

Perhaps this whole excercise was really more of an "experiment"...
..::Oddysey::..

I took that into consideration since I'm on dial-up. I did notice it slowing down so I limited only to Google.com.
Shea, et vas anders;

Yeah, I must have been sleeping when you said "Google" the first time. Banging Head So what if your Google search returns are bit slower, so long as they tell you what you want to know.

BTW, 4 out of 5 doctors recommend getting and using a broadband connection to reduce or eliminate stressful tension in your life! :o Wink [lol]


Oddysey
Here is my final filter. I think you'll like it. It is set only to work on Google and it grays out the links and sets the link to Google.com. It also adds the prefix '!!!' to all the links.

Code:
Name = "Highlight: Change CSS"
Active = TRUE
Multi = TRUE
URL = "$TYPE(htm)(www.|)google.com/"
Limit = 512
Match = "<head>"
Replace = "<head><style>.javascript{font-family:Verdana,sans-serif;color:#C0C0C0;text-decoration:none;font-weight:bold}.javascript:link, .javascript:hover, .javascript:active, .javascript:visited{color:#C0C0C0}</style>"

Name = "Highlight: Links Contained within HOSTS File"
Active = TRUE
URL = "$TYPE(htm)(www.|)google.com/"
Bounds = "<a\s*>"
Limit = 512
Match = "\0 (href=$AV(*$LST(Hosts)*))\1 \2"
Replace = "<a href=""class='javascript' title='Warning: &nbsp;HOSTS Link...' \1 \2<font color='#000000'>!!!</font>"
Pages: 1 2
Reference URL's