atlas-engineer / nyxt

Nyxt - the hacker's browser.
https://nyxt-browser.com/
9.68k stars 407 forks source link

Feature request: image blocking #150

Closed azzamsa closed 9 months ago

azzamsa commented 5 years ago

Hi

It would be great if next has a feature to 'block images'. We often surf the internet with image blocked. Internet here rather slow and bit expensive (at least for me). Fyi, firefox also provide special app to use in this area, and bundled with 'image block'. Hope next support this soon.

Thank you.

photo_2018-12-04_06-12-31

Ambrevar commented 5 years ago

Image block (and all sorts of blocking :p) is a big need for me as well.

It's coming in the next release, hopefully very soon!

azzamsa commented 5 years ago

Image block (and all sorts of blocking :p) is a big need for me as well.

:tada:. When developers need it, I'm sure it will be implemented. I think this huge is need for most people :)

Ambrevar commented 5 years ago

@azzamsa : This is now possible in Next 1.2.1! There is no high-level command for now, but all network resources are intercepted and can be filtered from the Lisp side. I will work on something like a "no-image mode" soon!

azzamsa commented 5 years ago

@Ambrevar Failed to compile latest source. I run make all and this is what I get, with no '/ports/' and 'next' produced.

; in: LAMBDA ($1)
;     (LAMBDA (CL-STRING-MATCH::$1) `((:END)))
;
; caught STYLE-WARNING:
;   The variable $1 is defined but never used.
WARNING:
   bare references to struct types are deprecated. Please use (:POINTER
                                                               (:STRUCT
                                                                SQLITE3)) or (:STRUCT
                                                                              SQLITE3) instead.
WARNING:
   bare references to struct types are deprecated. Please use (:POINTER
                                                               (:STRUCT
                                                                SQLITE3-STMT)) or (:STRUCT
                                                                                   SQLITE3-STMT) instead.
WARNING: redefining LOG4CL-IMPL:APPENDER-ADDED in DEFGENERIC
WARNING: redefining LOG4CL-IMPL:APPENDER-REMOVED in DEFGENERIC
WARNING: redefining LOG4CL-IMPL::PROPERTY-ALIST in DEFGENERIC
[undoing binding stack and other enclosing state... done]
[performing final GC... done]
[defragmenting immobile space... (fin,inst,fdefn,code,sym)=2395+1437+27770+29177+26237... done]
[saving current Lisp image into /home/user/code-coba-home/manual-compile/next/next/next:
writing 0 bytes from the read-only space at 0x50000000
writing 432 bytes from the static space at 0x50100000
writing 60850176 bytes from the dynamic space at 0x1000000000
writing 1462272 bytes from the immobile space at 0x50300000
writing 19507216 bytes from the immobile space at 0x52100000
done]
make -C ports/gtk-webkit
make[1]: Entering directory '/home/user/code-coba-home/manual-compile/next/next/ports/gtk-webkit'
cc `pkg-config --cflags webkit2gtk-4.0`   -c -o next-gtk-webkit.o next-gtk-webkit.c
In file included from buffer.h:10:0,
                 from window.h:12,
                 from server.h:11,
                 from next-gtk-webkit.c:8:
javascript.h: In function ‘javascript_result’:
javascript.h:16:2: error: unknown type name ‘JSCValue’
  JSCValue *value;
  ^~~~~~~~
javascript.h:25:10: warning: implicit declaration of function ‘webkit_javascript_result_get_js_value’ [-Wimplicit-function-declaration]
  value = webkit_javascript_result_get_js_value(js_result);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
javascript.h:25:8: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
  value = webkit_javascript_result_get_js_value(js_result);
        ^
javascript.h:27:2: error: unknown type name ‘JSCException’
  JSCException *exception;
  ^~~~~~~~~~~~
javascript.h:29:14: warning: implicit declaration of function ‘jsc_value_to_string’ [-Wimplicit-function-declaration]
  str_value = jsc_value_to_string(value);
              ^~~~~~~~~~~~~~~~~~~
javascript.h:29:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
  str_value = jsc_value_to_string(value);
            ^
javascript.h:30:14: warning: implicit declaration of function ‘jsc_context_get_exception’ [-Wimplicit-function-declaration]
  exception = jsc_context_get_exception(jsc_value_get_context(value));
              ^~~~~~~~~~~~~~~~~~~~~~~~~
javascript.h:30:40: warning: implicit declaration of function ‘jsc_value_get_context’ [-Wimplicit-function-declaration]
  exception = jsc_context_get_exception(jsc_value_get_context(value));
                                        ^~~~~~~~~~~~~~~~~~~~~
javascript.h:30:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
  exception = jsc_context_get_exception(jsc_value_get_context(value));
            ^
In file included from /usr/include/glib-2.0/glib.h:62:0,
                 from /usr/include/gtk-3.0/gdk/gdkconfig.h:13,
                 from /usr/include/gtk-3.0/gdk/gdk.h:30,
                 from /usr/include/gtk-3.0/gtk/gtk.h:30,
                 from next-gtk-webkit.c:6:
javascript.h:32:45: warning: implicit declaration of function ‘jsc_exception_get_message’ [-Wimplicit-function-declaration]
   g_warning("Error running javascript: %s", jsc_exception_get_message(exception));
                                             ^
/usr/include/glib-2.0/glib/gmessages.h:336:32: note: in definition of macro ‘g_warning’
                                __VA_ARGS__)
                                ^~~~~~~~~~~
buffer.h: In function ‘buffer_navigated_callback’:
buffer.h:126:4: warning: implicit declaration of function ‘strndup’ [-Wimplicit-function-declaration]
    strndup(msg->response_body->data, msg->response_body->length));
    ^
/usr/include/glib-2.0/glib/gmessages.h:336:32: note: in definition of macro ‘g_warning’
                                __VA_ARGS__)
                                ^~~~~~~~~~~
buffer.h:126:4: warning: incompatible implicit declaration of built-in function ‘strndup’
    strndup(msg->response_body->data, msg->response_body->length));
    ^
/usr/include/glib-2.0/glib/gmessages.h:336:32: note: in definition of macro ‘g_warning’
                                __VA_ARGS__)
                                ^~~~~~~~~~~
In file included from window.h:12:0,
                 from server.h:11,
                 from next-gtk-webkit.c:8:
buffer.h: In function ‘buffer_set_proxy’:
buffer.h:378:23: warning: implicit declaration of function ‘strdup’ [-Wimplicit-function-declaration]
  buffer->_proxy_uri = strdup(proxy_uri);
                       ^~~~~~
buffer.h:378:23: warning: incompatible implicit declaration of built-in function ‘strdup’
In file included from server.h:11:0,
                 from next-gtk-webkit.c:8:
window.h: In function ‘window_generate_input_event’:
window.h:167:24: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
    event->key.length = strlen(event->key.string);
                        ^~~~~~
window.h:167:24: warning: incompatible implicit declaration of built-in function ‘strlen’
window.h:167:24: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
In file included from /usr/include/glib-2.0/glib.h:62:0,
                 from /usr/include/gtk-3.0/gdk/gdkconfig.h:13,
                 from /usr/include/gtk-3.0/gdk/gdk.h:30,
                 from /usr/include/gtk-3.0/gtk/gtk.h:30,
                 from next-gtk-webkit.c:6:
window.h: In function ‘window_consume_event’:
window.h:228:4: warning: incompatible implicit declaration of built-in function ‘strndup’
    strndup(msg->response_body->data, msg->response_body->length));
    ^
/usr/include/glib-2.0/glib/gmessages.h:336:32: note: in definition of macro ‘g_warning’
                                __VA_ARGS__)
                                ^~~~~~~~~~~
In file included from server.h:11:0,
                 from next-gtk-webkit.c:8:
window.h: In function ‘window_init’:
window.h:511:2: warning: ‘gtk_window_set_wmclass’ is deprecated [-Wdeprecated-declarations]
  gtk_window_set_wmclass(GTK_WINDOW(window->base), g_string_ascii_down(g_string_new(APPNAME))->str, APPNAME);
  ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/gtk-3.0/gtk/gtkdialog.h:32:0,
                 from /usr/include/gtk-3.0/gtk/gtkaboutdialog.h:30,
                 from /usr/include/gtk-3.0/gtk/gtk.h:31,
                 from next-gtk-webkit.c:6:
/usr/include/gtk-3.0/gtk/gtkwindow.h:154:12: note: declared here
 void       gtk_window_set_wmclass              (GtkWindow           *window,
            ^~~~~~~~~~~~~~~~~~~~~~
In file included from next-gtk-webkit.c:8:0:
server.h: In function ‘server_window_make’:
server.h:54:37: warning: incompatible implicit declaration of built-in function ‘strdup’
  g_hash_table_insert(state.windows, strdup(a_key), window);
                                     ^~~~~~
server.h: In function ‘server_buffer_make’:
server.h:182:37: warning: incompatible implicit declaration of built-in function ‘strdup’
  g_hash_table_insert(state.buffers, strdup(a_key), buffer);
                                     ^~~~~~
<builtin>: recipe for target 'next-gtk-webkit.o' failed
make[1]: *** [next-gtk-webkit.o] Error 1
make[1]: Leaving directory '/home/user/code-coba-home/manual-compile/next/next/ports/gtk-webkit'
Makefile:44: recipe for target 'gtk-webkit' failed
make: *** [gtk-webkit] Error 2

user at machine in ~/code-coba-home/manual-compile/next/next on master
$ make all
make -C ports/gtk-webkit
make[1]: Entering directory '/home/user/code-coba-home/manual-compile/next/next/ports/gtk-webkit'
cc `pkg-config --cflags webkit2gtk-4.0`   -c -o next-gtk-webkit.o next-gtk-webkit.c
In file included from buffer.h:10:0,
                 from window.h:12,
                 from server.h:11,
                 from next-gtk-webkit.c:8:
javascript.h: In function ‘javascript_result’:
javascript.h:16:2: error: unknown type name ‘JSCValue’
  JSCValue *value;
  ^~~~~~~~
javascript.h:25:10: warning: implicit declaration of function ‘webkit_javascript_result_get_js_value’ [-Wimplicit-function-declaration]
  value = webkit_javascript_result_get_js_value(js_result);
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
javascript.h:25:8: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
  value = webkit_javascript_result_get_js_value(js_result);
        ^
javascript.h:27:2: error: unknown type name ‘JSCException’
  JSCException *exception;
  ^~~~~~~~~~~~
javascript.h:29:14: warning: implicit declaration of function ‘jsc_value_to_string’ [-Wimplicit-function-declaration]
  str_value = jsc_value_to_string(value);
              ^~~~~~~~~~~~~~~~~~~
javascript.h:29:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
  str_value = jsc_value_to_string(value);
            ^
javascript.h:30:14: warning: implicit declaration of function ‘jsc_context_get_exception’ [-Wimplicit-function-declaration]
  exception = jsc_context_get_exception(jsc_value_get_context(value));
              ^~~~~~~~~~~~~~~~~~~~~~~~~
javascript.h:30:40: warning: implicit declaration of function ‘jsc_value_get_context’ [-Wimplicit-function-declaration]
  exception = jsc_context_get_exception(jsc_value_get_context(value));
                                        ^~~~~~~~~~~~~~~~~~~~~
javascript.h:30:12: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
  exception = jsc_context_get_exception(jsc_value_get_context(value));
            ^
In file included from /usr/include/glib-2.0/glib.h:62:0,
                 from /usr/include/gtk-3.0/gdk/gdkconfig.h:13,
                 from /usr/include/gtk-3.0/gdk/gdk.h:30,
                 from /usr/include/gtk-3.0/gtk/gtk.h:30,
                 from next-gtk-webkit.c:6:
javascript.h:32:45: warning: implicit declaration of function ‘jsc_exception_get_message’ [-Wimplicit-function-declaration]
   g_warning("Error running javascript: %s", jsc_exception_get_message(exception));
                                             ^
/usr/include/glib-2.0/glib/gmessages.h:336:32: note: in definition of macro ‘g_warning’
                                __VA_ARGS__)
                                ^~~~~~~~~~~
buffer.h: In function ‘buffer_navigated_callback’:
buffer.h:126:4: warning: implicit declaration of function ‘strndup’ [-Wimplicit-function-declaration]
    strndup(msg->response_body->data, msg->response_body->length));
    ^
/usr/include/glib-2.0/glib/gmessages.h:336:32: note: in definition of macro ‘g_warning’
                                __VA_ARGS__)
                                ^~~~~~~~~~~
buffer.h:126:4: warning: incompatible implicit declaration of built-in function ‘strndup’
    strndup(msg->response_body->data, msg->response_body->length));
    ^
/usr/include/glib-2.0/glib/gmessages.h:336:32: note: in definition of macro ‘g_warning’
                                __VA_ARGS__)
                                ^~~~~~~~~~~
In file included from window.h:12:0,
                 from server.h:11,
                 from next-gtk-webkit.c:8:
buffer.h: In function ‘buffer_set_proxy’:
buffer.h:378:23: warning: implicit declaration of function ‘strdup’ [-Wimplicit-function-declaration]
  buffer->_proxy_uri = strdup(proxy_uri);
                       ^~~~~~
buffer.h:378:23: warning: incompatible implicit declaration of built-in function ‘strdup’
In file included from server.h:11:0,
                 from next-gtk-webkit.c:8:
window.h: In function ‘window_generate_input_event’:
window.h:167:24: warning: implicit declaration of function ‘strlen’ [-Wimplicit-function-declaration]
    event->key.length = strlen(event->key.string);
                        ^~~~~~
window.h:167:24: warning: incompatible implicit declaration of built-in function ‘strlen’
window.h:167:24: note: include ‘<string.h>’ or provide a declaration of ‘strlen’
In file included from /usr/include/glib-2.0/glib.h:62:0,
                 from /usr/include/gtk-3.0/gdk/gdkconfig.h:13,
                 from /usr/include/gtk-3.0/gdk/gdk.h:30,
                 from /usr/include/gtk-3.0/gtk/gtk.h:30,
                 from next-gtk-webkit.c:6:
window.h: In function ‘window_consume_event’:
window.h:228:4: warning: incompatible implicit declaration of built-in function ‘strndup’
    strndup(msg->response_body->data, msg->response_body->length));
    ^
/usr/include/glib-2.0/glib/gmessages.h:336:32: note: in definition of macro ‘g_warning’
                                __VA_ARGS__)
                                ^~~~~~~~~~~
In file included from server.h:11:0,
                 from next-gtk-webkit.c:8:
window.h: In function ‘window_init’:
window.h:511:2: warning: ‘gtk_window_set_wmclass’ is deprecated [-Wdeprecated-declarations]
  gtk_window_set_wmclass(GTK_WINDOW(window->base), g_string_ascii_down(g_string_new(APPNAME))->str, APPNAME);
  ^~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/gtk-3.0/gtk/gtkdialog.h:32:0,
                 from /usr/include/gtk-3.0/gtk/gtkaboutdialog.h:30,
                 from /usr/include/gtk-3.0/gtk/gtk.h:31,
                 from next-gtk-webkit.c:6:
/usr/include/gtk-3.0/gtk/gtkwindow.h:154:12: note: declared here
 void       gtk_window_set_wmclass              (GtkWindow           *window,
            ^~~~~~~~~~~~~~~~~~~~~~
In file included from next-gtk-webkit.c:8:0:
server.h: In function ‘server_window_make’:
server.h:54:37: warning: incompatible implicit declaration of built-in function ‘strdup’
  g_hash_table_insert(state.windows, strdup(a_key), window);
                                     ^~~~~~
server.h: In function ‘server_buffer_make’:
server.h:182:37: warning: incompatible implicit declaration of built-in function ‘strdup’
  g_hash_table_insert(state.buffers, strdup(a_key), buffer);
                                     ^~~~~~
<builtin>: recipe for target 'next-gtk-webkit.o' failed
make[1]: *** [next-gtk-webkit.o] Error 1
make[1]: Leaving directory '/home/user/code-coba-home/manual-compile/next/next/ports/gtk-webkit'
Makefile:44: recipe for target 'gtk-webkit' failed
make: *** [gtk-webkit] Error 2
Ambrevar commented 5 years ago

You need webkitgtk 2.22 or newer. If you are on Debian, you can either upgrade to Debien Testing or install Guix and run

guix install webkitgtk@2.24

I recommend the latter ;)

Ambrevar commented 5 years ago

Back to the topic: I've added a buffer-set endpoints which allows for customizing arbitrary settings on the platform port. WebKit can block images, sadly for now it's an "all or nothing" option. So technically we can have a "no-image mode", but it'd be better if we could replace pictures with place holders and have them load on click.

jmercouris commented 5 years ago

@Ambrevar I believe what are you suggesting is doable by injecting some JS before the HTML page is loaded to replace the image source tags and store the URL somewhere or something

azzamsa commented 5 years ago

@Ambrevar I have installed guix, and install sbcl-next succelfully. But my os can't find neither next or next-sbcl.

Also, I tried to make all but always failed here (after pull the newest commit from master):

Error output was:
/home/user/.cache/common-lisp/sbcl-1.4.14-linux-x64/home/user/code-coba-home/manual-compile/next/next/quicklisp/dists/quicklisp/software/iolib-v0.8.3/src/syscalls/ffi-types-unix.c:14:17: fatal error: lfp.h: No such file or directory
 #include <lfp.h>
                 ^
compilation terminated.
Ambrevar commented 5 years ago

With guix, you can run next from a shell by simply typing next.

To compile from master, you need to install libfixposix as well as all the deps listed in the developer README:

https://github.com/atlas-engineer/next/blob/master/documents/README.org#gnulinux-dependencies

azzamsa commented 5 years ago

Oh yeah, I can type next now in terminal after some reboot.

For manual compile, I still failed.

$ sudo apt install libfixposix
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libfixposix

Next, I will add apt install list of packages under https://github.com/atlas-engineer/next/blob/master/documents/README.org#gnulinux-dependencies

Ambrevar commented 5 years ago

What's your distribution? libfixposix is on Debian:

https://packages.debian.org/search?keywords=libfixposix&searchon=names&suite=all&section=all

Next, I will add apt install list of packages under https://github.com/atlas-engineer/next/blob/master/documents/README.org#gnulinux-dependencies

The problem is that we can't possibly list all commands for all distributions.

Ideally, Next would be packaged for all distributions, then there would be no need for instructions as the dependencies would come with the package itself.

easbarba commented 5 years ago

@azzamsa

Guix install Next as sbcl-next

azzamsa commented 5 years ago

The problem is that we can't possibly list all commands for all distributions.

Yes, but at least we have some example for some popular distro :)

I choose to use the Guix installation, manual installation always drag me to an error.

Ambrevar commented 5 years ago

Which error? Can you report the command you've issued and the output?

azzamsa commented 5 years ago

1) Is it better for us to have something like slack/irc channel, so that we can discuss the error from manual compiling without messing issue thread? (maybe)

2) Why I recommend to add sudo apt install every dependency with version. Take an example of gstreamer in debian repo, it's hard to decide which packages that we need, the one with package0 or package1 or package-dev ? (confusing)

3) this is the error I get: https://gist.github.com/azzamsa/da07c41a20d0b647618545cc85275f2a

jmercouris commented 5 years ago

@azzamsa

  1. IRC Channel: next-browser
  2. Sounds like a problem with Debian rather than Next
  3. Which packages have you installed?
azzamsa commented 5 years ago
  1. Which packages have you installed?

I've successfully build and use next last month, now when I pull new revision, I get those error. I will try to check every dependency one by one again.

Ambrevar commented 5 years ago

The log you've shared shows that you are compiling against an outdated version of webkitgtk. Make sure you have webkitgtk 2.22 at least.

azzamsa commented 5 years ago

I have installed the newest webkitgtk using guix, Sorry, but how to make sure compiling next choose the installed webkit from guix?

Ambrevar commented 5 years ago

That's your issue. This depends on your distribution.

To know which one is chosen, look at the output of

$ pkg-config --cflags webkit2gtk-4.0

in a shell. You'll need to configure the INCLUDE_PATH or pkg-config correctly. I'm not too sure if there is a universal way to do it.

jmercouris commented 3 years ago

This is now possible with no-image mode. Please try it out :-)

Ambrevar commented 3 years ago

noimage-mode is only an all-or-nothing solution, we lack the ability to unblock select images like some plugins do.

jmercouris commented 3 years ago

Can you be more specific? What are the heuristics used to decide whether to block an image?

Ambrevar commented 3 years ago

The mode would block all images, replacing them with clickable placeholders. When the user clicks the placeholder, it loads the corresponding image.

aadcg commented 1 year ago

noimage-mode is only an all-or-nothing solution, we lack the ability to unblock select images like some plugins do.

The mode would block all images, replacing them with clickable placeholders. When the user clicks the placeholder, it loads the corresponding image.

A new issue that highlights how no-image can be improved should be created.

aartaka commented 1 year ago

I'm not sure this is implementable, actually. Image loading is mostly on the renderer side, and the only thing we can do here will be an unportable dirty hack at best. I'm thinking about closing this one, because no-image-mode is probably the best shot at this issue.

aadcg commented 1 year ago

I agree. Plus, I believe that creating issues with attainable/actionable goals is better than having general ones. If anyone comes up with ideas to improve image-mode, please share!

jmercouris commented 9 months ago

Agreed.