Skip to content

Instantly share code, notes, and snippets.

@hghwng
Created February 23, 2016 01:22
Show Gist options
  • Save hghwng/ea8634e7337adc994153 to your computer and use it in GitHub Desktop.
Save hghwng/ea8634e7337adc994153 to your computer and use it in GitHub Desktop.
Add page to Pocket in Pentadactyl.
"" Pocket
map a :pocket<CR>
js <<EOF
group.commands.add(["pocket"],
"Add to Pocket",
function(args) {
let url = args.length === 0 ? buffer.uri.spec : args[0];
let title = args["-title"] || "undefined";
window.pktApi.addLink(url, {
title: title,
success: function(response) {
dactyl.echomsg("Added to Pocket: " + response.item.normal_url);
},
error: function(response) {
dactyl.echoerr("Failed to add to Pocket: " + response.message);
},
})
}, {
argCount: "?",
completer: function (context, args) {
context.title = ["Page URL"];
let frames = buffer.allFrames();
context.completions = [
[win.document.documentURI, frames.length == 1 ? /*L*/"Current Location" : /*L*/"Frame: " + win.document.title]
for (win of frames)];
return;
},
options: [{
names: ["-title", "-t"],
description: "Page title",
completer: function title(context, args) {
let frames = buffer.allFrames();
return [[win.document.title, frames.length == 1 ? /*L*/"Current Location" : /*L*/"Frame: " + win.location.href]
for (win of frames)];
},
type: CommandOption.STRING
}]
});
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment