Create a Delicious Bookmarklet in Firefox Using the Delicious API

I want to create a Delicious shortcut in Firefox, which bookmarks the current page with a predefined tag.

To prove the concept, if I enter this url, it works:

https://john: pwd@api.del.icio.us /v1/posts/add?url=http://www.google.com& description=http://www.google.com&tags=testtag 

But this, like a bookmarklet, no, I get access:

 javascript:( function() { location.href = 'https://john: pwd@api.del.icio.us /v1/posts/add?url=' + encodeURIComponent(window.location.href) + '&description=' + encodeURIComponent(document.title) + '&tags=testtag'; } )() 

Is this possible with the javascript bookmark?

Update: I tried this, but still got an access denied error, so it has something to do with Javascript / Firefox.

 javascript:( function() { location.href = 'https://john: pwd@api.del.icio.us /v1/posts/add?url=' + 'http://www.google.com' + '&description=' + 'http://www.google.com' + '&tags=testtag'; } )() 

Update 2: Having tried many of the options above in different browsers, I still can’t get past the message about access denied, so I offer a reward.

+4
source share
2 answers

I suspect Firefox is trying to protect you from security issues when running Javascript. When I tried to enter text in my example into my address bar, Firefox asked me to ask if I was sure that I want to enter api.del.icio.us

This other question regarding HTTP auth is similar to your question, maybe it will help you.


Update:

I used the Firebug Net panel and its Javascript console, and I was able to see the request / response headers.

Here is a request from the Javascript console that DOES NOT WIN:

 GET /v1/posts/add?url=http://www.spoons.com/&description=forks&tags=knives HTTP/1.1 Host: api.del.icio.us User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive Referer: https://stackoverflow.com/questions/2708950/2740195 Authorization: Basic XXXXXXXXXXXXXXXXX Cache-Control: max-age=0 

And here is the query from the address bar, which is WORKED:

 GET /v1/posts/add?url=http://www.spoons.com/&description=forks&tags=knives HTTP/1.1 Host: api.del.icio.us User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 115 Connection: keep-alive Authorization: Basic XXXXXXXXXXXXXXXXX Cache-Control: max-age=0 

The only difference is the Referer header, which caused access denial. Setting network.http.sendRefererHeader in Firefox about.config can be set to 0, which disables the Referer header. When I tried this, then the Javascript console method started working.

There is a Firefox extension called refspoof , which is useful for sending your own custom referer headers, maybe this can help here.

+2
source

It looks like you are missing url= .

+1
source

Source: https://habr.com/ru/post/1307946/


All Articles