I was helping a friend with his Tripod
* site a few days ago, and soon I was very annoyed by the multitude of popup windows. I suggested he install Mozilla, but he didn't want to install such a big package for one day. Then I suggested he install the Google toolbar, but he balked at that too.
Finally, I suggested I create a quick popup blocker with Perl, which was already installed, and he said "Fine!" with a touch of irritation in his voice.
So I did, and just a few minutes later, here's the result:
#!perl
use strict;
use warnings;
use Win32::OLE qw/EVENTS/;
use Win32::OLE::Variant;
my $ie = Win32::OLE->CreateObject('InternetExplorer.Application', 'Qui
+t')
or die "Can't start IE", Win32::OLE::LastError();
$ie->{Visible} = 1;
$|++;
Win32::OLE->WithEvents($ie, 'main', 'DWebBrowserEvents2');
$ie->GoHome;
Win32::OLE->MessageLoop();
sub NewWindow2 {
my ($self, $browser, $cancel) = @_;
$cancel->Put(1);
print "$self->{LocationURL} tried to open a new window!\n";
}
sub OnQuit {
Win32::OLE->QuitMessageLoop;
}
Okay, it has some features (read limitations ;). It will block all new windows (even when you use the "Open in New Window" context menu) and it only works on the instance of IE that it started.
* Note - Tripod upgraded to 5.8 :) - but without any core modules :(
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.