+ g_free(cookiefile);
+ g_free(scriptfile);
+ g_free(stylefile);
+}
+
+void
+runscript(WebKitWebFrame *frame, JSContextRef js) {
+ JSStringRef jsscript;
+ char *script;
+ JSValueRef exception = NULL;
+ GError *error;
+
+ if(g_file_get_contents(scriptfile, &script, NULL, &error)) {
+ jsscript = JSStringCreateWithUTF8CString(script);
+ JSEvaluateScript(js, jsscript, JSContextGetGlobalObject(js), NULL, 0, &exception);
+ }
+}
+
+void
+clipboard(Client *c, const Arg *arg) {
+ gboolean paste = *(gboolean *)arg;
+
+ if(paste)
+ gtk_clipboard_request_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), pasteuri, c);
+ else
+ gtk_clipboard_set_text(gtk_clipboard_get(GDK_SELECTION_PRIMARY), c->linkhover ? c->linkhover : geturi(c), -1);
+}
+
+char *
+copystr(char **str, const char *src) {
+ char *tmp;
+ tmp = g_strdup(src);
+
+ if(str && *str) {
+ g_free(*str);
+ *str = tmp;
+ }
+ return tmp;
+}
+
+WebKitWebView *
+createwindow(WebKitWebView *v, WebKitWebFrame *f, Client *c) {
+ Client *n = newclient();
+ return n->view;
+}
+
+gboolean
+decidedownload(WebKitWebView *v, WebKitWebFrame *f, WebKitNetworkRequest *r, gchar *m, WebKitWebPolicyDecision *p, Client *c) {
+ if(!webkit_web_view_can_show_mime_type(v, m)) {
+ webkit_web_policy_decision_download(p);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+gboolean
+decidewindow(WebKitWebView *view, WebKitWebFrame *f, WebKitNetworkRequest *r, WebKitWebNavigationAction *n, WebKitWebPolicyDecision *p, Client *c) {
+ Arg arg;
+
+ if(webkit_web_navigation_action_get_reason(n) == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) {
+ webkit_web_policy_decision_ignore(p);
+ arg.v = (void *)webkit_network_request_get_uri(r);
+ newwindow(NULL, &arg);
+ return TRUE;
+ }
+ return FALSE;