1

I use Google Chrome and its developer tools like 'Inspect element' to check performance of my web pages. I know that its Developer tool 'Console' can be used to execute JavaScript.

I was just saving my one interested web page on my Delicious web account and I noticed that all that information it needs goes through JavaScript, So I just tried to put that code on my JS Console so that I can see the whole background process, but it failed. Can anyone please tell me how should I work with it, because I know this can be done.

The things I am seeing When I clicked the bookmark

The code you will need to save as your bookmark

javascript:(function(e,t)%7Bvar n=e.document;setTimeout(function()%7Bfunction a(e)%7Bif(e.data==="destroy_bookmarklet")%7Bvar r=n.getElementById(t);if(r)%7Bn.body.removeChild(r);r=null%7D%7D%7Dvar t="DELI_bookmarklet_iframe",r=n.getElementById(t);if(r)%7Breturn%7Dvar i="https://delicious.com/save?",s=n.createElement("iframe");s.id=t;s.src=i+"url="+encodeURIComponent(e.location.href)+"&title="+encodeURIComponent(n.title)+"&note="+encodeURIComponent(""+(e.getSelection?e.getSelection():n.getSelection?n.getSelection():n.selection.createRange().text))+"&v=1.1";s.style.position="fixed";s.style.top="0";s.style.left="0";s.style.height="100%25";s.style.width="100%25";s.style.zIndex="16777270";s.style.border="none";s.style.visibility="hidden";s.onload=function(){this.style.visibility="visible"};n.body.appendChild(s);var o=e.addEventListener?"addEventListener":"attachEvent";var u=o=="attachEvent"?"onmessage":"message";e[o](u,a,false)},1)})(window)

Details: I've an account on delicious.com which provides me a service to save my interested web links. for example If I am visiting a Stackoverflow question page and I like the question I just need to click on the bookmark(I've provided you the URL above), I am wondering how it fetches its parent page and saves it in their database, How it can be done using just javascript, I always noticed bookmarks with only web addresses but this one contains javascript code, Can anyone please tell me how it works, Thanks

1 Answer 1

1

What you tried to execute is a JavaScript pseudo-scheme. Note the javascript: part at the beginning. Doesn't it sound familiar with other schemes like http:, https:, ftp:?

It would be executed in the URL, not in the Console. In other words, you use JavaScript pseudo-scheme to execute a piece of JavaScript code, in the address bar of the browser.

To execute it in Console, you have to do two things:

  1. Remove javascript: scheme
  2. Because it's supposed to be executed in the URL, it's URL encoded. You have to decode it first. See that %7B? It represents {. Console won't recognize it, till it's decoded to the original character.
Sign up to request clarification or add additional context in comments.

1 Comment

Note that the javascript: isn't hurting anything in the console, because it's treated as a label (though it is totally unnecessary). The URL encoding, as you say, is definitely causing the breakage.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.