Post Reply 
remove/replace blank?
Mar. 06, 2009, 09:59 PM
Post: #1
remove/replace blank?
Are the two code below perform the same function? If not can I please get a filter with the JS codes. I just want all instance of opening a new window/tab code to be remove.
Code:
[Patterns]
Name = "<a>...: Replace blank/new     6.08.13 (multi) [pr sd] (d.1 l.3)"
Active = TRUE
Multi = TRUE
URL = "($TYPE(htm)|$TYPE(js))(^$TST(keyword=*.(a_code|a_target|i_level:[12]).*))"
Bounds = "<a(rea)+\s*>|<form\s*>|<base\s*>"
Limit = 2048
Match = "(*target=\\+"+)\1 [_-]+(blank|new)(^[a-z0-9_-])\2"
        "&(^$TST(comment=1)|$TST(tNoscript=1))"
Replace = "\1_top\2"

Code:
// ==UserScript==
// @name Remove "target=_blank"
// @author Arve Bersvendsen
// @namespace http://virtuelvis.com/
// @description  This script will search for all links on a page, and
//            remove all instances of target="_blank" in the
//            page, so that web sites never, ever opens new
//            windows.
// @ujs:category general: enhancements
// @ujs:published 2005-05-11 15:08
// @ujs:modified 2005-09-19 09:19
// @ujs:documentation http://userjs.org/scripts/general/enhancements/remove-blank
// @ujs:download http://userjs.org/scripts/download/general/enhancements/removeblank.js
// @ujs:download.gm http://userjs.org/scripts/download/general/enhancements/removeblank.user.js
// @include *
// @exclude http://*.googlesyndication.com/*
// ==/UserScript==


/*
* This script is granted to the Public Domain
*/

document.addEventListener('load',function(ev){
  var d = document.getElementsByTagName('a');
  for (var i = d.length-1; i > -1; i--) {
    if (d[i].getAttribute('target') == "_blank") {
      d[i].removeAttribute('target');
    }
  }
},false);
Add Thank You Quote this message in a reply
Mar. 06, 2009, 10:06 PM
Post: #2
RE: remove/replace blank?
the replace blank/new does MORE than that script does...

that script is "limited to" target = _blank ONLY and is even FURTHER "limited" to those that exists within an <a> tag...

the filter covers <a>, <area>, <form>, <base> *and* catchtes not only _blank but catches _new as well...
Add Thank You Quote this message in a reply
Mar. 09, 2009, 09:55 PM
Post: #3
RE: remove/replace blank?
notice they don't filter out content provided by flash.

e.g http://www.samsungssd.com and click on the "read more" links and the link opens a new window/tab
Add Thank You Quote this message in a reply
Mar. 10, 2009, 01:34 AM
Post: #4
RE: remove/replace blank?
bugger;

Depends on the browser. Tabbed browsers that can't be configured might present a problem.... Those that can be configured of course won't need a filter - you'd just set your preference and go about your merry way. Smile!

If it's an older version of IE, or some other non-tabbed browser, then you're in luck, a filter will do the trick every time. In fact, I do just the opposite - I want a separate window for every link on certain sites, so I inject a "target='_blank'" into every link on any site contained in a list. (Why? Because the main page takes too long to reload, so I just "spawn" the link to a new window, and then kill it when I'm done. Presto! I'm right back at the site's main page without delay. Or, in one case, I need to do a comparison between two (or more) products. Voila! I have two spawned windows - I don't have to kill a window just to go back to the main page.)

Killing blanks or news is easy, just look for it like so (sorry, but I think your filter was doing more work than necessary):


Code:
Name = "kill new window links  [oddysey]"
Active = TRUE
Multi = TRUE
URL = "($TYPE(htm)|$TYPE(js))"
Bounds = "<a(rea|)\s*>|<base\s*>"
Limit = 256
MATCH = "\1 target=$AVQ(\2) \3
REPLACE = "<\1 \3>"


Discussion:
This filter is generalized to all browsers/filter configuration sets. Customize to comply with sidki's set as you see fit.

According to both my research and my experience, the Form element has no 'target=' attribute, unlike the anchor, area and base elements. Thus I've removed it from my version of the filter as well.

To make the <a(rea) match more dependably, use the OR symbol, like this: Bounds = "<a(rea|)\s*>|<base\s*>"

According to Scott, if you use the Bounds (with or without the Byte Limit), you must match on the exact same things in both the Bounds and Match strings. The easiest way to do that is with a \1 and \x in the Match string. You didn't do that, so I can only guess at what you might have gotten for results. Sad

Do you really need a 2KB byte limit? I've set mine at 256, and it's never failed me yet. Two thousand bytes of URL..... that's a lot of mozza! Drool

And finallly, you must capture the value of AVQ() into a variable. It's OK, of course, to ignore that value in the Replace string.

Give that a try, see what you think. Cheers


Oh, and filtering Flash is probably not gonna happen. I'm pretty sure that Scott didn't want to go down that whole road, what with filtering images, animations, all the various movie types..... that'd be a real nightmare! Again, a tabbed browser that's configurable might be able to avoid this, I dunno.

HTH



Oddysey

I'm no longer in the rat race - the rats won't have me!
Add Thank You Quote this message in a reply
Mar. 10, 2009, 06:08 PM
Post: #5
RE: remove/replace blank?
(Mar. 10, 2009 01:34 AM)Oddysey Wrote:  According to Scott, if you use the Bounds (with or without the Byte Limit), you must match on the exact same things in both the Bounds and Match strings. The easiest way to do that is with a \1 and \x in the Match string. You didn't do that, so I can only guess at what you might have gotten for results. Sad

This is a tough statement. I wonder why you do that. Sad Anyway...

First some suggestions.
Before saying that a filter doesn't work, test it. Proxomitron has a test window, where you can enter code such as:
Code:
<a href="foo" target="_blank">bar</a>

Before stating that form tags don't have a target attribute, check it, for instance at:
http://www.blooberry.com/indexdot/html/t...f/form.htm


Secondly, something to consider.
This is not a private conversation but a public forum. So, many people are likely to believe what you're saying. Especially if you are an admin. IOW, if you are an admin you have responsibilities. Causing confusion is certainly not one of them.


Finally, regarding other subforums, it's mostly up to you to try behaving with integrity and verify what you're saying.
However, this subforum is about supporting users of sidki-configs (i don't perceive them as *my* configs anymore).

I would have liked to keep it a helpful place, but, with all due respect, i have neither the time nor the energy to to clean up the mess you're creating. Apparently, no one else cares to jump in and set things straight.

Consequently, if you continue like that, i don't see how i could further offer support here.
Add Thank You Quote this message in a reply
Mar. 10, 2009, 08:40 PM
Post: #6
RE: remove/replace blank?
Bugger, i prefer a javascript method to have a cleaner log window. Maybe we should take a look to http://maxkueng.com/gmscripts it has a javascript called Blank must die. If we find it working well, we could say it here in a few days and try to adapt it to a filter. By the way the first filter is integrated in the sidki config, but maybe this subforum should be better used to report bugs, suggest things, help developing or do beta testing for a future release.

Oddysey, very old methods for IE6. Yes better with a newer browser where you can decide if open in a new tab or in the same only clicking with the wheel or with the left click.
Firefox have some settings like the next:
browser.link.open_newwindow = 1
browser.link.open_newwindow.restriction = 0
The 2k limit maybe was needed because of large javascript codes being executed when onclick, onmouseover etc

Sidki, i appreciate a lot your efforts in the arrangement/order. I agree in all of we when confussed just ask, if not just go to the test window, and if obtain some results you find interesting (for newbyes too) just post/SHARE them. To say here, would be nice if the forum should remember some laws to people before posting and some recomended posts to read when registering here to remember them the subforums we have, and the two things we have to add always when requesting help.
Add Thank You Quote this message in a reply
Mar. 11, 2009, 08:21 AM
Post: #7
RE: remove/replace blank?
(Mar. 10, 2009 06:08 PM)sidki3003 Wrote:  
(Mar. 10, 2009 01:34 AM)Oddysey Wrote:  According to Scott, if you use the Bounds (with or without the Byte Limit), you must match on the exact same things in both the Bounds and Match strings. The easiest way to do that is with a \1 and \x in the Match string. You didn't do that, so I can only guess at what you might have gotten for results. Sad

This is a tough statement. I wonder why you do that. Sad
Perhaps my mentioning Scott could have been a clue?...... From the Help file (Web Page Filter Editor), I quote:

Quote:When using bounds however, the situation changes. Since the bounds selects the range of text being searched - the matching expression must match everything matched by the bounds for the rule as a whole to match. The easiest way to do this is by using wildcards at both the beginning and end of the expression. Often matching variables are used (as in "\1 foo \2") so the text surrounding the part of the tag you're matching can be captured and included in the replacement text.
(Emphasis in italics are Scott's, not mine.)

That's my side of the story, and I'm stickin' to it! Wink

(Mar. 10, 2009 06:08 PM)sidki3003 Wrote:  Anyway...

First some suggestions.
Before saying that a filter doesn't work, test it. Proxomitron has a test window, where you can enter code such as:
Code:
<a href="foo" target="_blank">bar</a>
I'm not sure what your aim was with that. No one ever said that a filter didn't work. However, I did say that I thought (my opinion was) that bugger's filter was bit over-broad.

But reminding people about how to test a filter is never a waste of time, thanks for bringing it up.

(Mar. 10, 2009 06:08 PM)sidki3003 Wrote:  Before stating that form tags don't have a target attribute, check it, for instance at:
http://www.blooberry.com/indexdot/html/t...f/form.htm
First, let me start by apologizing. My information was from the w3cschools website, and they don't show Target as an attribute for the Form element. I didn't think to double-check that with the real thing, w3c.org itself. Generally, the school's site presents its information more clearly, with better examples. However, I do stand corrected, Target is a valid attribute for the Form element. I don't recall ever seeing it used, anywhere in the wild, but the authors of the original specification must have had something in mind, when they set that one in stone, eh?

Further, a little more research, which I admit I should have done during my last reply, shows that the Target attribute is also valid for Frames and Links, as well as the Anchor, Area, Base, and Form elements. All of these could easily be incorporated into the Boundry check.


(Mar. 10, 2009 06:08 PM)sidki3003 Wrote:  Secondly, something to consider.
This is not a private conversation but a public forum. So, many people are likely to believe what you're saying. Especially if you are an admin. IOW, if you are an admin you have responsibilities. Causing confusion is certainly not one of them.

Finally, regarding other subforums, it's mostly up to you to try behaving with integrity and verify what you're saying. However, this subforum is about supporting users of sidki-configs (i don't perceive them as *my* configs anymore).

I would have liked to keep it a helpful place, but, with all due respect, i have neither the time nor the energy to to clean up the mess you're creating. Apparently, no one else cares to jump in and set things straight.

Consequently, if you continue like that, i don't see how i could further offer support here.
Well, that certainly comes out of the clear blue! All I can say is, I'm sorry that somebody pee'd in your Cheerios this morning man, that's just so unlike you. Sad

I hope the rest of your day goes better, such that you come out of your funk sooner rather than later. As far as I'm concerned, this was just a hiccough between friends, alright?



Oddysey

I'm no longer in the rat race - the rats won't have me!
Add Thank You Quote this message in a reply
Mar. 11, 2009, 08:24 PM
Post: #8
RE: remove/replace blank?
Code:
[Patterns]
Name = "<a>...: Replace blank/new     6.08.13 (multi) [pr sd] (d.1 l.3)"
Active = TRUE
Multi = TRUE
URL = "($TYPE(htm)|$TYPE(js))(^$TST(keyword=*.(a_code|a_target|i_level:[12]).*))"
Bounds = "<a(rea)+\s*>|<form\s*>|<base\s*>"
Limit = 2048
Match = "(*target=\\+"+)\1 [_-]+(blank|new)(^[a-z0-9_-])\2"
        "&(^$TST(comment=1)|$TST(tNoscript=1))"
Replace = "\1_top\2"

I think:
The Bounds begin with < and end with >.
The Match uses * and \2 to cover the Bounds.
The filter matches the exact same things in both the Bounds and Match strings. IOW, it works.
The filter is also checking scripts and needs a large Byte Limit.
I would have complained years ago, if it didn't work. Wink
<a(rea)+\s is as good as and is often quicker than <a(rea|)\s but harder to explain.
You don't have to capture the value of $AVQ() into a variable.
Lots of people can't follow, test, or debug the expressions. Sidki can.
Somebody should review their posts. Wink

Code:
[Patterns]
Name = "Test +"
Active = FALSE
Limit = 256
Match = "A+B"
Replace = "C"
Test against
Code:
BBBBBBBBBBBBBBBB
Result
Code:
CCCCCCCCCCCCCCCC

So while
Proxo Help Wrote:The plus sign indicates a run of repeating characters. For instance, "a+" would match "a", "aa", or "aaaa".
it also appears to match a run of none.
IOW, A+B matches B.
Something like A+{0,*}B or (A+B|B) or (A+|)B is not needed.
If there must be an A, AA+B or A+{1,*}B could work.

About (^[a-z0-9_-])\2
Code:
[Patterns]
Name = "What the ?"
Active = FALSE
Limit = 256
Match = "(^[a-z0-9_-])\2"
Replace = "**\2**"
Test against
Code:
;BBBBBBBBBBBBBBBB
Result
Code:
**;BBBBBBBBBBBBBBBB**
\2 captured everything!?
Not just the semicolon!?

Proxo Help Wrote:For example, "(^foo|bar)" would match anything that's not "foo" or "bar".
Note that a negated expression consumes no characters - it just test them. I think Perl calls this a "negative forward assertion"?
So, if (^foo|bar) nothing will be consumed...
Then, \2 must only capture things that are consumed.
Since, (^[a-z0-9_-]) doesn't consume and just tests.
(^[a-z0-9_-])\2 must act like (^[a-z0-9_-])(*)\2

Code:
Bounds = "<a(rea)+\s*>|<form\s*>|<base\s*>"
Match = "(*target=\\+"+)\1 [_-]+(blank|new)(^[a-z0-9_-])\2"
So:
Bounds = "<a(rea)+\s*>|<form\s*>|<base\s*>"
or
Bounds = "<a(rea|)\s*>|<form\s*>|<base\s*>"
or
Bounds = "<area\s*>|<a\s*>|<form\s*>|<base\s*>"

Match = "(*target=\\+"+)\1 [_-]+(blank|new)(^[a-z0-9_-])\2"
or
Match = "(*target=\\+{0,*}("|))\1 (_|-|)(blank|new)(^[a-z0-9_-])(*)\2"

Quote:And finallly, you must capture the value of AVQ() into a variable.
Code:
[Patterns]
Name = "Test $AVQ"
Active = FALSE
Limit = 256
Match = "=$AVQ(*)"
Replace = "="
Test against
Code:
="BBBBBBBBBBBBBBBB" B
Result
Code:
= B

Conclusion:
The Bounds begin with < and end with >.
The Match uses * and \2 to cover the Bounds.
The filter matches the exact same things in both the Bounds and Match strings. IOW, it works.
<a(rea)+\s is hard to explain. I'll leave the speed tests to the users.
You don't have to capture the value of $AVQ() into a variable.
Lots of people can't follow, test, or debug the expressions. Sidki can.
Somebody should review their posts. Wink
FWIW

I'm typing this and missing the Basketball games... Sad

Hope I did good.
Have fun.
Add Thank You Quote this message in a reply
Mar. 11, 2009, 09:14 PM
Post: #9
RE: remove/replace blank?
JJoe , it's wonderful to have you back !! This thread is so far over my head that I was getting dizzy trying to follow it . But when I saw your post I was overjoyed that you are well and back on the forum . Best regards , Ralph
Add Thank You Quote this message in a reply
Mar. 11, 2009, 10:29 PM
Post: #10
RE: remove/replace blank?
JJoe,

I second Ralph's welcoming sentiments, it'll be good to get the place back to full-effort productivity.

Of course, since there are now two of you who think, within the same thread, that I need to take a vacation, I will now do so, and leave this place in good hands.

Ta-ta!



Oddysey

I'm no longer in the rat race - the rats won't have me!
Add Thank You Quote this message in a reply
Mar. 12, 2009, 12:25 AM
Post: #11
RE: remove/replace blank?
JJoe, very welcome and very good post!! I didn't know about these tricks and bugs. Thanks!!

Oddysey, the grandpa of the forum Wink i hope you don't count with a vote from me to you to take some vacation. I think we must live and take care with the possible confussions of having written conversations (i use to edit silently old posts when i think someone could understand something bad). The good thing is we can communicate everyday at everyhour, but as we can't listen us, we can tend to don't get the tone of a friendly conversation :/

My point to remember people some things before creating a new thread is:
1) test with the config released, being sure a filter the user added is not the culprit.
2) do some debug as i explained in the thread to know what filter is causing problems
3) if needing help add [req], what browser, his version and what proxomitron config set is using, at least one link where the problem happens.
4) know in what subforum to post
5) remember the hard work for free of people posting here, respect their work, say thanks, don't demand anything and follow the above law to don't bore the people wich share here. I know many people don't post here to don't get interrogated about their filters. So these laws should help all of us.

And when registering to the forums:
1) explain them what subforums we have, and for what are all of them
2) tell them to read our recommended threads
Add Thank You Quote this message in a reply
Mar. 12, 2009, 02:25 AM (This post was last modified: Mar. 12, 2009 02:28 AM by JJoe.)
Post: #12
RE: remove/replace blank?
Quote:Of course, since there are now two of you who think, within the same thread, that I need to take a vacation, I will now do so,


I don't see how you reached this conclusion, especially when one of those two is me. Somebody hasn't been paying attention over years.
I want people to have and help others have fun.

I think you have experiences, talents, skills, and enjoy helping and posting.
You are proud of this place, your part in it, and want it to be better.
Looks to me like you must participate. Smile!

I don't enjoy posting much.
Seems like everytime I turn around somebody is threatening to take a vacation! Wink

For a number of reasons, I can't claim to be "back".
I did have the time and ability (I think) to explain or show somethings.
I hoped it would help.

You better hang around.

and

Have fun.

Gotta go.
Add Thank You Quote this message in a reply
Post Reply 


Forum Jump: