Open schvabodka-man opened 6 years ago
Hi, thank you for opening your issue! I share your sentiment, as a user, Adblock is immensely important to me/blocking images/js etc
So to answer your question, yes there are definitely plans for this, I think probably in version 0.07 or 0.08! I'll keep you updated!
-John
+1
Hey everyone, just to provide a quick update on this. I am still working hard on the new version which will finally enable this functionality. I anticipate a release within a couple of weeks. Thank you for your patience!
-John
Will it be some native solution, or will it rely on existing addons, like uBlock origin or Adblock plus? The former being much preferred.
Well, it turns out that my integration efforts have been in vain, because I'd have to make my own webkit port on MacOS to actually use the purported content blocking rules (only present in Safari), if any one has any other information they are privy to, or knows how to do it, please let me know.
As of now, the follow up plan is to implement advertisement blocking by updating the hosts file, not exactly the most elegant, but it works...
For simple host based blocking (at least), this can be done a bit cleaner (and without editing the system hosts file, which will probably need root) in qtwebkit by setting a network access manager which you define yourself to block whatever domains you want. This the example of how qb does this on qtwebkit. I'm pretty sure there should be something similar in webkitgtk, as luakit has a hostblocker built in, but I'm much less familiar with that (you might be able to get some pointers by reading the relevant sections of their source!)
Hi, to everyone wanting this ad-blocking feature. I am hard at work, but I need your help to make it happen, as part of a new architecture, I did finally figure out how to actually make ad-block possible.
If you would be able to, please support, or spread awareness about my crowdfunding campaign so that I can pay the C/C++ developer who I'll be working with, thank you for your time!
https://www.indiegogo.com/projects/next-browser-nix-support#/
I'm on this! Expect at least a host-based blocker + image blocker + javascript toggle from the work I'm going to put on this in the coming days :D
I've just pushed the resource blocker. Javascript toggle coming soon. Not too sure about the image blocker actually, does anyone know how to deal with image in WebKitGTK?
Nice! I assume it will be documented as well?
It already is (a little): https://github.com/atlas-engineer/next/blob/master/documents/MANUAL.org#resource-blodking-ad-blocking
Would it be hard to integrate this: https://github.com/brave/ad-block ?
We can't (or don't want to) "integrate" brace/ad-block directly since we would like to stick to a full-Lisp code base as much as possible, but sure the current algorithm can be expanded to follow more closely what Ublock-origin and brace/ad-block do.
It's a bit of work, but certainly doable. Specialists in ad-blocking are welcome to pitch in :D
See also #464.
Does this issue have any priority? I'd really like this to be implemented as It's the only thing preventing me from switching to Next as far as I've seen.
It has high priority indeed, post 2.0 (which is due in hopefully just a few of weeks).
One way to handle it would be to implement support WebExtensions, then we would get uBlock for free.
Help is more than welcome! :)
Hello. I'm working on a WebKitGTK extension similar to uBlock Origin as my bachelors thesis. I wanted to ask if Nyxt supports loading WebKitWebExtensions written in C/C++. Based on this cl-webkit code I think it should, but I want to be sure so I can potentially refer to Nyxt as a reason for why the WebKitGTK ecosystem would benefit from having such an extension and that the user base of these browsers is not negligible. Thank you.
We were just looking for a reason to merge WebExtension support!
https://github.com/joachifm/cl-webkit/pull/41
@aartaka Any comments?
It seems we found the reason to complete WebKitWebExtension support :tada:
I can look into it next week and test it with example extensions I found. Shouldn't be hard, so by the end of the next week we should have support for WebKitWebExtensions loading!
@dudik, thank you for this motivation!
It makes me extremely happy to see your enthusiasm. Sadly, I have just started writing my thesis and the first half is centered around theory. I'm also still in the middle of a normal semester, so I won't be able to show you anything worthwhile until February. Maybe sooner, but it's hard to say right now. I made some research and it is also in my own interest to have a WebKitGTK content blocker, so I'm positive about creating something useful. I'm really sorry, but also very thankful for the motivation.
No pressure, you're not obliged to work on it just because we found your idea to be in-line with what we do :)
In any way, good luck!
@dudik, good news: we've merged the WebKitWebExtension
support in cl-webkit! This means that Nyxt can use WebKit extensions and you can refer to Nyxt as a use-case for your thesis :)
Qutebrowser recently merged an adblocker based on Brave qutebrowser/qutebrowser#5317. Perhaps worth looking at how they did it. As far as I know, it is implemented in Rust, so it would add a non-lisp part into the code base, though.
It should not be part of the core, we would like to support the actual webextensions API so firefox and other plugins can be easily used and ported
In other words, no Nyxt specific hacks should be necessary
congratulations to the team for the achievement!
So after working on a pure C adblock for a month, I realized that because of performance reasons, I would have to implement it with inter-process communication in mind. That gave me the freedom to use any language I want so I ended up putting the C adblock aside and just creating a "bridge" between the Brave Rust adblocker and the C extension. This is the result. At this time it's pretty barebones and the code quality is questionable, but it's working both for cosmetic and network filtering so I felt it was the right time to make it public. While writing this comment I realized that I'm not freeing some memory in the C extension. This will get fixed tommorow when I wake up as I'm pretty sleepy. (it's fixed) Anyways, in the meantime I would like to hear if it works on your platform and how well. Thanks!
Thank you for much for sharing your work!
I just had a look at the code: so it looks like if we want to integrate
this in Nyxt, we just need to write FFI bindings to void webkit_web_extension_initialize(WebKitWebExtension *extension)
, is this correct?
No, we needn't :)
This function is an entry point for all WebKit extensions, so the only thing we need is to compile the extension, put it where Nyxt can find it (see WebKitWebExtension documentation), run adblock server, and enjoy the extension being enabled in Nyxt on the next startup.
EDIT: don't -> needn't
You mean we already have this binding?
Yes and no 🙃
We don't have it as a CL-CFFI binding, but we don't need to have it because WebKit manages its extensions automatically. The only change to Nyxt that we need to do is to set the extensions directory. This is trivial, I'll open the PR, most probably in a couple of hours.
EDIT: it's -> its :/
@aartaka are you still planning on open that PR? Cheers!
@aartaka are you still planning on open that PR? Cheers!
Actually, it's long merged :D
The directory is .config/nyxt/extensions/. However, it's likely to change soon (as per https://github.com/atlas-engineer/nyxt/pull/1505), so keep an eye on the gtk-extensions-path
of your Nyxt buffers :)
Amazing, I'll give it a go ASAP. Thanks a lot!
Wouldn't it be possible to write extensions in common lisp?
Of course, and some exist already! See https://github.com/atlas-engineer/nyxt/blob/master/documents/EXTENSIONS.org.
As for ad-blocking, the problem is mostly with maintenance; it's a huge endeavor. We would be better off reusing a well maintained ad-blocker than rolling out our own.
Qutebrowser uses brave browser's adblocker written in Rust.
Indeed, that's also an option that was mentioned in the past.
As an extra reference: the Webmacs alternative browser - written in Python as a replacement for Conkeror - also uses Brave browser's adblocker. The code is pulled as a submodule, then compiled here: https://github.com/parkouss/webmacs/blob/master/setup.py
and used in this way: https://github.com/parkouss/webmacs/blob/master/webmacs/adblock.py
I think uBlock Origin is the only extension I really need. You don't need WebExtension to get advanced adblock. Other extensions can be written in common lisp.
Isn't uBLock Origin based on WebExtension? How would you load uBlock Origin in Nyxt?
Brave's Rust adblock library is almost the same as uBlock Origin.
The directory is .config/nyxt/extensions/. However, it's likely to change soon (as per #1505), so keep an eye on the
gtk-extensions-path
of your Nyxt buffers :)
@aartaka Could you please give an example of how to load a WebKitWebExtension in Nyxt?
@aartaka Could you please give an example of how to load a WebKitWebExtension in Nyxt?
Sure! I assume you are aware of the fact that WebKitWebExtensions are .so
C libraries. The steps are:
.so
in .local/share/nyxt/gtk-extensions/
.One concern of mine, that we currently discussed in #1781, is that it can actually not load the extension due to WebKit being picky about the directories. To trespass the restriction, you can do export WEBKIT_FORCE_SANDBOX=0
(or add (setf (uiop:getenv "WEBKIT_FORCE_SANDBOX") "0")
to your config), until we come up with a better solution. Beware: this can disable extension sandboxing, so be careful about what you install!
EDIT: Change the directory to what it currently (Jan 2022) is.
Which one between WebExtension and Rust adblock library is better?
Which one between WebExtension and Rust adblock library is better?
I'd say WebExtensions, as those can hijack JS requests and modify the page opened in the browser, while any external adblocking library is usually restricted to host filtering. However perfect host filtering can be, that's not the only way tracking/advertisement works. Thus, WebExtensions are a priority.
However, if you want to use Brave's adblocker, you can try installing blockit as a WebKitWebExtension. I haven't managed to wrap my head around Rust building and thus haven't tried it, but it should run fine in Nyxt.
I'd say WebExtensions, as those can hijack JS requests and modify the page opened in the browser, while any external adblocking library is usually restricted to host filtering.
Perhaps, that's why qutebrowser can't do cosmetic filtering, yet?
blockit already supports cosmetic filtering. I think people should test nyxt with blockit.
I think it'll be better if we support web-extension apis, and then a lot of functionality can be done at the plugin side rather than embrace everything in the browser itself, which can ease the pain of maintaining a big project.
Now that #1762 is merged, there's a solid base to build uBlock support on top of. Here's a list of things to do for uBlock to work (copy-pasted from the linked pull request):
Hello. Are there plans on implementing per domain based settings to block stuff like ads, javascript, pictures, etc like umatrix?