Undo the disabling method

This commit is contained in:
jun7 2018-05-22 12:32:47 +09:00
parent 3edc7d8e99
commit 257c0a893c
2 changed files with 11 additions and 9 deletions

View File

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

View File

@ -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)
if (!useapi)
g_signal_connect(wp, "send-request", G_CALLBACK(reqcb), NULL);
g_object_set_data(G_OBJECT(wp), "wyebabcheck", check);
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;
}