Create a ShortCut/BookMark in Chrome to the Links Shortener using Javascript


I have created a link shortener which can be found at this URL: https://rot47.net/_url/ and to create a link, use the form in this URL: https://rot47.net/_url/add.php

To help users putting the link into the editbox, you can give a parameter to the Link, so for example,

https://rot47.net/_url/add.php?p=https://helloacm.com

So, we can create a link and place it in the HTML page.

<a rel="nofollow" href="javascript:(function(w,d){var u=d.location.href;w.open('https://rot47.net/_url/add.php?p='+encodeURIComponent(u))}(window,document));" target="_blank">Drag or BookMark This Utility Link!</a>

So, the good thing about this is that it tells users that the link can be actually bookmarked or dragged to the bookmark bar (under URL bar in Chrome). If you right click the link and choose [edit], you will see this popup.

bookmark-javascript-shorten-link Create a ShortCut/BookMark in Chrome to the Links Shortener using Javascript implementation javascript web programming

bookmark-javascript-shorten-link

So, next time, when you want to shorten a long URL and share it, you can directly click the bookmarked button in your browser, which is a lot faster.

The Javascript, if tidy up, is as follows:

1
2
3
4
(function(w, d) {
  var u = d.location.href;
  w.open('https://rot47.net/_url/add.php?p=' + encodeURIComponent(u))
}(window, document));
(function(w, d) {
  var u = d.location.href;
  w.open('https://rot47.net/_url/add.php?p=' + encodeURIComponent(u))
}(window, document));

It is rather self-explanatory. Two global objects, window and document are passed into the anonymous function. Then the new window is popup and redirected to the requested URL with parameter.

–EOF (The Ultimate Computing & Technology Blog) —

GD Star Rating
loading...
373 words
Last Post: Batch Script: Return Value Via ErrorLevel Code from Sub Function or Script
Next Post: Powershell Tutorial - Create COM object

The Permanent URL is: Create a ShortCut/BookMark in Chrome to the Links Shortener using Javascript

Leave a Reply