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) &&
(str = g_variant_get_string((GVariant *)v, NULL)))
{ {
const char *str = g_variant_get_string((GVariant *)v, NULL); bool enable = true;
if (str) char **args = g_strsplit(str, ";", -1);
{ for (char **arg = args; *arg; arg++)
char **args = g_strsplit(str, ";", -1); if (g_str_has_prefix(*arg, "adblock:"))
for (char **arg = args; *arg; arg++) {
if (g_str_has_prefix(*arg, "adblock:")) enable = !strcmp(*arg + 8, "true");
{ hasarg = true;
enable = strcmp(*arg + 8, "true") == 0; }
hasarg = true; g_strfreev(args);
} if (!enable) return;
g_strfreev(args);
}
} }
if (!hasarg && *(g_getenv("DISABLE_ADBLOCK") ?: "") != '\0')
enable = false;
if (enable) if (!hasarg && *(g_getenv("DISABLE_ADBLOCK") ?: "") != '\0')
{ return;
wyebloop(EXE, 30, 24);
g_signal_connect(ex, "page-created", G_CALLBACK(pageinit), NULL); wyebloop(EXE, 30, 24);
} g_signal_connect(ex, "page-created", G_CALLBACK(pageinit), NULL);
} }
#endif #endif