wyebadblock/README.md

152 lines
3.9 KiB
Markdown
Raw Normal View History

2017-07-17 08:10:19 +00:00
# wyebadblock
2018-07-29 09:45:25 +00:00
An adblock extension using the easylist.txt for [wyeb](https://github.com/jun7/wyeb), also webkit2gtk browsers.
2017-07-17 08:18:17 +00:00
2019-08-17 17:02:23 +00:00
most of code of this are from https://github.com/GNOME/epiphany/tree/master/embed
2017-07-17 08:18:17 +00:00
2018-06-05 09:43:00 +00:00
wyebab is shared by clients, So even nowadays, browsers spawn procs for each windows,
2018-06-09 14:21:26 +00:00
wyebab keeps single server proc that makes less RAM and less CPU times.
2017-07-17 08:18:17 +00:00
2018-08-04 13:16:19 +00:00
For example, while an epiphay's webproc uses 240M RAM for
a page, wyeb uses 160M for the same page.
2018-08-04 13:16:19 +00:00
Of course wyebab uses 80M but not gain.
2018-05-20 10:02:35 +00:00
2018-06-02 17:51:35 +00:00
Don't worry, wyebab wills quit automatically when there is no client and 30 secs past.
2018-05-23 03:51:04 +00:00
## usage:
2018-02-05 13:23:08 +00:00
2020-05-06 22:53:57 +00:00
depends: gtk+-3.0 glib-2.0 webkit2gtk-4.0
2020-05-06 22:44:42 +00:00
2018-01-19 02:11:17 +00:00
make
2018-02-05 13:38:21 +00:00
sudo make install
2017-07-17 08:18:17 +00:00
then
2018-06-09 14:21:26 +00:00
copy the **easylist.txt** to ~/.config/wyebadblock/
2017-07-17 08:18:17 +00:00
2018-01-11 06:57:12 +00:00
wyebadblock only checks 'easylist.txt'
2017-07-17 08:18:17 +00:00
2020-03-19 11:34:34 +00:00
You can check whether wyebab has found easylist.txt by `wyebab --css`
2018-01-19 02:11:17 +00:00
2018-08-04 13:16:19 +00:00
## Addition for other webkit2gtk browsers
2018-10-28 13:05:32 +00:00
webkit2gtk loads extensions in a dir designated by each apps.
2018-10-28 13:08:50 +00:00
So we have to make a link to wyebab in the dir.
2018-10-28 13:05:32 +00:00
Following paths are for Arch Linux. Make sure on other distros, the paths are may different.
2018-01-01 13:53:19 +00:00
2018-06-02 14:56:21 +00:00
### surfer
See the Surfer's README
https://github.com/nihilowy/surfer
2018-05-21 05:18:03 +00:00
### epiphany
sudo ln -s /usr/lib/wyebrowser/adblock.so /usr/lib64/epiphany/web-extensions
This lacks epiphany's functionalities about adblock (e.g. can't disable), but saves RAM and CPU.
Make sure while you keep enable epiphany's one, it is working too.
### surf
sudo mkdir usr/local/lib/surf
2018-03-22 03:11:17 +00:00
sudo ln -s /usr/lib/wyebrowser/adblock.so /usr/local/lib/surf
2018-01-01 13:52:12 +00:00
2018-06-02 17:51:35 +00:00
There is a PKGBUILD file. see the 'PKGBULDs' dir.
2018-02-04 06:07:14 +00:00
2018-01-01 13:52:12 +00:00
### vimb
2018-03-22 03:11:17 +00:00
sudo ln -s /usr/lib/wyebrowser/adblock.so /usr/lib/vimb
2018-01-19 02:11:17 +00:00
2018-03-18 12:06:00 +00:00
There is a PKGBUILD file. see the 'PKGBULDs' dir.
2018-01-01 13:52:12 +00:00
2018-10-28 13:08:50 +00:00
If the path doesn't work, check https://fanglingsu.github.io/vimb/howto.html#block
2018-10-28 13:05:32 +00:00
2018-05-20 06:45:32 +00:00
### luakit
2018-05-21 05:18:03 +00:00
sudo ln -s /usr/lib/wyebrowser/adblock.so /lib/luakit
2018-05-20 06:45:32 +00:00
2018-01-01 13:52:12 +00:00
### lariza
mkdir -p ~/.config/lariza/web_extensions
2018-03-22 03:11:17 +00:00
ln -s /usr/lib/wyebrowser/adblock.so ~/.config/lariza/web_extensions
2018-01-03 04:06:29 +00:00
2021-06-29 10:29:36 +00:00
Since lariza enables sandbox, wyebadblock does not work without changing 'webkit_web_context_set_sandbox_enabled'.
2020-02-14 15:28:52 +00:00
### badwolf
mkdir -p ${XDG_DATA_HOME:-$HOME/.local/share}/badwolf/webkit-web-extensions/
ln -s /usr/lib/wyebrowser/adblock.so ${XDG_DATA_HOME:-$HOME/.local/share}/badwolf/webkit-web-extensions/
2018-01-19 02:11:17 +00:00
2018-02-04 06:07:14 +00:00
### Others
2018-08-04 13:16:19 +00:00
search 'webkit_web_context_set_web_extensions_directory' in its source code
and make the link from the dir to the wyebadblock just like above browsers.
2018-02-04 05:51:40 +00:00
2021-06-29 10:29:36 +00:00
Also make sure 'webkit_web_context_set_sandbox_enabled' is not set.
2018-02-04 05:51:40 +00:00
2018-01-19 02:16:52 +00:00
---
2018-01-19 02:11:17 +00:00
## Element Hiding
2018-05-19 15:51:50 +00:00
Per domain CSS hider rule is not supported
2018-01-19 02:11:17 +00:00
2018-06-07 05:46:26 +00:00
wyebab --css > user.css
2018-01-19 02:11:17 +00:00
2018-08-04 13:16:19 +00:00
And add the user.css to your browser as a user css.
2018-05-19 15:51:50 +00:00
For wyeb, just copy the user.css to the conf dir.
2018-08-04 13:16:19 +00:00
Make sure that huge css takes RAM a lot.
2018-06-09 14:21:26 +00:00
Also it is often used to detect adblock.
2018-05-19 15:51:50 +00:00
2018-05-23 03:51:04 +00:00
## Disabling
Setting chars(whatever) to the env value $DISABLE_ADBLOCK disables adblock.
2018-11-06 16:29:27 +00:00
or
Move the easylist.txt.
2018-05-23 03:58:07 +00:00
### For source code:
2018-05-23 03:51:04 +00:00
set string ";adblock:false;" as the user data of the
webkit_web_context_set_web_extensions_initialization_user_data;
2018-05-23 10:28:32 +00:00
#### Runtime
2018-05-23 03:51:04 +00:00
g_object_set_data(G_OBJECT(webkitwebpage), "adblock", GINT_TO_POINTER('n'));
2018-08-04 13:16:19 +00:00
in any extension in the same process.
2018-05-23 03:51:04 +00:00
2018-05-23 03:58:07 +00:00
#### Full Control
2018-05-23 03:56:51 +00:00
2018-05-23 03:51:04 +00:00
If you want full control of wyebab as wyeb does, wyebab has api mode.
Set string ";wyebabapi;" as the extensions_init's data.
In api mode wyebab doesn't block URIs but keeps alive server proc and
set the check function to the page object.
2018-05-23 10:47:23 +00:00
So you can call the check func where ever as below.
2018-05-23 03:51:04 +00:00
bool (*checkf)(const char *, const char *) =
g_object_get_data(G_OBJECT(webkitwebpage), "wyebcheck");
if (checkf)
passed = checkf(requesturi, pageuri);
or
Use the shell interface below.
2018-08-04 13:16:19 +00:00
or
Use wyebrun like the client code of wyebab in the ISEXT part of the ab.c.
2018-05-23 03:51:04 +00:00
2018-05-19 15:51:50 +00:00
## Shell
wyebab
2018-06-04 13:17:42 +00:00
Reads stdin outputs to stdout and keeps server.
2018-05-19 15:51:50 +00:00
blank + enter quits.
2018-06-22 03:06:01 +00:00
wyebab "requst_uri page_uri"
2018-05-19 15:51:50 +00:00
2018-05-21 05:19:45 +00:00
Outputs result and
2018-06-04 13:18:40 +00:00
Keeps server 30 secs.