Created
February 23, 2016 01:22
-
-
Save hghwng/ea8634e7337adc994153 to your computer and use it in GitHub Desktop.
Add page to Pocket in Pentadactyl.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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