diff --git a/README.md b/README.md index 1f0488d..c9f811f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/ephy-uri-tester.c b/ephy-uri-tester.c index d90bdef..36c8cfd 100644 --- a/ephy-uri-tester.c +++ b/ephy-uri-tester.c @@ -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);