alphapapa / org-web-tools

View, capture, and archive Web pages in Org-mode
GNU General Public License v3.0
647 stars 33 forks source link

Feature: Use browser cookies file #28

Open codygman opened 5 years ago

codygman commented 5 years ago

Edit: This might be out of scope for this package and instead the place of some sync browser with url-cookies-file type package that runs on the idle timer. Maybe not though and I'm sure others have had this need that use org-web-tools before.

I link to private github repositories and would like to have the title of the page hidden unless logged in rather than link text of "Page not found - Github".

I plan on trying to implement this at some point, but want to leave the idea here in case I don't get to it, someone wants to pick it up immediately, or there are ideas about how to implement it.

After a little research we can do the following for firefox:

Then url-retrieve-syncronously and by extension org-web-tools-insert-link-for-url can access anything you've logged into with firefox!

codygman commented 5 years ago

I also just realized this would solve that problem for the other org-web-tools features as well.

alphapapa commented 5 years ago

This would be a little complicated to implement, especially considering that it would probably need to support at least 4 browsers: w3m, eww, Chrom(e|ium), and Firefox. I'm not interested in working on it myself, but I'd be willing to consider well-written patches.

You could probably implement a prototype by wrapping the appropriate functions from this package in your own functions and binding url-cookies-file in them.

stefan2904 commented 1 year ago

An alternative could be to do this externally and create a suitable file, which is then used in url-cookies-file. I know that you probably don't like to do stuff outside of emacs, though. ;-)

What comes to my mind is using stuff like the browser_cookie3 python package, which has support for some browsers (not w3m and eww, though).

stefan2904 commented 1 year ago

the format of url-cookie-file is apparently either elisp or "Netscape/Mozilla format" (the latter appears to be unused).

;; A cookie is stored internally as a vector of 7 slots
;; [ url-cookie NAME VALUE EXPIRES LOCALPART DOMAIN SECURE ]
stefan2904 commented 1 year ago

I did a quick implementation of this idea, and it works for my use cases.

Here is the python script. Below I also mention the small modification to org-web-tools that is currently required: https://gist.github.com/stefan2904/b1a4b21656f2c3b44ab598e652d7cc1a