Bookmarklets #23

Closed
wants to merge 5 commits into
from

Conversation

Projects
None yet
3 participants
@xconstruct
Contributor

xconstruct commented Jul 19, 2011

Hi!
I've added a bookmarklet module which works similar to quickmarks. You can add javascript snippets and execute them on a keypress.

Usage is currently:
:bml[et] token - Save selected link/text with javascript-URI as the token
:bml[et] token javascript-uri - Save specified javascript-URI as token
:bmlets - Bring up the menu of all bookmarklets
:delbml[et] token - Deletes a bookmarklet
gl[t] - Execute the selected bookmarklet 't'

Bookmarklets are saved in data_dir/bookmarklets/[token].js as pure JavaScript. I may introduce a description field, so you can identify the bookmarklets later on.
Tested it with wikipedia's bookmarklet and Google Translate.

@mason-larobina

This comment has been minimized.

Show comment
Hide comment
@mason-larobina

mason-larobina Jul 19, 2011

Member

Thanks, I'll take a look over the code tomorrow and get back to you.

Member

mason-larobina commented Jul 19, 2011

Thanks, I'll take a look over the code tomorrow and get back to you.

@mason-larobina

This comment has been minimized.

Show comment
Hide comment
@mason-larobina

mason-larobina Jul 22, 2011

Member

I feel this is a little to similar to quickmarks, would it be better if we found a better way of managing bookmarklets with quickmarks. For example I was thinking of having a following-mode for setting a quickmark and perhaps a following mode specifically for bookmarklets (which only hints javascript: uris). Then of-course giving the quickmarks lib javascript: handling code (or make a generic javascript: handler).

What do you think? I've only used a couple of bookmarklets when using firefox (readability & in-line images on reddit) so you'll have to let me know if there is some fundamental feature I'm missing.

Member

mason-larobina commented Jul 22, 2011

I feel this is a little to similar to quickmarks, would it be better if we found a better way of managing bookmarklets with quickmarks. For example I was thinking of having a following-mode for setting a quickmark and perhaps a following mode specifically for bookmarklets (which only hints javascript: uris). Then of-course giving the quickmarks lib javascript: handling code (or make a generic javascript: handler).

What do you think? I've only used a couple of bookmarklets when using firefox (readability & in-line images on reddit) so you'll have to let me know if there is some fundamental feature I'm missing.

@xconstruct

This comment has been minimized.

Show comment
Hide comment
@xconstruct

xconstruct Jul 22, 2011

Contributor

I agree with you, that's probably the better way - especially with the following mode. Didn't want to rewrite a whole module for my first experiments with luakit, but now I know a little bit more about the API (and the new following mode seems so much nicer!).

Do you want to give it a try or shall I?

Contributor

xconstruct commented Jul 22, 2011

I agree with you, that's probably the better way - especially with the following mode. Didn't want to rewrite a whole module for my first experiments with luakit, but now I know a little bit more about the API (and the new following mode seems so much nicer!).

Do you want to give it a try or shall I?

@mason-larobina

This comment has been minimized.

Show comment
Hide comment
@mason-larobina

mason-larobina Jul 22, 2011

Member

Actually @karottenreibe would be the person to ask because we would need some way of actually filtering each uri (which isn't possible in the current following lib).

Member

mason-larobina commented Jul 22, 2011

Actually @karottenreibe would be the person to ask because we would need some way of actually filtering each uri (which isn't possible in the current following lib).

@xconstruct

This comment has been minimized.

Show comment
Hide comment
@xconstruct

xconstruct Jul 23, 2011

Contributor

Couldn't resist to give it another try:

xconstruct/bmlets

This adds a generic javascript: handler by evalulating javascript-uris in w:navigate() and adds quickmark/bookmark following binds. So far, the quickmarks lib works without any changes at all.
I don't know if a separate following mode for bookmarklets would be necessary - I wouldn't need it and maybe it makes things just overly complicated.

Interesting how small the code gets in comparison to my initial bookmarklets-lib :p

Contributor

xconstruct commented Jul 23, 2011

Couldn't resist to give it another try:

xconstruct/bmlets

This adds a generic javascript: handler by evalulating javascript-uris in w:navigate() and adds quickmark/bookmark following binds. So far, the quickmarks lib works without any changes at all.
I don't know if a separate following mode for bookmarklets would be necessary - I wouldn't need it and maybe it makes things just overly complicated.

Interesting how small the code gets in comparison to my initial bookmarklets-lib :p

@karottenreibe

This comment has been minimized.

Show comment
Hide comment
@karottenreibe

karottenreibe Jul 25, 2011

Contributor

I agree, your new solution is much superior :-)
I don't see the use in a separate follow mode. If you need to just match links with javascript: URIs you can use CSS3's attribute selectors for that: http://www.w3.org/TR/css3-selectors/, e.g: a[href^=javascript:]

Contributor

karottenreibe commented Jul 25, 2011

I agree, your new solution is much superior :-)
I don't see the use in a separate follow mode. If you need to just match links with javascript: URIs you can use CSS3's attribute selectors for that: http://www.w3.org/TR/css3-selectors/, e.g: a[href^=javascript:]

@mason-larobina

This comment has been minimized.

Show comment
Hide comment
@mason-larobina

mason-larobina Jul 25, 2011

Member

Oh wow! nice one.

And thanks Constantin, I like this patch a lot more :) I'll merge it in tonight.

Member

mason-larobina commented Jul 25, 2011

Oh wow! nice one.

And thanks Constantin, I like this patch a lot more :) I'll merge it in tonight.

@mason-larobina

This comment has been minimized.

Show comment
Hide comment
@mason-larobina

mason-larobina Aug 13, 2011

Member

Ok, merged in your bmlets branch and modified the quickmark binding slightly (;M to ;M%w to match the original quickmark binding).

Thanks! (sorry it took a while, I've not done anything on luakit while I was preparing my luakit talk).

Member

mason-larobina commented Aug 13, 2011

Ok, merged in your bmlets branch and modified the quickmark binding slightly (;M to ;M%w to match the original quickmark binding).

Thanks! (sorry it took a while, I've not done anything on luakit while I was preparing my luakit talk).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment