Add a capability what disabling adblock at runtime

This commit is contained in:
jun7 2018-05-21 19:56:11 +09:00
parent d61e37cffb
commit b040c652d1
2 changed files with 6 additions and 1 deletions

View File

@ -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'));
---

View File

@ -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)