Clean up random code

This commit is contained in:
jun7 2018-05-22 00:13:53 +09:00
parent 4e439f7f6f
commit 4feef09576

View File

@ -966,31 +966,28 @@ static void pageinit(WebKitWebExtension *ex, WebKitWebPage *wp)
G_MODULE_EXPORT void webkit_web_extension_initialize_with_user_data( G_MODULE_EXPORT void webkit_web_extension_initialize_with_user_data(
WebKitWebExtension *ex, const GVariant *v) WebKitWebExtension *ex, const GVariant *v)
{ {
bool enable = true;
bool hasarg = false; bool hasarg = false;
if (v && g_variant_is_of_type((GVariant *)v, G_VARIANT_TYPE_STRING)) const char *str;
{ if (v && g_variant_is_of_type((GVariant *)v, G_VARIANT_TYPE_STRING) &&
const char *str = g_variant_get_string((GVariant *)v, NULL); (str = g_variant_get_string((GVariant *)v, NULL)))
if (str)
{ {
bool enable = true;
char **args = g_strsplit(str, ";", -1); char **args = g_strsplit(str, ";", -1);
for (char **arg = args; *arg; arg++) for (char **arg = args; *arg; arg++)
if (g_str_has_prefix(*arg, "adblock:")) if (g_str_has_prefix(*arg, "adblock:"))
{ {
enable = strcmp(*arg + 8, "true") == 0; enable = !strcmp(*arg + 8, "true");
hasarg = true; hasarg = true;
} }
g_strfreev(args); g_strfreev(args);
if (!enable) return;
} }
}
if (!hasarg && *(g_getenv("DISABLE_ADBLOCK") ?: "") != '\0')
enable = false;
if (enable) if (!hasarg && *(g_getenv("DISABLE_ADBLOCK") ?: "") != '\0')
{ return;
wyebloop(EXE, 30, 24); wyebloop(EXE, 30, 24);
g_signal_connect(ex, "page-created", G_CALLBACK(pageinit), NULL); g_signal_connect(ex, "page-created", G_CALLBACK(pageinit), NULL);
}
} }
#endif #endif