Author Topic: Anti-Auto-JS-Redirection  (Read 4320 times)

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Anti-Auto-JS-Redirection
« on: June 28, 2002, 12:42:31 PM »
updated 2002-08-14

Hi all,

Here is a filter that converts JavaScript redirects to an option.

[Patterns]
Name = "<script>: Anti-Auto-JS-Redirection"
Active = TRUE
URL = "$TYPE(htm)"
Bounds = "$NEST(<script,</script*>)"
Limit = 512
Match = "*.location(.href|)="([^"'+]++)1 " (^+)*"
Replace = "<center><a class="prox" href="1">[JS Redirect]</a></center>$STOP()"

As always, if you don't use stylesheets, the replacement can be simplified to:

Replace = "<center><a href="1">[JS Redirect]</a></center>$STOP()"

regards, sidki

Edited by - sidki3003 on 16 Aug 2002  21:17:15
 

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Anti-Auto-JS-Redirection
« Reply #1 on: July 18, 2002, 02:43:39 PM »
Some more changes.

[Patterns]
Name = "<script>: Anti-Auto-JS-Redirection"
Active = TRUE
Bounds = "$NEST(<script,</script*>)"
Limit = 512
Match = "*.location(.href|)="(^['"+]) 1"*"
Replace = "<span class=prox style=display:inline;>"
          "<center><a class="prox" href="1">[JS Redirect]</a></center></span>"

sidki

 
 

altosax

  • Moderator
  • Sr. Member
  • *****
  • Posts: 328
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Anti-Auto-JS-Redirection
« Reply #2 on: July 25, 2002, 12:25:02 AM »
tegghead wrote:

quote:

Not for one thing or another, but dumping html in the middle of a script usually generates JS errors for me, preventing any inserted subsequent script to not be executed and thus sometimes killing the effects of say end.js...



i'm not using this filter but it should not place html in script tags because all bounds are replaced. have you modified the filter?

regards,
altosax.

 
 

altosax

  • Moderator
  • Sr. Member
  • *****
  • Posts: 328
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Anti-Auto-JS-Redirection
« Reply #3 on: July 25, 2002, 12:26:32 AM »
i don't know why, but my reply was placed BEFORE the post i was replying!!!

 
 

TEggHead

  • Jr. Member
  • **
  • Posts: 93
    • ICQ Messenger - 21893433
    • AOL Instant Messenger -
    • Yahoo Instant Messenger - eljarec
    • View Profile
    • Email
Anti-Auto-JS-Redirection
« Reply #4 on: July 25, 2002, 11:08:23 AM »
quote:

Some more changes.

Bounds = "$NEST(<script,</script*>)"

Replace = "<span class=prox style=display:inline;>"
          "<center><a class="prox" href="1">[JS Redirect]</a></center></span>"



Not for one thing or another, but dumping html in the middle of a script usually generates JS errors for me, preventing any inserted subsequent script to not be executed and thus sometimes killing the effects of say end.js...

I think this one would be perfect candidate for a function replacement a la PRX_open? (sadly redefining of location.replace does not seem to work with IE5.0 but 5.5 and up allow it at least although it would be problematic with location.href I admit)

 

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Anti-Auto-JS-Redirection
« Reply #5 on: July 25, 2002, 04:46:28 PM »
Let's see where this reply is placed in the thread

quote:

Not for one thing or another, but dumping html in the middle of a script usually generates JS errors for me, preventing any inserted subsequent script to not be executed and thus sometimes killing the effects of say end.js...



I didn't notice that on my box yet (XP, IE6) as long as i, as altosax stated, replace the whole script.

quote:

I think this one would be perfect candidate for a function replacement a la PRX_open? (sadly redefining of location.replace does not seem to work with IE5.0 but 5.5 and up allow it at least although it would be problematic with location.href I admit)



Paul Rupe has implemented that in version 1.32 of start.js:

Code:

// Intercept calls to *.location = or *.location.replace()
function setLocationPROX(l)
{
  if (pageIsLoadingPROX)
    document.write('<center><a class=proxlink target=_top href="' + l +
                   '">[Tame Redirect]</a><center>');
  else
    top.location = l;
  return false;
}
location.replace = setLocationPROX;



While this works nicely for location.replace(), it has no effect (IE6) on location and (as you mentioned) location.href .

sidki

 
 

sidki3003

  • Sr. Member
  • ****
  • Posts: 476
    • ICQ Messenger -
    • AOL Instant Messenger -
    • Yahoo Instant Messenger -
    • View Profile
    • http://
    • Email
Anti-Auto-JS-Redirection
« Reply #6 on: August 14, 2002, 03:48:46 PM »
Updated to leave alone URLs containing JS expressions.
Changes in the first post.
quote:

While this works nicely for location.replace(), it has no effect (IE6) on location and (as you mentioned) location.href .


If modified accordingly, that is.