lusakasa / saka-key

A keyboard interface to the web
https://key.saka.io
MIT License
861 stars 70 forks source link

Bind JS scripts/bookmarklets? (for pocket integration) #45

Open cougarten opened 7 years ago

cougarten commented 7 years ago

Hi, looking at the structure of this wonderful plugin it seems trivial to add some custom js, but can you hint me at where to add it (without loosing it with updates etc) and how to bind it?

Simply triggering a bookmarklet-style js and bind it to a key would be great!

I want it to add pages to pocket via (contrary to their old bookmarklet, this undocumented url still works): javascript:(function(){window.open('https://getpocket.com/edit?url='+escape(window.location.href)', '_self');})

Additional things that would be nice:

Thank you so much for providing an alternative to the other keyboard-wizardry add-ons that are now becoming legacy. I thought I'd leave FF behind for good (and install your extention on chrome, hehe) and I'm so happy I can stay!

eejdoowad commented 7 years ago

Custom commands are tricky to implement because they involve so many different components of Saka Key including:

But your post inspired me, so I sketched out a proposal for custom commands in #28. I think it should meet your needs. This will be fun to implement, so it should be out by this weekend.

kevincox commented 7 years ago

Hi, what is holding this back? The next release of ff is looming so I can probably find some time to implement this feature. Is there any blocker, or just waiting on someone to put in the time?

eejdoowad commented 7 years ago

The main blocker is my lack of time as of late. The other blocker is that there are subtle issues you have to take care of when providing implementing custom commands.

  1. No JavaScript evaluation in the background page
  2. When to evaluate custom command JavaScript
  3. Where to evaluate custom command JavaScript
  4. How to make custom commands work across multiple frames of a page
  5. How to make hints mode accessible to custom commands
  6. How to store and propagate custom commands
  7. How to let users add custom commands using the options page

I can share a design that addresses many of these issues if you're interested in helping with the implementation. I've also made some baby steps toward the implementation myself.

kevincox commented 7 years ago

I'd appreciate what you have so far. I'm starting to read the code but I'm not too familar with webextensions or saka-key so it will take me a while to get hacking.

eejdoowad commented 7 years ago

Have a look at https://key.saka.io/dev_docs/

kevincox commented 7 years ago

Yup, I've been reading through those :)