From 257c0a893c144a32eb527e62099189c82bff29f7 Mon Sep 17 00:00:00 2001 From: jun7 Date: Tue, 22 May 2018 12:32:47 +0900 Subject: [PATCH] Undo the disabling method --- README.md | 2 +- ephy-uri-tester.c | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 4236823..049c9f6 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ webkit_web_context_set_web_extensions_initialization_user_data; Runtime: - g_object_set_data(G_OBJECT(webkitwebpage), "wyebab", GINT_TO_POINTER('n')); + g_object_set_data(G_OBJECT(webkitwebpage), "adblock", GINT_TO_POINTER('n')); in any extension. diff --git a/ephy-uri-tester.c b/ephy-uri-tester.c index 1d8ac49..4cd1411 100644 --- a/ephy-uri-tester.c +++ b/ephy-uri-tester.c @@ -939,7 +939,7 @@ static bool check(const char *requri, const char *pageuri) static gboolean reqcb(WebKitWebPage *page, WebKitURIRequest *req, WebKitURIResponse *r, gpointer p) { - if (g_object_get_data(G_OBJECT(page), "wyebab") == (gpointer)'n') + if (g_object_get_data(G_OBJECT(page), "adblock") == (gpointer)'n') return false; const char *requri = webkit_uri_request_get_uri(req); @@ -954,20 +954,18 @@ static gboolean reqcb(WebKitWebPage *page, WebKitURIRequest *req, } if (check(requri, pageuri)) return false; - - void (*rf)(gpointer p, const char *) = - g_object_get_data(G_OBJECT(page), "blockedreport"); - if (rf) - rf(g_object_get_data(G_OBJECT(page), "blockedreportto"), requri); return true; } +static bool useapi = false; static void pageinit(WebKitWebExtension *ex, WebKitWebPage *wp) { DD(pageinit) - g_signal_connect(wp, "send-request", G_CALLBACK(reqcb), NULL); - g_object_set_data(G_OBJECT(wp), "wyebabcheck", check); + if (!useapi) + g_signal_connect(wp, "send-request", G_CALLBACK(reqcb), NULL); + + g_object_set_data(G_OBJECT(wp), "wyebcheck", check); } G_MODULE_EXPORT void webkit_web_extension_initialize_with_user_data( @@ -981,11 +979,15 @@ G_MODULE_EXPORT void webkit_web_extension_initialize_with_user_data( bool enable = true; char **args = g_strsplit(str, ";", -1); for (char **arg = args; *arg; arg++) + { if (g_str_has_prefix(*arg, "adblock:")) { enable = !strcmp(*arg + 8, "true"); hasarg = true; } + if (!strcmp(*arg, "wyebabapi")) + useapi = true; + } g_strfreev(args); if (!enable) return; }