all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#68604: [PATCH] Add user option to disable JavaScript in xwidget webview
@ 2024-01-19 23:16 Noé Lopez
  2024-01-20  7:57 ` Eli Zaretskii
  0 siblings, 1 reply; 18+ messages in thread
From: Noé Lopez @ 2024-01-19 23:16 UTC (permalink / raw)
  To: 68604

[-- Attachment #1: Type: text/plain, Size: 865 bytes --]

Hi,

This patch adds a new variable for xwidget webkit that allows users to
disable javascript.  Javascript is often used by websites for tracking,
advertisements, cookies and being obnoxious in general.

As I mostly use xwidget for viewing online documentation and simple
pages, disabling javascript is a very elegant solution to get rid of
everything obnoxious and browse with ease.  I hope this patch can be
useful for people with the same use case as me where javascript is not
needed.


In GNU Emacs 30.0.50 (build 5, x86_64-pc-linux-gnu, GTK+ Version
  3.24.38, cairo version 1.18.0) of 2024-01-19 built on navi
Repository revision: bd5bfc29137b6e452e1900a1fc3cf09e77959133
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101010
System Description: Void Linux

Configured using:
  'configure --with-xwidgets'

[-- Attachment #2: 0001-Add-user-option-to-disable-JavaScript-in-xwidget-web.patch --]
[-- Type: text/x-patch, Size: 3574 bytes --]

From cea55d4953cb70a8a4c3ba9c21aad68efc7475f1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?No=C3=A9=20Lopez?= <noelopez@free.fr>
Date: Fri, 19 Jan 2024 23:40:53 +0100
Subject: [PATCH] Add user option to disable JavaScript in xwidget webview

* etc/NEWS:
* doc/emacs/misc.texi (Embedded Webkit Widgets):
Document the change.
* lisp/xwidget.el:
* src/xwidget.el:
Add the 'xwidget-webkit-disable-javascript' variable to disable
JavaScript in WebKit sessions.
---
 doc/emacs/misc.texi | 8 ++++++++
 etc/NEWS            | 7 +++++++
 lisp/xwidget.el     | 7 +++++++
 src/xwidget.c       | 7 +++++++
 4 files changed, 29 insertions(+)

diff --git a/doc/emacs/misc.texi b/doc/emacs/misc.texi
index 7eb28f56826..d39d98678a0 100644
--- a/doc/emacs/misc.texi
+++ b/doc/emacs/misc.texi
@@ -3009,6 +3009,14 @@ Embedded WebKit Widgets
 
 It is bound to @kbd{H}.
 
+@vindex xwidget-webkit-disable-javascript
+@cindex disabling javascript in webkit buffers
+  JavaScript is enabled by default inside WebKit buffers, this can be
+undesirable as websites often use it to track your online activity. It
+can be disabled by setting the variable @code{xwidget-webkit-disable-javascript} to @code{t}.
+You must kill all WebKit buffers for this setting to take effect after
+it is changed.
+
 @node Browse-URL
 @subsection  Following URLs
 @cindex World Wide Web
diff --git a/etc/NEWS b/etc/NEWS
index 735a05f6579..33655663bd8 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1254,6 +1254,13 @@ chat buffers use by default.
 *** New command 'customize-dirlocals'.
 This command pops up a buffer to edit the settings in ".dir-locals.el".
 
+** Xwidget Webkit
+
++++
+*** New user option 'xwidget-webkit-disable-javascript'
+This allows disabling JavaScript in xwidget webkit
+sessions.
+
 \f
 * New Modes and Packages in Emacs 30.1
 
diff --git a/lisp/xwidget.el b/lisp/xwidget.el
index cca01c8cb3a..2fb79bb7b1d 100644
--- a/lisp/xwidget.el
+++ b/lisp/xwidget.el
@@ -116,6 +116,13 @@ xwidget-webkit-cookie-file
   :type '(choice (const :tag "Do not store cookies" nil) file)
   :version "29.1")
 
+(defcustom xwidget-webkit-disable-javascript nil
+  "If non-nil, disables the execution of JavaScript in xwidget webkit sessions.
+You must kill all xwidget-webkit buffers for this setting to take
+effect after changing it."
+  :type '(boolean)
+  :version "30.0")
+
 ;;;###autoload
 (defun xwidget-webkit-browse-url (url &optional new-session)
   "Ask xwidget-webkit to browse URL.
diff --git a/src/xwidget.c b/src/xwidget.c
index 58910459142..fc0055963c6 100644
--- a/src/xwidget.c
+++ b/src/xwidget.c
@@ -379,6 +379,7 @@ DEFUN ("make-xwidget",
 	  /* Enable the developer extras.  */
 	  settings = webkit_web_view_get_settings (WEBKIT_WEB_VIEW (xw->widget_osr));
 	  g_object_set (G_OBJECT (settings), "enable-developer-extras", TRUE, NULL);
+	  g_object_set (G_OBJECT (settings), "enable-javascript", !Vxwidget_webkit_disable_javascript, NULL);
 	}
 
       gtk_widget_set_size_request (GTK_WIDGET (xw->widget_osr), xw->width,
@@ -3972,6 +3973,12 @@ syms_of_xwidget (void)
 	       doc: /* List of all xwidget views.  */);
   Vxwidget_view_list = Qnil;
 
+  DEFVAR_BOOL("xwidget-webkit-disable-javascript", Vxwidget_webkit_disable_javascript,
+	      doc: /* If non-nil, disables the execution of JavaScript in xwidget webkit sessions.
+You must kill all xwidget-webkit buffers for this setting to take
+effect after changing it.  */);
+  Vxwidget_webkit_disable_javascript = Qnil;
+
   Fprovide (intern ("xwidget-internal"), Qnil);
 
   id_to_xwidget_map = CALLN (Fmake_hash_table, QCtest, Qeq,
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-03-14  9:34 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-19 23:16 bug#68604: [PATCH] Add user option to disable JavaScript in xwidget webview Noé Lopez
2024-01-20  7:57 ` Eli Zaretskii
2024-01-20 12:52   ` Noé Lopez
2024-01-20 13:03     ` Eli Zaretskii
2024-03-01 21:51       ` Noé Lopez
2024-03-02  7:25         ` Eli Zaretskii
2024-03-03  5:05         ` Richard Stallman
2024-03-03 17:10           ` Noé Lopez
2024-03-04  2:01             ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-06  2:22               ` Richard Stallman
2024-03-06  4:00                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-09  8:44                   ` Eli Zaretskii
2024-03-09 10:23                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-14  9:34                       ` Eli Zaretskii
2024-03-09 13:58                     ` Noé Lopez
2024-03-10  3:00                   ` Richard Stallman
2024-03-10  3:12                     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-13  2:27                       ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.