javascript - Encoding and decoding within bookmarklet -


i want create bookmarklet lengtens shorte.st links using website.

example link: http://sh.st/**abcde** has turned

http://longurl.org/expand?url=http%3a%2f%2fsh.st%2**abcde** 

i created following code:

javascript:(function(){var str = window.location.tostring();var str1 = str.substring(13,18);var str2 = "http://longurl.org/expand?url=http%3a%2f%2fsh.st%";var str3 =str2.concat(str1);alert(str3);window.location=str3;})(); 

code bad, know, i've never written in javascript before. works. except 1 thing: % in bookmarklet decoded /. , dont want happen. guess somewere along way supposed encode string, i'm not sure. appreciated.


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -