From b040c652d1c88d098259d530e01b74ec4d2c84ee Mon Sep 17 00:00:00 2001 From: jun7 Date: Mon, 21 May 2018 19:56:11 +0900 Subject: [PATCH] Add a capability what disabling adblock at runtime --- README.md | 3 +++ ephy-uri-tester.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d614ffb..9950f05 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,9 @@ For source code: set string "adblock:false;" as the user data of the webkit_web_context_set_web_extensions_initialization_user_data; +Runtime: + g_object_set_data(G_OBJECT(webkitwebpage), "adblock", GINT_TO_POINTER('n')); + --- diff --git a/ephy-uri-tester.c b/ephy-uri-tester.c index 75b0d7d..792b519 100644 --- a/ephy-uri-tester.c +++ b/ephy-uri-tester.c @@ -930,6 +930,9 @@ static bool first = true; static gboolean reqcb(WebKitWebPage *page, WebKitURIRequest *req, WebKitURIResponse *r, gpointer p) { + if (g_object_get_data(G_OBJECT(page), "adblock") == (gpointer)'n') + return false; + const char *requri = webkit_uri_request_get_uri(req); const char *pageuri = webkit_web_page_get_uri(page); @@ -954,7 +957,6 @@ static gboolean reqcb(WebKitWebPage *page, WebKitURIRequest *req, return false; } - static void pageinit(WebKitWebExtension *ex, WebKitWebPage *wp) { DD(pageinit)