Quentin, >> > I think that's fine, as this was kind of happening before anyway, >> > and if we can remove that IPC between main and ext through >> > ugly glib, the better. >> >> Not sure I get this one. Why glib? > > Because of the need for integrating into the main gtk loop, > look at the whole GIO madness (which doesn't work well too) > from pageusermessagereply().
Oh I see now! > Maybe, but this is mostly already part of the webkitgtk documentation. > We could keep a skeleton on the side, but as a second time patch, > making clear we remove the main surf webext, while having a something > like a webext-example.c on the side. Maybe just clean up the webext-surf.c and retain it in the Makefile? Much line config.h, it's there to be extended, even if doing nothing by default. I'm okay with webext-example.c idea too, though. >> > - Maybe it's not really useful to disable JavaScript (the original >> > one) entirely as it's needed for the core feature of being able to >> > scroll. Instead, we could substitute it for JavaScriptMarkup >> > directly. >> >> This is my doubt too. I opted for a separately toggled option because >> it seems useful (to a paranoid like me) to have a master override like >> JavaScript setting in addition to *-Markup one. But that also means >> that one can accidentally disable scrolling, which is not that >> intuitive. >> >> But the course of action with substituting JavaScript for >> JavaScriptMarkup in user-facing code (-Ss option, config examples >> maybe) seems most sane to me too. > > Yeah, what could be done is to do the substitution regarding > the option handling and toggling, > while keeping both options for those who actually want it. > > Then what could be useful is some comment somewhere, > eihter in the config.def.h directly, or the README. I've gone with a separate CLI option (-Jj,) and a note in config.def.h, find the full patch (including the original one) attached.
>From 785172240ca46923b7a500f2ae8f97f5e5658704 Mon Sep 17 00:00:00 2001 From: Artyom Bologov <g...@aartaka.me> Date: Sun, 20 Apr 2025 21:44:07 +0400 Subject: [surf] [PATCH] Add JavaScriptMarkup setting/option: disable page (but not user) JS --- config.def.h | 4 ++++ surf.1 | 9 ++++++++- surf.c | 13 +++++++++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 7c19915..a69e5dd 100644 --- a/config.def.h +++ b/config.def.h @@ -32,6 +32,10 @@ static Parameter defconfig[ParameterLast] = { [HideBackground] = { { .i = 0 }, }, [Inspector] = { { .i = 0 }, }, [JavaScript] = { { .i = 1 }, }, + /* The difference with "JavaScript" is that it only disables + * website-driven JS, leaving user/browser-invoked JS (like + * page scrolling) on. */ + [JavaScriptMarkup] = { { .i = 1 }, }, [KioskMode] = { { .i = 0 }, }, [LoadImages] = { { .i = 1 }, }, [MediaManualPlay] = { { .i = 1 }, }, diff --git a/surf.1 b/surf.1 index c1a7744..73277a7 100644 --- a/surf.1 +++ b/surf.1 @@ -3,7 +3,7 @@ surf \- simple webkit-based browser .SH SYNOPSIS .B surf -.RB [-bBdDfFgGiIkKmMnNpPsStTvwxX] +.RB [-bBdDfFgGiIjJkKmMnNpPsStTvwxX] .RB [-a\ cookiepolicies] .RB [-c\ cookiefile] .RB [-C\ stylefile] @@ -73,6 +73,13 @@ Disable Images. .B \-I Enable Images. .TP +.TP +.B \-j +Disable JavaScript Markup (but not user/browser JavaScript). +.TP +.B \-J +Enable JavaScript Markup. +.TP .B \-k Disable kiosk mode (enable key strokes and right click). .TP diff --git a/surf.c b/surf.c index 660e7cf..0cbeba8 100644 --- a/surf.c +++ b/surf.c @@ -68,6 +68,7 @@ typedef enum { HideBackground, Inspector, JavaScript, + JavaScriptMarkup, KioskMode, LoadImages, MediaManualPlay, @@ -835,6 +836,9 @@ setparameter(Client *c, int refresh, ParamName p, const Arg *a) case JavaScript: webkit_settings_set_enable_javascript(c->settings, a->i); break; + case JavaScriptMarkup: + webkit_settings_set_enable_javascript_markup(c->settings, a->i); + break; case KioskMode: return; /* do nothing */ case LoadImages: @@ -1151,6 +1155,7 @@ newview(Client *c, WebKitWebView *rv) "enable-html5-database", curconfig[DiskCache].val.i, "enable-html5-local-storage", curconfig[DiskCache].val.i, "enable-javascript", curconfig[JavaScript].val.i, + "enable-javascript-markup", curconfig[JavaScriptMarkup].val.i, "enable-site-specific-quirks", curconfig[SiteQuirks].val.i, "enable-smooth-scrolling", curconfig[SmoothScrolling].val.i, "enable-webgl", curconfig[WebGL].val.i, @@ -2101,6 +2106,14 @@ main(int argc, char *argv[]) defconfig[LoadImages].val.i = 1; defconfig[LoadImages].prio = 2; break; + case 'j': + defconfig[JavaScriptMarkup].val.i = 0; + defconfig[JavaScriptMarkup].prio = 2; + break; + case 'J': + defconfig[JavaScriptMarkup].val.i = 1; + defconfig[JavaScriptMarkup].prio = 2; + break; case 'k': defconfig[KioskMode].val.i = 0; defconfig[KioskMode].prio = 2; -- 2.48.1
Best of luck, -- Artyom Bologov https://aartaka.me