.P
 Mandatory arguments to long options are mandatory for short options too.
 .TP
+.BI "\-C, \-\-cmd " "CMD"
+Run \fICMD\fP as ex command line right before the first page is loaded.
+If the flag is used more than one time, the commands are called in order they
+are given.
+You could also pass several ex commands in one \fICMD\fP,
+if they are separated by "|".
+.sp
+.EX
+vimb --cmd "set dark-mode=on|set header=Referer,DNT=1"
+.EE
+.TP
 .BI "\-c, \-\-config " "FILE"
 Use custom configuration given as \fIFILE\fP.
 This will also be applied on new spawned instances.
 
         WebKitJavascriptResult *res, gpointer data);
 static gboolean profileOptionArgFunc(const gchar *option_name,
         const gchar *value, gpointer data, GError **error);
+static gboolean autocmdOptionArgFunc(const gchar *option_name,
+        const gchar *value, gpointer data, GError **error);
 
 struct Vimb vb;
 
 #endif
         + (vb.incognito ? 1 : 0)
         + (vb.profile ? 2 : 0)
-        + (vb.no_maximize ? 1 : 0),
+        + (vb.no_maximize ? 1 : 0)
+        + g_slist_length(vb.cmdargs) * 2,
         sizeof(char *)
     );
 
     if (vb.no_maximize) {
         cmd[i++] = "--no-maximize";
     }
+    for (GSList *l = vb.cmdargs; l; l = l->next) {
+        cmd[i++] = "-C";
+        cmd[i++] = l->data;
+    }
     cmd[i++] = (char*)uri;
     cmd[i++] = NULL;
 
         }
     }
     g_free(vb.profile);
+
+    g_slist_free_full(vb.cmdargs, g_free);
 }
 #endif
 
     return TRUE;
 }
 
+static gboolean autocmdOptionArgFunc(const gchar *option_name,
+        const gchar *value, gpointer data, GError **error)
+{
+    vb.cmdargs = g_slist_append(vb.cmdargs, g_strdup(value));
+    return TRUE;
+}
+
 int main(int argc, char* argv[])
 {
     Client *c;
     gboolean ver = FALSE, buginfo = FALSE;
 
     GOptionEntry opts[] = {
+        {"cmd", 'C', 0, G_OPTION_ARG_CALLBACK, (GOptionArgFunc*)autocmdOptionArgFunc, "Ex command run before first page is loaded", NULL},
         {"config", 'c', 0, G_OPTION_ARG_FILENAME, &vb.configfile, "Custom configuration file", NULL},
         {"embed", 'e', 0, G_OPTION_ARG_STRING, &winid, "Reparents to window specified by xid", NULL},
         {"incognito", 'i', 0, G_OPTION_ARG_NONE, &vb.incognito, "Run with user data read-only", NULL},
 
     c = client_new(NULL);
     client_show(NULL, c);
+
+    /* process the --cmd if this was given */
+    for (GSList *l = vb.cmdargs; l; l = l->next) {
+        ex_run_string(c, l->data, false);
+    }
     if (argc <= 1) {
         vb_load_uri(c, &(Arg){TARGET_CURRENT, NULL});
     } else if (!strcmp(argv[argc - 1], "-")) {