Author Topic: Popup Bookmarklets  (Read 1172 times)

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Popup Bookmarklets
« on: May 30, 2002, 02:48:58 PM »
Hi,

I'm looking for a way to make certain bookmarklets work without sacrificing my popup killer.

Here is an example, where you mark an English or German keyword on a webpage.
A new window will popup with the corresponding translation.
If nothing is marked on the page, you are prompted for the keyword.

javascript:Qr=document.selection.createRange().text;if(!Qr){void(Qr=prompt('Keywords...',''))}if(Qr)mahatma=window.open('http://dict.leo.org/?search='+escape(Qr),"");mahatma();

Now we have two problematic functions.
prompt:
I disabled the nullifier in Paul Rupe's start.js and will see whether i get nagged.
window.open:
That's the beast. I think the most efficient filters for it are the JavaScript ones, like windowopen.js or start.js.

The thing would be to write an exception pattern that covers bookmarklets like so:

function KillAllPopupsButBookmarklets()
{
  if ("exception pattern goes here")
    return true;
  else
  {
    return false;
  }
}

I don't know enough about JavaScript to get this to work.
Any ideas?

regards, sidki


 
 

hpguru

  • Sr. Member
  • ****
  • Posts: 257
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://lightning.prohosting.com/~hpguru/
    • Email
Popup Bookmarklets
« Reply #1 on: May 30, 2002, 08:19:27 PM »
Are you running IE and if so do you have active scripting disabled for that sites zone? I have found that some of my bookmarklets may not work correctly or at all in my restricted zone or in a mixed zone.

Here is what I use to disable popup and popunder windows. First I use this filter (a variation on Scott's filter) to disable active scripting everywhere.


Name = "Disable Active Scripting"
Active = TRUE
URL = "(^$LST(AllowScript))"
Limit = 256
Match = "<script*>"
Replace = "<script language="0">"


This one is just a tad faster than Scott's filter when a list is employed but not much.

The next filter disables the event handlers "onload" and "onunload" in the body tag but it only works in IE (I think only IE6). Netscape 4.x will report an error. Opera doesn't report an error but it doesn't work either.


Name = "Disable BODY Event Handlers"
Active = TRUE
Limit = 256
Match = "(<body*>)"
Replace = ""
          "<script>"
          "document.body.onload = 'null';"
          "document.body.onunload = 'null';"
          "</script>"


This filter resets those event attributes to their default values. I've been testing it for about a month. I haven't seen a popup or popunder the whole time. Of course there are lots of other event handlers that can open a popup but nullifying these two alone seem to be doing the trick for me. This filter also does the job without having to search for the event attributes.

 
Facing each other,
a thousand miles apart.

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Popup Bookmarklets
« Reply #2 on: May 30, 2002, 09:19:50 PM »
Hi hpguru, thanks for your response.

Yes i'm running IE6. My internet zone has active scripting enabled and i'm prompted in the others.
The zone responsable for the bookmarklet should be the zone the currently displayed page is in.
So that's ok.

These two filters are definitely sufficient. Just went to a testing page with them.
Unfortunately disabling active scripting all together (except listed sites) is too restrictive for my purposes.
I'll have to go with tweaking the window.open function, which can be redefined via JS.

 
 

hpguru

  • Sr. Member
  • ****
  • Posts: 257
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://lightning.prohosting.com/~hpguru/
    • Email
Popup Bookmarklets
« Reply #3 on: May 31, 2002, 12:48:33 AM »
I began disabling Active Content everywhere (with the exception of select sites)some time ago. At the time I was using Netscape as my default browser and I finally got fed up with poorly composed scripts causing Netscape to crash (doesn't take much). Anyway I've grown accustomed to blocking active content. I've found most sites that use scripting don't make it a hard requirement for access. If there is something worth while at the site such that I will want to make frequent stops and I think I can trust them then it is easy enough to upgrade their privileges to allow them to run scripts, java or whatever. That made browsing with Netscape a much more satisfying experience and I'm sure it improves my experience with IE as well although I must admit, IEs error handling routines are vastly superior to Netscapes.

 
Facing each other,
a thousand miles apart.

xartica

  • Newbie
  • *
  • Posts: 38
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • Email
Popup Bookmarklets
« Reply #4 on: May 31, 2002, 02:52:22 AM »
Sidki3003:
With MSIE, you should be able to drag the bookmarklet to you "Links" toolbar. When you activate the bookmarklet, IE should handle it in the "local" security context (regardless of the location of the page you're running the bookmark against).

Hpguru:
My config "nulls" onunload via a filter that matches <end>.
I didn't come up with this idea, but agree that it's a necessity
(matching <end>, that is) because a page could contain an inline script
that RE-reassigns onunload, after your script (inserted just below the opening body tag) has nulled it.



 
 

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Popup Bookmarklets
« Reply #5 on: May 31, 2002, 03:17:38 AM »
Xartica, that doesn't do it. "Bypass proxy server for local addresses" ticked, not sure whether that makes a difference.

 
 

hpguru

  • Sr. Member
  • ****
  • Posts: 257
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://lightning.prohosting.com/~hpguru/
    • Email
Popup Bookmarklets
« Reply #6 on: May 31, 2002, 04:27:43 AM »
I concidered matching
<end>
When I created the filter. There was some reason why I opted to match the body tag but at the moment I can't remember what my reasoning was.

I've noted instances where bookmarklets failed to execute and the site I was attempting to act upon or within was in the restricted zone. Yes it is odd but it happens. I've also seen this happen when attempting to fetch a script via Local.ptron.

 
Facing each other,
a thousand miles apart.

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Popup Bookmarklets
« Reply #7 on: June 05, 2002, 01:27:15 PM »
I finally got it working

First step:
Give the bookmarklet a common windowname like so:

function=window.open("somesite.com","bmwindow");

Now one can test for it in start.js or windowopen.js
(thanks TEggHead/JarC for this one ).

Second step:
I'm using start.js which has known problems with IE's read-only functions.
So replacing

eval(replaceFunctionPROX('open', 'oldOpenPROX', 'openPROX', 'u, n, p'));

with

oldOpenPROX=window.open;
window.open=openPROX;

was necessary (no real clue why this one works and not the other ).

Third step:
function openPROX(url, name, props) has to be changed from

  if (!popupsAllowedPROX ||

to

  if (name.indexOf('bmwindow') != -1)
  {
  return oldOpenPROX(url, name);
  }
  else if (!popupsAllowedPROX ||

regards, sidki