From e9bbc58fe1b54567738bc2720cd0332feb9ff3e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Mon, 30 Sep 2019 11:20:52 +0200 Subject: Add surf-pass to access user names and passwords from surf --- surf.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'surf.c') diff --git a/surf.c b/surf.c index f553239..8a1f3d7 100644 --- a/surf.c +++ b/surf.c @@ -35,7 +35,7 @@ #define LENGTH(x) (sizeof(x) / sizeof(x[0])) #define CLEANMASK(mask) (mask & (MODKEY|GDK_SHIFT_MASK)) -enum { AtomFind, AtomGo, AtomUri, AtomLast }; +enum { AtomFind, AtomGo, AtomUri, AtomActiveValue, AtomLast }; enum { OnDoc = WEBKIT_HIT_TEST_RESULT_CONTEXT_DOCUMENT, @@ -173,6 +173,7 @@ static void handleplumb(Client *c, const char *uri); static void newwindow(Client *c, const Arg *a, int noembed); static void spawn(Client *c, const Arg *a); static void msgext(Client *c, char type, const Arg *a); +static void activeval(Client *c, const Arg *a); static void destroyclient(Client *c); static void cleanup(void); @@ -328,6 +329,7 @@ setup(void) atoms[AtomFind] = XInternAtom(dpy, "_SURF_FIND", False); atoms[AtomGo] = XInternAtom(dpy, "_SURF_GO", False); atoms[AtomUri] = XInternAtom(dpy, "_SURF_URI", False); + atoms[AtomActiveValue] = XInternAtom(dpy, "_SURF_ACTIVE_VALUE", False); gtk_init(NULL, NULL); @@ -1048,6 +1050,14 @@ spawn(Client *c, const Arg *a) } } +void +activeval(Client *c, const Arg *a) +{ + const char *value = a->v; + + evalscript(c, "document.activeElement.value = '%s';", value); +} + void destroyclient(Client *c) { @@ -1316,6 +1326,12 @@ processx(GdkXEvent *e, GdkEvent *event, gpointer d) a.v = getatom(c, AtomGo); loaduri(c, &a); + return GDK_FILTER_REMOVE; + } else if (ev->atom == atoms[AtomActiveValue]) { + a.v = getatom(c, AtomActiveValue); + if (*(char*)a.v != '\0') + activeval(c, &a); + return GDK_FILTER_REMOVE; } } -- cgit v1.2.3