Add a env value

This commit is contained in:
jun7 2018-01-02 10:07:34 +09:00
parent 4efc8c36f4
commit c7bde6ade0
2 changed files with 16 additions and 0 deletions

View File

@ -14,6 +14,16 @@ copy **easylist.txt** to ~/.config/wyebadblock
this only checks 'easylist.txt'
---
Setting chars(whatever) to the env value $DISABLE_ADBLOCK disables adblock.
For source code:
set string ";adblock:false;" as user data of the
webkit_web_context_set_web_extensions_initialization_user_data;
---
## webkit2gtk browsers

View File

@ -987,6 +987,7 @@ G_MODULE_EXPORT void webkit_web_extension_initialize_with_user_data(
WebKitWebExtension *ex, const GVariant *v)
{
bool enable = true;
bool hasarg = false;
if (v)
{
const gchar *str = g_variant_get_string((GVariant *)v, NULL);
@ -995,10 +996,15 @@ G_MODULE_EXPORT void webkit_web_extension_initialize_with_user_data(
gchar **args = g_strsplit(str, ";", -1);
for (gchar **arg = args; *arg; arg++)
if (g_str_has_prefix(*arg, "adblock:"))
{
enable = strcmp(*arg + 8, "true") == 0;
hasarg = true;
}
g_strfreev(args);
}
}
if (!hasarg && *(g_getenv("DISABLE_ADBLOCK") ?: "") != '\0')
enable = false;
if (enable)
g_signal_connect(ex, "page-created", G_CALLBACK(initex), NULL);