1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-19 12:47:59 +01:00

Add plugins.

This commit is contained in:
Kris Maglione
2015-12-20 03:49:29 -08:00
parent f85f3df612
commit 5bb2e31150
9 changed files with 3210 additions and 0 deletions

51
plugins/curl.js Executable file
View File

@@ -0,0 +1,51 @@
"use strict";
var INFO =
["plugin", { name: "curl",
version: "0.3",
href: "http://dactyl.sf.net/pentadactyl/plugins#curl-plugin",
summary: "Curl command-line generator",
xmlns: "dactyl" },
["author", { email: "maglione.k@gmail.com" },
"Kris Maglione"],
["license", { href: "http://opensource.org/licenses/mit-license.php" },
"MIT"],
["project", { name: "Pentadactyl", "min-version": "1.0" }],
["p", {},
"This plugin provides a means to generate a ", ["tt", {}, "curl(1)"], " ",
"command-line from the data in a given form."],
["item", {},
["tags", {}, ";C"],
["strut"],
["spec", {}, ";C"],
["description", {},
["p", {},
"Generates a curl command-line from the data in the selected form. ",
"The command includes the data from each form element, along with ",
"the current User-Agent string and the cookies for the current ",
"page."]]]];
hints.addMode('C', "Generate curl command for a form", function(elem) {
if (elem.form)
var { url, postData, elements } = DOM(elem).formData;
else
var url = elem.getAttribute("href");
if (!url || /^javascript:/.test(url))
return;
url = util.newURI(url, null,
elem.ownerDocument.documentURIObject).spec;
let { shellEscape } = util.closure;
dactyl.clipboardWrite(["curl"].concat(
[].concat(
[["--form-string", shellEscape(datum)] for (datum of (elements || []))],
postData != null && !elements.length ? [["-d", shellEscape("")]] : [],
[["-H", shellEscape("Cookie: " + elem.ownerDocument.cookie)],
["-A", shellEscape(navigator.userAgent)],
[shellEscape(url)]]
).map(function(e) e.join(" ")).join(" \\\n ")).join(" "), true);
});
/* vim:se sts=4 sw=4 et: */