Hello,
I added 2 SLOC to the patch Moritz Wilhelmy sent to the mailing list
on 28/09/2009.
These 2 lines in newclient function make the patch behave opposite
to what it behaved.
I mean that images and flash are now disabled by default and it's
a good adblocker. :)
It applies on tip.
I hope it will be useful for someone.
Thanks to Moritz for this patch as it prevents disturbances while
surfing and that's quite enjoyable to me.
Julien
diff -up surf/config.def.h surf_toggle_image_flash/config.def.h
--- surf/config.def.h 2010-03-22 15:24:22.000000000 +0100
+++ surf_toggle_image_flash/config.def.h 2010-03-22 15:39:10.000000000 +0100
@@ -18,6 +18,8 @@ static Key keys[] = {
{ MODKEY|GDK_SHIFT_MASK,GDK_r, reload, { .b = TRUE } },
{ MODKEY, GDK_r, reload, { .b = FALSE } },
{ MODKEY|GDK_SHIFT_MASK,GDK_p, print, { 0 } },
+ { MODKEY, GDK_f, toggleflash,{ 0 } },
+ { MODKEY, GDK_i, toggleimages,{ 0 } },
{ MODKEY, GDK_p, clipboard, { .b = TRUE } },
{ MODKEY, GDK_y, clipboard, { .b = FALSE } },
{ MODKEY|GDK_SHIFT_MASK,GDK_j, zoom, { .i = -1 } },
Les sous-répertoires surf/.hg et surf_tip_toggle_image_flash/.hg sont identiques.
diff -up surf/surf.c surf_toggle_image_flash/surf.c
--- surf/surf.c 2010-03-22 15:24:22.000000000 +0100
+++ surf_toggle_image_flash/surf.c 2010-03-22 15:38:38.000000000 +0100
@@ -104,6 +104,8 @@ static void source(Client *c, const Arg
static void spawn(Client *c, const Arg *arg);
static void stop(Client *c, const Arg *arg);
static void titlechange(WebKitWebView *v, WebKitWebFrame* frame, const char* title, Client *c);
+static void toggleflash(Client *c, const Arg *arg);
+static void toggleimages(Client *c, const Arg *arg);
static void update(Client *c);
static void updatedownload(WebKitDownload *o, GParamSpec *pspec, Client *c);
static void updatewinid(Client *c);
@@ -534,6 +536,8 @@ newclient(void) {
if(!(ua = getenv("SURF_USERAGENT")))
ua = useragent;
g_object_set(G_OBJECT(settings), "user-agent", ua, NULL);
+ g_object_set(G_OBJECT(settings), "enable-plugins", FALSE, NULL);
+ g_object_set(G_OBJECT(settings), "auto-load-images", FALSE, NULL);
uri = g_strconcat("file://", stylefile, NULL);
g_object_set(G_OBJECT(settings), "user-stylesheet-uri", uri, NULL);
g_free(uri);
@@ -763,6 +767,26 @@ titlechange(WebKitWebView *v, WebKitWebF
}
void
+toggleflash(Client *c, const Arg *arg)
+{
+ static int flash = 0;
+ WebKitWebSettings *settings;
+ settings = webkit_web_view_get_settings(c->view);
+ flash = !flash;
+ g_object_set(G_OBJECT(settings), "enable-plugins", flash, NULL);
+}
+
+void
+toggleimages(Client *c, const Arg *arg)
+{
+ static int images = 0;
+ WebKitWebSettings *settings;
+ settings = webkit_web_view_get_settings(c->view);
+ images = !images;
+ g_object_set(G_OBJECT(settings), "auto-load-images", images, NULL);
+}
+
+void
update(Client *c) {
char *t;