WebKitHitTestResult *, gpointer);
static gboolean quit_if_nothing_active(void);
static gboolean remote_msg(GIOChannel *, GIOCondition, gpointer);
+static void run_user_scripts(WebKitWebView *);
static void search(gpointer, gint);
static void show_web_view(WebKitWebView *, gpointer);
static Window tabbed_launch(void);
webkit_web_view_run_javascript(WEBKIT_WEB_VIEW(c->web_view),
grab_feeds, NULL,
grab_feeds_finished, c);
+
+ run_user_scripts(WEBKIT_WEB_VIEW(c->web_view));
}
gtk_entry_set_progress_fraction(GTK_ENTRY(c->location), p);
}
return TRUE;
}
+void
+run_user_scripts(WebKitWebView *web_view)
+{
+ gchar *base = NULL, *path = NULL, *contents = NULL;
+ const gchar *entry = NULL;
+ GDir *scriptdir = NULL;
+
+ base = g_build_filename(g_get_user_config_dir(), __NAME__, "scripts", NULL);
+ scriptdir = g_dir_open(base, 0, NULL);
+ if (scriptdir != NULL)
+ {
+ while ((entry = g_dir_read_name(scriptdir)) != NULL)
+ {
+ path = g_build_filename(base, entry, NULL);
+ if (g_str_has_suffix(path, ".js"))
+ {
+ if (g_file_get_contents(path, &contents, NULL, NULL))
+ {
+ webkit_web_view_run_javascript(web_view, contents, NULL, NULL, NULL);
+ g_free(contents);
+ }
+ }
+ g_free(path);
+ }
+ g_dir_close(scriptdir);
+ }
+
+ g_free(base);
+}
+
void
search(gpointer data, gint direction)
{
.P
Lines starting with \fB#\fP are ignored.
.\" --------------------------------------------------------------------
+.SH "USER-SUPPLIED JAVASCRIPT FILES"
+After a page has been successfully loaded, the directory
+\fI~/.config\:/lariza\:/scripts\fP will be scanned and each file in it
+ending with \fB.js\fP will be run as a JavaScript file in the context of
+said page.
+.P
+During development, you will most likely want to run \fBlariza\fP with
+$\fBLARIZA_ENABLE_CONSOLE_TO_STDOUT\fP enabled.
+.\" --------------------------------------------------------------------
.SH "TRUSTED CERTIFICATES"
By default, \fBlariza\fP trusts whatever CAs are trusted by WebKit, i.e. by
your GnuTLS installation. If you wish to trust additional certificates,