From 4a81dde28d93e6e7957ccdcf769229422225b036 Mon Sep 17 00:00:00 2001 From: jun7 Date: Tue, 21 Apr 2020 22:50:36 +0900 Subject: [PATCH] Change css for grep -v and add user-message-received handler not tested though --- ab.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/ab.c b/ab.c index 943f5fa..d5ae6a5 100644 --- a/ab.c +++ b/ab.c @@ -60,6 +60,17 @@ static gboolean reqcb(WebKitWebPage *kp, WebKitURIRequest *req, return true; } +#if WEBKIT_MAJOR_VERSION > 2 || WEBKIT_MINOR_VERSION > 26 +static gboolean msgcb(WebKitWebPage *kp, WebKitUserMessage *msg, gpointer p) +{ + if (strcmp("wyebadblock", webkit_user_message_get_name(msg))) return false; + g_object_set_data(G_OBJECT(kp), "adblock", + g_variant_get_boolean(webkit_user_message_get_parameters(msg)) ? NULL : + GINT_TO_POINTER('n')); + return true; +} +#endif + static gboolean keepcb(WebKitWebPage *kp) { if (g_object_get_data(G_OBJECT(kp), "adblock") != (gpointer)'n') @@ -74,6 +85,9 @@ static void pageinit(WebKitWebExtension *ex, WebKitWebPage *kp) if (!apimode) g_signal_connect(kp, "send-request", G_CALLBACK(reqcb), NULL); +#if WEBKIT_MAJOR_VERSION > 2 || WEBKIT_MINOR_VERSION > 26 + g_signal_connect(kp, "user-message-received", G_CALLBACK(msgcb), NULL); +#endif g_object_set_data(G_OBJECT(kp), "wyebcheck", check); @@ -222,10 +236,10 @@ int main(int argc, char **argv) g_thread_join(initt); g_print("%s", tester->blockcss->str); - g_print("\n\n\n\n{display:none !important}\n" - "\n/*\n" + g_print("\n\n\n\n" + "{display:none !important} /*\n" "{opacity:0 !important; position:absolute !important;}\n" - "\n*/\n"); + ); //g_print(tester->blockcssprivate->str); } else