Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #30895 > unrolled thread

[Browser] How to replace strings in a URL with a javascript boormarklet?

Started byarpegiateur@gmail.com
First post2016-07-18 13:42 -0700
Last post2016-07-19 13:41 -0700
Articles 20 on this page of 31 — 5 participants

Back to article view | Back to comp.lang.javascript


Contents

  [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-07-18 13:42 -0700
    Re: [Browser] How to replace strings in a URL with a javascript boormarklet? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-07-18 23:24 +0200
      Re: [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-07-19 08:10 -0700
        Re: [Browser] How to replace strings in a URL with a javascript boormarklet? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-07-19 19:49 +0200
          Re: [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-07-19 13:34 -0700
            Re: [Browser] How to replace strings in a URL with a javascript boormarklet? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-07-20 09:39 +0200
              Re: [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-07-20 10:09 -0700
                Re: [Browser] How to replace strings in a URL with a javascript boormarklet? Osmo Saarikumpu <osmo@weppipakki.com> - 2016-07-21 16:21 +0300
                  Re: [Browser] How to replace strings in a URL with a javascript boormarklet? Osmo Saarikumpu <osmo@weppipakki.com> - 2016-07-21 16:36 +0300
                    Re: [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-07-22 12:19 -0700
                      Re: [Browser] How to replace strings in a URL with a javascript boormarklet? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-07-22 23:20 +0200
                        Re: [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-07-22 18:13 -0700
                          Re: [Browser] How to replace strings in a URL with a javascript boormarklet? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-07-23 12:02 +0200
                            Re: [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-07-26 11:49 -0700
                              Re: [Browser] How to replace strings in a URL with a javascript boormarklet? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-07-27 00:20 +0200
                                Re: [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-07-28 08:07 -0700
                                  Re: [Browser] How to replace strings in a URL with a javascript boormarklet? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-07-28 19:24 +0200
                                    Re: [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-07-28 14:44 -0700
                                      Re: [Browser] How to replace strings in a URL with a javascript boormarklet? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-07-29 00:29 +0200
                                        Re: [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-07-30 07:53 -0700
                                          Re: [Browser] How to replace strings in a URL with a javascript boormarklet? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-07-30 17:59 +0200
                                            Re: [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-08-03 08:03 -0700
                                              Re: [Browser] How to replace strings in a URL with a javascript boormarklet? "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2016-08-03 10:05 -0700
                                              Re: [Browser] How to replace strings in a URL with a javascript boormarklet? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-03 23:38 +0200
                                                Re: [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-08-04 13:09 -0700
                                                  Re: [Browser] How to replace strings in a URL with a javascript boormarklet? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-04 22:37 +0200
                                                    Re: [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-08-05 10:54 -0700
                                                      Re: [Browser] How to replace strings in a URL with a javascript boormarklet? "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2016-08-05 20:31 +0200
    Re: [Browser] How to replace strings in a URL with a javascript boormarklet? Aleksandro <aleksandro@gmx.com> - 2016-07-19 15:45 -0400
      Re: [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-07-19 13:40 -0700
      Re: [Browser] How to replace strings in a URL with a javascript boormarklet? arpegiateur@gmail.com - 2016-07-19 13:41 -0700

Page 1 of 2  [1] 2  Next page →


#30895 — [Browser] How to replace strings in a URL with a javascript boormarklet?

Fromarpegiateur@gmail.com
Date2016-07-18 13:42 -0700
Subject[Browser] How to replace strings in a URL with a javascript boormarklet?
Message-ID<fe04be32-6355-40e1-9ba4-f656650a1612@googlegroups.com>
 -1
down vote
favorite
	

I regularly visit a site that is using and abusing more and more of those links protectors where you have to wait -with the tab in focus or the timer won't run-, only to open another link protector where you have to proof you're not a robot, then choose from a collection of images the ones that have trees (oh yes), and then wait a few more seconds to finally open the damn link, only to find that sometimes it doesn't have what I wanted (music album previews).

I have 160 links to process and I refuse to go through all this everytime.

The link is something like this:

http://sh.st/r/54a92df92a7214a3b10b7be0308d9088/12/1/http://ouo.io/s/7GRMeb12/?s=http%3A%2F%2Fwww.amazon.co.uk%2Fgp%2Fproduct%2FB01AJ05PXC%3Fkeywords%3DLust%2520for%2520Youth%2520-%2520Compassion%26qid%3D1456989377%26ref_%3Dsr_1_1%26sr%3D8-1

The URL shorteners are always those 2, sh.st and ouo (I had to put a space in each of them or the editor wouldn't let me to post this). As you can see I need 2 things: To eliminate those 2 spammy annoying and frustrating link protectors and keep only the 3rd link which is the one with the content I want (in htis case, amazon).

The other is to substitute those %2F and other hex combinations with their real values like : and / .

I already have a list for those values, I just need an example where 1 or 2 of those are replaced, but I don't know anything about javascript, I'm more of a DOS/batch guy (archaic, I know :P).

My objective is to have a bookmarklet, a bookmark with javascript code in it that with just one click, grabbs the current double protected link, filters out the trash in it, substitutes hex strings with the correct values, and finally navigates to that link. I'm sure this is easy for someone with average knowledge of javascript.

Can anyone help me?

[toc] | [next] | [standalone]


#30896

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-07-18 23:24 +0200
Message-ID<XnsA649EE145C3BEeejj99@194.109.6.166>
In reply to#30895
arpegiateur@gmail.com wrote on 18 Jul 2016 in comp.lang.javascript:
> I regularly visit a site that is using and abusing more and more of
> those links protectors where you have to wait -with the tab in focus or
> the timer won't run-, only to open another link protector where you have
> to proof you're not a robot, then choose from a collection of images the
> ones that have trees (oh yes), and then wait a few more seconds to
> finally open the damn link, only to find that sometimes it doesn't have
> what I wanted (music album previews). 
> 
> I have 160 links to process and I refuse to go through all this
> everytime. 
> 
> The link is something like this:
> 
> http://sh.st/r/54a92df92a7214a3b10b7be0308d9088/12/1/http://ouo.io/s/7GRM
> eb12/?s=http%3A%2F%2Fwww.amazon.co.uk%2Fgp%2Fproduct%2FB01AJ05PXC%3Fkeywo
> rds%3DLust%2520for%2520Youth%2520-%2520Compassion%26qid%3D1456989377%26re
> f_%3Dsr_1_1%26sr%3D8-1 
[..]
> 
> My objective is to have a bookmarklet, a bookmark with javascript code
> in it that with just one click, grabbs the current double protected
> link, filters out the trash in it, substitutes hex strings with the
> correct values, and finally navigates to that link. I'm sure this is
> easy for someone with average knowledge of javascript. 

<!DOCTYPE html>
<html><head>
<script>
function decode(t) {
location.href=decodeURIComponent(t.value.replace(/^.*(http)/,'$1'));
};
</script>
</head><body>

Drop or paste the code in the textarea and then click on it:

<br><br>
<textarea onclick='decode(this)' style='height:200px;width:500px;'>
</textarea>
</body></html>




-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#30898

Fromarpegiateur@gmail.com
Date2016-07-19 08:10 -0700
Message-ID<7efb128d-dbde-48ec-9f49-edc7fb99ff95@googlegroups.com>
In reply to#30896
Wow! That works amazing, and with much less code than I imagined. Still, and I'm not trying to streching it here, but could you transform that into those bookmarklets that start with "javascript:" so that I could just click on it the moment the url shortener page appeared;  instead of opening your html file, go to the shortened page, drag the link to your html and click on it?

If you could do it, awsome, if not, amazing job anyway, because you already saved me a lot of frustration and time :-)

Cheers, and tank you again.




On Monday, July 18, 2016 at 10:24:16 PM UTC+1, Evertjan. wrote:
> arpegiateur[at]gmailDOTcom wrote on 18 Jul 2016 in comp.lang.javascript:
> > I regularly visit a site that is using and abusing more and more of
> > those links protectors where you have to wait -with the tab in focus or
> > the timer won't run-, only to open another link protector where you have
> > to proof you're not a robot, then choose from a collection of images the
> > ones that have trees (oh yes), and then wait a few more seconds to
> > finally open the damn link, only to find that sometimes it doesn't have
> > what I wanted (music album previews). 
> > 
> > I have 160 links to process and I refuse to go through all this
> > everytime. 
> > 
> > The link is something like this:
> > 
> > http://sh.st/r/54a92df92a7214a3b10b7be0308d9088/12/1/http://ouo.io/s/7GRM
> > eb12/?s=http%3A%2F%2Fwww.amazon.co.uk%2Fgp%2Fproduct%2FB01AJ05PXC%3Fkeywo
> > rds%3DLust%2520for%2520Youth%2520-%2520Compassion%26qid%3D1456989377%26re
> > f_%3Dsr_1_1%26sr%3D8-1 
> [..]
> > 
> > My objective is to have a bookmarklet, a bookmark with javascript code
> > in it that with just one click, grabbs the current double protected
> > link, filters out the trash in it, substitutes hex strings with the
> > correct values, and finally navigates to that link. I'm sure this is
> > easy for someone with average knowledge of javascript. 
> 
> <!DOCTYPE html>
> <html><head>
> <script>
> function decode(t) {
> location.href=decodeURIComponent(t.value.replace(/^.*(http)/,'$1'));
> };
> </script>
> </head><body>
> 
> Drop or paste the code in the textarea and then click on it:
> 
> <br><br>
> <textarea onclick='decode(this)' style='height:200px;width:500px;'>
> </textarea>
> </body></html>
> 
> 
> 
> 
> -- 
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#30900

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-07-19 19:49 +0200
Message-ID<XnsA64AC9985FA77eejj99@194.109.6.166>
In reply to#30898
arpegiateur@gmail.com wrote on 19 Jul 2016 in comp.lang.javascript:

> Wow! That works amazing, and with much less code than I imagined. Still,
> and I'm not trying to streching it here, but could you transform that
> into those bookmarklets that start with "javascript:" so that I could
> just click on it the moment the url shortener page appeared;  instead of
> opening your html file, go to the shortened page, drag the link to your
> html and click on it? 

What is a "shortened page", is there no html in it?

How do you want to get the information to your bookmarklet?

If you put my html-page somewhere, on a server or on your pc,
and put the link in the bookmark-bar, what is the working difference with a 
bookmarklet?

> If you could do it, awsome, if not, 

It is just that I don't exactly understand what you envision.

Please do not toppost, 
do sparce interpost without quoting signatures on Usenet.

> amazing job anyway, because you
> already saved me a lot of frustration and time :-) 
> 
> Cheers, and tank you again.




-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#30917

Fromarpegiateur@gmail.com
Date2016-07-19 13:34 -0700
Message-ID<0a3eba30-0511-4cb4-b191-11623ec1fcbc@googlegroups.com>
In reply to#30900
 
> What is a "shortened page", is there no html in it?

That entire link in my 1st post here is the shortener page, the first of two. It's the page that makes you wait before it opens the link I want. 


> How do you want to get the information to your bookmarklet?

For instance like a bookmarklet I have here called 'Translate page' that takes the URL, puts it into Google translator and translates the entire page. In essence, it takes the URL and processes it.

> If you put my html-page somewhere, on a server or on your pc,
> and put the link in the bookmark-bar, what is the working difference with a 
> bookmarklet?
Not much, unless I change the Operating system or even the browser (I do that when my browser starts to get bloated), and then I'll certainly forget of that html file, risking having only that bookmark pointing to a non-existent file.
I could save the Html to a backup folder I guess. But I have this coding philosophy even in my .Bat files to make them independent of other files (as much as possible), as self-contained as they can be.

Also it would use fewer steps. But I don't want to overburden you with this. You already were very useful :-)


> It is just that I don't exactly understand what you envision.

Going to the relevant page with just one click, meaning, when I open the 'album preview' link from my RSS feed and the browser opens the 1st link shortener, I then click on the bookmarklet, which will take the URL, decode it, and open the final result in the browser.

Better yet would be if I could just drag and drop that 'album preview' link in my feed directly on top of the bookmarklet which would then decode it and open it automatically, but I don't know if that's even possible.
 
> Please do not toppost, 
> do sparce interpost without quoting signatures on Usenet.

Ok sorry, the times I posted in google groups could be counted with the fingers of one hand, with many to spare :P I don't know the 'etiquette'

[toc] | [prev] | [next] | [standalone]


#30928

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-07-20 09:39 +0200
Message-ID<XnsA64B625527832eejj99@194.109.6.166>
In reply to#30917
arpegiateur@gmail.com wrote on 19 Jul 2016 in comp.lang.javascript:

>> Please do not toppost, 
>> do sparce interpost without quoting signatures on Usenet.
> 
> Ok sorry, the times I posted in google groups could be counted with the
> fingers of one hand, with many to spare :P I don't know the 'etiquette' 

This NG is NOT a Google-group but a Usenet group, and even predates Google 
by decennia. Usenet even predates the World-Wide-Web by over a decennium.

Google may well be devoid of any etiquette, 
but Usenet "Netiquette" is something else.

Seems you are using a Google-groups server as a web-newsreader into Usenet,
without realizing its hidden, and therefore quite dirty, potential.

>> What is a "shortened page", is there no html in it?
> 
> That entire link in my 1st post here is the shortener page, the first of 
two. It's the page that makes you wait before it opens the link I want. 
> 
> 
>> How do you want to get the information to your bookmarklet?
> 
> For instance like a bookmarklet I have here called 'Translate page' 

Where? Should I register for that to log in?
That is something we usenetters are very reluctant to do.

> that takes the URL, puts it into Google translator and translates
> the entire page. In essence, it takes the URL and processes it.

Well, you can take the essence of my javascript code, and use it as you 
like, it seems you are the bookmarklet specialist here ;-)

var source = '....';
var result = decodeURIComponent(source.replace(/^.*(http)/,'$1'));

this code throws away everything before the last 'http' [or "https" for that 
matter] and decodes the resulting string.

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#30952

Fromarpegiateur@gmail.com
Date2016-07-20 10:09 -0700
Message-ID<a52bb885-677d-45c2-b6d7-6d724603ec02@googlegroups.com>
In reply to#30928
On Wednesday, July 20, 2016 at 8:40:04 AM UTC+1, Evertjan. wrote:
> 
> This NG is NOT a Google-group but a Usenet group, and even predates Google 
> by decennia. Usenet even predates the World-Wide-Web by over a decennium.
> 
> Google may well be devoid of any etiquette, 
> but Usenet "Netiquette" is something else.
> 
> Seems you are using a Google-groups server as a web-newsreader into Usenet,
> without realizing its hidden, and therefore quite dirty, potential.

Ok, it says Google Groups in this left panel, but I guess is just a front end then. But I find it easier to search for topics like these, although I hate that it doesn't let me edit a post once I send it.
What dirty potential are you talking about? The data that google gathers?


> Where? Should I register for that to log in?
> That is something we usenetters are very reluctant to do.

The translate bookmarklet:

javascript:var%20t=((window.getSelection&&window.getSelection())||(document.getSelection&&document.getSelection())||(document.selection%20&&document.selection.createRange&&document.selection.createRange().text));var%20e=(document.charset||document.characterSet);if(t!=''){location.href='http://translate.google.com/translate_t?text='+t+'&hl=en&tbb=1&ie='+e;}else{location.href='http://translate.google.com/translate?u='+escape(location.href)+'&hl=en&tbb=1&ie='+e;};

...it will translate any non-english webpage into english, just put that code into a new bookmark, open the page you want to translate, click that bookmark, and presto you'll have that page in english,  with *no google login required*, don't worry :). 
It works with private browser sessions too. I hope you find it useful.


> Well, you can take the essence of my javascript code, and use it as you 
> like, it seems you are the bookmarklet specialist here ;-)
> 
> var source = '....';
> var result = decodeURIComponent(source.replace(/^.*(http)/,'$1'));
> 
> this code throws away everything before the last 'http' [or "https" for that 
> matter] and decodes the resulting string.


'Specialist' only in knowing their usefullness :D
All right, I'll try your last code suggestion.
Thank you for your work so far, it already helped a lot :)

[toc] | [prev] | [next] | [standalone]


#30955

FromOsmo Saarikumpu <osmo@weppipakki.com>
Date2016-07-21 16:21 +0300
Message-ID<nmqi7t$8ul$1@dont-email.me>
In reply to#30952
On 20/07/2016 20:09, arpegiateur@gmail.com wrote:
> On Wednesday, July 20, 2016 at 8:40:04 AM UTC+1, Evertjan. wrote:
>> Well, you can take the essence of my javascript code, and use it as you
>> like, it seems you are the bookmarklet specialist here ;-)
>>
>> var source = '....';
>> var result = decodeURIComponent(source.replace(/^.*(http)/,'$1'));
> All right, I'll try your last code suggestion.

Here is a proposal for the bookmarklet:

javascript:(function () 
{location.assign(decodeURIComponent(location.href.replace(/^.*(http)/,'$1')))})()

-- 
Best wishes, Osmo

[toc] | [prev] | [next] | [standalone]


#30957

FromOsmo Saarikumpu <osmo@weppipakki.com>
Date2016-07-21 16:36 +0300
Message-ID<nmqj40$bba$1@dont-email.me>
In reply to#30955
On 21/07/2016 16:21, Osmo Saarikumpu wrote:
> Here is a proposal for the bookmarklet:
>
> javascript:(function ()
> {location.assign(decodeURIComponent(location.href.replace(/^.*(http)/,'$1')))})()

On second thought:

location.assign(decodeURIComponent(location.href.replace(/^.*(http)/,'$1'))) 


should be sufficient for this one.

-- 
Best wishes, Osmo

[toc] | [prev] | [next] | [standalone]


#30961

Fromarpegiateur@gmail.com
Date2016-07-22 12:19 -0700
Message-ID<a24b5bf3-1345-443a-8214-f80f921ae899@googlegroups.com>
In reply to#30957
Osmo, both work wonderfully, thank you : )

I was trying to do that with this feeble attempts:

javascript:var source=location.href;var result=decodeURIComponent(source.replace(/^.*(http)/,'$1'));

javascript:(function decode(t){location.href=decodeURIComponent(t.value.replace(/^.*(http)/,'$1'));}); 

javascript:location.href=decodeURIComponent(t.value.replace(/^.*(http)/,'$1')); 


...but I always got nothing (remember I don't know squat about javascript)

But yours do work. I chose the latter, simpler one, as a good programing practice.

I can process the cr@p out of text strings with DOS batch commands, but in javascript I can't even print a 'Hello World'. Well I can if I google it and copy paste it :P

Anyway thanks again to you and Evertjan, you both were very helpful.

 



On Thursday, July 21, 2016 at 2:36:05 PM UTC+1, Osmo Saarikumpu wrote:
> On 21/07/2016 16:21, Osmo Saarikumpu wrote:
> > Here is a proposal for the bookmarklet:
> >
> > javascript:(function ()
> > {location.assign(decodeURIComponent(location.href.replace(/^.*(http)/,'$1')))})()
> 
> On second thought:
> 
> location.assign(decodeURIComponent(location.href.replace(/^.*(http)/,'$1'))) 
> 
> 
> should be sufficient for this one.
> 
> -- 
> Best wishes, Osmo

[toc] | [prev] | [next] | [standalone]


#30962

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-07-22 23:20 +0200
Message-ID<XnsA64DED5FCE72Beejj99@194.109.6.166>
In reply to#30961
arpegiateur@gmail.com wrote on 22 Jul 2016 in comp.lang.javascript:

> I was trying to do that with this feeble attempts:
> 
> javascript:var source=location.href;var
> result=decodeURIComponent(source.replace(/^.*(http)/,'$1')); 

So you do nothing with the 'result' variable.

> javascript:(function
> decode(t){location.href=decodeURIComponent(t.value.replace(/^.*(http)/,'$
> 1'));}); 

So you do not call the function, so it cannot execute.

> javascript:location.href=decodeURIComponent(t.value.replace(/^.*(http)/,'
> $1')); 

Indeed, but to understand it, please first look at this one:

javascript:location.href='http://cnn.com/';

or even better use the console [F12] and there enter:

location.href='http://cnn.com/';



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#30963

Fromarpegiateur@gmail.com
Date2016-07-22 18:13 -0700
Message-ID<93e6c052-f2bc-445a-9bb6-23795cd70610@googlegroups.com>
In reply to#30962
On Friday, July 22, 2016 at 10:20:56 PM UTC+1, Evertjan. wrote:
> 
> So you do nothing with the 'result' variable.
> 
> > javascript:(function
> > decode(t){location.href=decodeURIComponent(t.value.replace(/^.*(http)/,'$
> > 1'));}); 
> 
> So you do not call the function, so it cannot execute.
> 
> > javascript:location.href=decodeURIComponent(t.value.replace(/^.*(http)/,'
> > $1')); 
> 

I may have tried this one too:
   javascript:decodeURIComponent(location.href.replace(/^.*(http)/,'$1'));

 ... which is probably wrong with the wrong syntax, but with the right idea.

To be honest I was just putting parts from other javascript bookmarklets into your code in 'unholly ways', mixing with some lightning and hoping in the end I could say "It's alive!" :P :D



> Indeed, but to understand it, please first look at this one:
> 
> javascript:location.href='http://cnn.com/';
> 
> or even better use the console [F12] and there enter:
> 
> location.href='http://cnn.com/';
> 
In the console it says that is about to exit the current page and go to CNN, after I authorize the copy-paste function in the console.

[toc] | [prev] | [next] | [standalone]


#30964

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-07-23 12:02 +0200
Message-ID<XnsA64E7A6F89A70eejj99@194.109.6.166>
In reply to#30963
arpegiateur@gmail.com wrote on 23 Jul 2016 in comp.lang.javascript:

> I may have tried this one too:
>    javascript:decodeURIComponent(location.href.replace(/^.*(http)/,'$1'))
>    ; 
> 
>  ... which is probably wrong with the wrong syntax, but with the right
>  idea. 

No, it is the wrong idea, because you modify a string but do nothing with 
the result, so in effect[!!], you did nothing.

it is:
1 copy present location.href into a string
2 skip the front of the string
3 decode the result

while you should do:
1 copy present location.href into a string
2 skip the front of the string
3 decode the result
4 paste the result as new location.href

> To be honest I was just putting parts from other javascript bookmarklets
> into your code in 'unholly ways', mixing with some lightning and hoping
> in the end I could say "It's alive!" :P :D

Well this is just as silly as thinking faith incantations have an effect 
upon the real world. 

Programming with an effect needs some knowledge of the language, logical 
thinking and of the programming environment: js-engine and DOM, for instance 
in thre case of a browser.

So start off with pseudocode of what you want, like the bove 1 2 3 4,
and then repeat your coding and logical thinking sequence ad nauseam.

Ad some debugging, by using the console [f12]
or inserting temporary alert(); -s.

1 copy present location.href into a string
 1a console.log(aString);
2 skip the front of the string
 2a console.log(aString);
3 decode the resulting string
 3a console.log(aString);
 3b alert('Now look at the console, please.');
4 paste this result as new location.href


You will get results in knowledge, experience and coding. Not buy pasting 
code from the web without adding your growing own logic and understanding.



-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#30974

Fromarpegiateur@gmail.com
Date2016-07-26 11:49 -0700
Message-ID<43f0b77c-7269-4814-81d8-75475178b659@googlegroups.com>
In reply to#30964
On Saturday, July 23, 2016 at 11:02:30 AM UTC+1, Evertjan. wrote:
> 
> 
> while you should do:
> 1 copy present location.href into a string
> 2 skip the front of the string
> 3 decode the result
> 4 paste the result as new location.href

I thought I was doing the 4th one


> Well this is just as silly as thinking faith incantations have an effect 
> upon the real world. 
> 
> Programming with an effect needs some knowledge of the language, logical 
> thinking and of the programming environment: js-engine and DOM, for instance 
> in thre case of a browser.
> 
>(...)

> You will get results in knowledge, experience and coding. Not buy pasting 
> code from the web without adding your growing own logic and understanding.

That was a metaphor, of course I wasn't randomly pasting pieces of code mindlessly (only the results felt that way), I went for the other bookmarklets I have here that take the URL, do something with it and navigate to the new URL, and through them I tried to get a glimpse of what I should do. Surely the opening of the URL should be common to all of them, but they weren't (several ways to skin a cat) and I was trying one or the other, with no results, from nothing happening whatsoever, to some errors here and there.

[toc] | [prev] | [next] | [standalone]


#30975

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-07-27 00:20 +0200
Message-ID<XnsA6523669C512eejj99@194.109.6.166>
In reply to#30974
arpegiateur@gmail.com wrote on 26 Jul 2016 in comp.lang.javascript:

> On Saturday, July 23, 2016 at 11:02:30 AM UTC+1, Evertjan. wrote:
>> 
>> 
>> while you should do:
>> 1 copy present location.href into a string
>> 2 skip the front of the string
>> 3 decode the result
>> 4 paste the result as new location.href
> 
> I thought I was doing the 4th one

How?

You skipped the code you are talking about!

Perhaps you misinterpreted the regex replace(),
that RETURNS the result and does NOT change the source, 
and THEN you still have to do something with it.


>> You will get results in knowledge, experience and coding. Not buy
>> pasting 
>  
>> code from the web without adding your growing own logic and
>> understanding 
> .
> 
> That was a metaphor, of course I wasn't randomly pasting pieces of code

How could I mindlessly have thought you ment what you said?

> mindlessly (only the results felt that way), I went for the other
> bookmarklets I have here that take the URL, do something with it and
> navigate to the new URL, and through them I tried to get a glimpse of
> what I should do. Surely the opening of the URL should be common to all
> of them, but they weren't (several ways to skin a cat) and I was trying
> one or the other, with no results, from nothing happening whatsoever, to
> some errors here and there. 

Javascript code engines do not interprete metaphors.

;-)

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#30992

Fromarpegiateur@gmail.com
Date2016-07-28 08:07 -0700
Message-ID<700db71a-128a-4c83-922c-a874d9b1ef54@googlegroups.com>
In reply to#30975
On Tuesday, July 26, 2016 at 11:20:56 PM UTC+1, Evertjan. wrote:

> You skipped the code you are talking about!
> 
> Perhaps you misinterpreted the regex replace(),
> that RETURNS the result and does NOT change the source, 
> and THEN you still have to do something with it.
> 

Perhaps. I deleted those drafts so I don't know for sure.

> 
> Javascript code engines do not interprete metaphors.
> 
> ;-)

The metaphor was applied in the way I described it to you, not the actual way I tried to make that work

;-)

[toc] | [prev] | [next] | [standalone]


#30993

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-07-28 19:24 +0200
Message-ID<XnsA653C57531EECeejj99@194.109.6.166>
In reply to#30992
arpegiateur@gmail.com wrote on 28 Jul 2016 in comp.lang.javascript:

> On Tuesday, July 26, 2016 at 11:20:56 PM UTC+1, Evertjan. wrote:
> 
>> You skipped the code you are talking about!
>> 
>> Perhaps you misinterpreted the regex replace(),
>> that RETURNS the result and does NOT change the source, 
>> and THEN you still have to do something with it.
> 
> Perhaps. I deleted those drafts so I don't know for sure.

Well, you sent it to Usenet, did you delete it from usenet?

>> Javascript code engines do not interprete metaphors.
>> 
>> ;-)
> 
> The metaphor was applied in the way I described it to you, not the
> actual way I tried to make that work 
> 
> ;-)

>>>> How to replace strings in a URL with a javascript boormarklet?

But your OQ, was "boormarklet" a metaphor too?
Could it be that you were on the wrong track?

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#30994

Fromarpegiateur@gmail.com
Date2016-07-28 14:44 -0700
Message-ID<253d0c26-b9b4-4f04-9a30-5a8692d82514@googlegroups.com>
In reply to#30993
On Thursday, July 28, 2016 at 6:24:43 PM UTC+1, Evertjan. wrote:
> 
> Well, you sent it to Usenet, did you delete it from usenet?
> 
The bits I showed here were just a sample, I had many more.

> 
> But your OQ, was "boormarklet" a metaphor too?
> Could it be that you were on the wrong track?
> 

Of course not. I thought you knew what a bookmarklet was:
« A bookmarklet is a bookmark stored in a web browser that contains JavaScript commands that add new features to the browser.»
 (https://en.wikipedia.org/wiki/Bookmarklet)

[toc] | [prev] | [next] | [standalone]


#30995

From"Evertjan." <exxjxw.hannivoort@inter.nl.net>
Date2016-07-29 00:29 +0200
Message-ID<XnsA6545012264Deejj99@194.109.6.166>
In reply to#30994
arpegiateur@gmail.com wrote on 28 Jul 2016 in comp.lang.javascript:

> On Thursday, July 28, 2016 at 6:24:43 PM UTC+1, Evertjan. wrote:
>> 
>> Well, you sent it to Usenet, did you delete it from usenet?
>> 
> The bits I showed here were just a sample, I had many more.

But you introduced code whereon I responded.

You asked a Q about that.

>> But your OQ, was "boormarklet" a metaphor too?
>> Could it be that you were on the wrong track?
> 
> Of course not.

Why "of course"?? I don't think I sould presume 
my correspondents are never mistaken.

> I thought you knew what a bookmarklet was:

Presuming on what others know on Usenet 
is not a good way to ask Qs.

> « A bookmarklet is a bookmark stored in a web browser that contains
> JavaScript commands that add new features to the browser.» 
>  (https://en.wikipedia.org/wiki/Bookmarklet)

Wow! So if the feature is not new, it is not a bookmarklet?

Seems you do not enjoy being taken for a ride.


-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

[toc] | [prev] | [next] | [standalone]


#30996

Fromarpegiateur@gmail.com
Date2016-07-30 07:53 -0700
Message-ID<163c8c94-bb21-4690-9643-f0ab6c468089@googlegroups.com>
In reply to#30995
On Thursday, July 28, 2016 at 11:30:07 PM UTC+1, Evertjan. wrote:

> 
> But you introduced code whereon I responded.
> 
> You asked a Q about that.

Yes, I know, and I thanked you for your suggestions.
> 
> >> But your OQ, was "boormarklet" a metaphor too?
> >> Could it be that you were on the wrong track?
> > 
> > Of course not.
> 
> Why "of course"?? I don't think I sould presume 
> my correspondents are never mistaken.
> 
> (...)
> 
> Presuming on what others know on Usenet 
> is not a good way to ask Qs.
>
> (...) 
> Wow! So if the feature is not new, it is not a bookmarklet?
> 
> Seems you do not enjoy being taken for a ride.
> 
> 
What isn't a good way? and "a feature is not new"?
I think something has been lost in translation 1 or 2 posts back and it's compounding now, because to be honest I don't have the slightest idea of what you're talking about now.

You gave me helpful suggestions, Osmo implemented those in the pratical way I wanted, I thanked you both, let's keep it as that.
Cheers.

[toc] | [prev] | [next] | [standalone]


Page 1 of 2  [1] 2  Next page →

Back to top | Article view | comp.lang.javascript


csiph-web