e1e0.net

sources for e1e0 website
git clone https://git.e1e0.net/e1e0.net.git
Log | Files | Refs

commit 5d8c4834b1054e73a26e4cea89981092c677b1b2
parent d2f27f496e2de922d9ccbd63e57c2287d7e9621b
Author: Paco Esteban <paco@onna.be>
Date:   Tue,  7 May 2019 19:22:51 +0200

New article about stawing away from the browser.

Diffstat:
Acontent/browser-dependency.md | 287+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 287 insertions(+), 0 deletions(-)

diff --git a/content/browser-dependency.md b/content/browser-dependency.md @@ -0,0 +1,287 @@ +title: Trying to avoid browser dependency. +author: paco +date: 2019-05-07 +css: style.css + +XXmenuXX + +--------- +# Trying to avoid browser dependency. +2019-05-07 + +Web browsers are almost the only GUI programs I use. They are also the most +bloated and vulnerable programs one can have installed on desktop/laptop. + +Those browsers have to handle a lot of external code that comes from the +websites visited. Not only static html (which is already problematic in some +cases) but also JavaScript, which has to be interpreted and run in your machine +with the obvious risk. + +Is not only a matter of security, but also privacy. Almost every website out +there is tracking you in some way or another. Or worst, is using one of the big +companies to track you, which makes their profiling even easier ... + +And then there's the _ups!_ moments like the recent [Firefox bug][1] that +deactivated all the user plugins. The worst part in my opinion is trying to fix +the thing using the _"Studies system"_, which already has a reputation ... + +The other big browser, Chrome is not free of all this stuff. They spy on you +directly without even hiding it. + +Here you can find a series of techniques to use web browsers as little as +possible. + +## Basic browsing + +For basic stuff, like sites that are mostly text as Wikipedia or others, one +can use a text based browser like [lynx][2]. This becomes impossible with sites +that make heavy use of JavaScript or sites that require captcha to login ... In +that case, the only alternative I can think of is use a conventional browser +with plugins like uBlock Origin or Privacy Badger. + +## Bookmarks + +There are some ways of have your bookmarks totally independent from a browser. +I choose to use [shiori][3]. It's a terminal utility that you can use to add, +search, or open bookmarks. It also has a web interface if you prefer that. + +A simple search can be done like this: + + shiori search keyword + +You cal also specify tags in the search with `-t`. Then you can open it in your +default browser with: + + shiori open id + +Take a look at `help`, it's really easy. + +You can also import/export bookmarks in html format as most browsers +understand, so migrating to/from `shiori` is quite easy. + +## Downloads + +Whenever I can, I use [curl][4], `ftp(1)` or [wget][5] from the command line with +direct links. If using a text based browser, then it should have its own way of +dealing with downloads. + +Some sites do not like user that do not use conventional browsers, as those are +more difficult to track (not impossible, just a bit more difficult). Some of +them block requests that don't come from _"regular"_ user agents, so it's +usually a good idea to configure your tools to identify themselves as Mozilla +Firefox or Google Chrome. Most of the times that is enough. + +If using bittorrent to download stuff, the problem is to find a torrent website +that is not completely full of crap and you can just take the magnet links +(because you should be using magnet links). Try to use API calls if your +favourite tracker allows it. + +I usually use [rarbg][6]. You have a lot of alternatives to interact with its +[api][7]. A long time ago I did some Perl module for it called +[Rarbg::torrentapi][8]. Then I use a sort of interactive script to search +torrents on the terminal, it pairs with [transmission][9] to send the magnet +links directly to the torrent client. + + #!/usr/bin/env perl + + use v5.24; + use strict; + use warnings; + use Rarbg::torrentapi; + use Getopt::Long; + no warnings 'experimental'; + + sub usage { + say + "Usage: $0 [--list] [--search <string>] [--categories <category>] [--limit <n>]"; + say "\t--list\t\t\tlists last added torrents sorted by seeds."; + say + "\t--search <string>\tsearches for <string> and returns sorted by seeds"; + say + "\t--category [movies|tv|music|xxxx]\tuses those categories (defaults to movies)"; + say "\t--limit [25|50|100]\tShows 'n' results (defaults to 25)"; + exit 1; + } + + my $tapi = Rarbg::torrentapi->new(); + my $counter = 0; + my $search = ""; + my $list; + my $result; + my $raw_category = ''; + my $category; + my $limit = 25; + + GetOptions( + "search=s" => \$search, + "list" => \$list, + "category=s" => \$raw_category, + "limit=i" => \$limit + ) or usage(); + + given ($raw_category) { + when ( $_ eq 'movies' or $_ eq 'tv' ) { + $category = $raw_category; + } + when ( $_ eq 'music' ) { + $category = '2;23;24;25;26'; + } + default { + $category = 'movies' + } + } + + if ($search) { + $result = $tapi->search( + { sort => 'seeders', + limit => $limit, + category => $category, + search_string => $search + } + ); + } + elsif ($list) { + $result = $tapi->list( + { sort => 'seeders', + limit => $limit, + category => $category + } + ); + } + else { + usage(); + } + + if ( ref($result) eq 'ARRAY' ) { + foreach my $t ( @{$result} ) { + printf( + "%d -> %s (%.2f GB # %d seeds)\n", + $counter, $t->title, $t->size / 1073741824, + $t->seeders + ); + $counter++; + } + } + elsif ( ref($result) eq 'Rarbg::torrentapi::Error' ) { + die "[*] We got an error: $result->{error}"; + } + else { + die "[*] Unexpected Error"; + } + + print "Input selection, separated by spaces. (Ctrl+C to quit) "; + my $selection = <STDIN>; + chomp $selection; + + if ( $selection =~ m/\d{1,2} ?/ ) { + my @selections = split( / /, $selection ); + foreach my $s (@selections) { + say "[*] You selected: " . $result->[$s]->title; + say " [-] sending magnet to transmission:\n" + . $result->[$s]->download; + my $magnet = $result->[$s]->download; + `transmission-remote MYTORRENTHOST --authenv -a $magnet`; + } + } + else { + die "selection is not a number!"; + } + +## RSS feeds + +The best solution I found for this is [newsboat][10]. You can use it directly +(providing a list of feeds to pull from) or connecting it to a supported +external service like [ttrss][11]. I happen to have access to a `ttrss` +installation, so I use that and also have the Android app on my phone. That way +I keep track of what I have read/seen. + +`newsboat` allows you to configure the browser it will use to open links. I +find useful to have a wrapper script as configured browser, so it routes the +different kinds of links to different programs, and defaults to a web browser +if needed. I also use it for other stuff on the command line, is pretty +convenient. + + #!/usr/bin/env bash + + ext="${1##*.}" + videoSites="youtube.com|youtu.be|diode.zone|peertube.social" + videoFiles="mkv mp4 gif webm mpd" + audioFiles="mp3 flac" + imageFiles="png jpg jpeg" + + if echo "$imageFiles" | grep -q -w "$ext"; then + feh -q "$1" & disown + elif echo "$videoFiles" | grep -q -w "$ext"; then + mpv --really-quiet --pause --keep-open "$1" & disown + elif echo "$audioFiles" | grep -q -w "$ext"; then + # I like podcasts and the like to open on a small terminal + urxvtc -geometry 60x6 -e mpv --pause --keep-open "$1" & disown + elif echo "$@" | grep -q -E "$videoSites"; then + mpv --really-quiet --pause "$1" & disown + else + firefox --private-window "$1" > /dev/null 2>&1 & disown + fi + +And then you tell `newsboat` to use it like so: + + browser "/path/to/my/script/linkhandler.sh %u" + +## Images + +You can use [feh][12] to see links to images. It just works. + +It can also be used to set up your background image on simple window managers, +invoked from `.xinitrc` or `.xsession` + +## Videos (and streaming) + +A good alternative to watch videos and streaming on the browser is [mpv][13]. It +has integration with [youtube-dl][14] (which not only "understands" youtube +links, but many many more). With a bit of configuration you won't need the +browser for video any more. Here is my `~/.config/mpv/mpv.conf` + + # sound works better like this on OpenBSD + ao=sndio + # try gpu accelerated video + vo=gpu,xv + # full screen by default + fs=yes + # user agent ... because the web sucks. + user-agent="Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0" + # moarrr cache + cache=yes + cache-default=8192 + # no 4k monitor so limit to best 1080 + ytdl-format=bestvideo[height <= 1080]+bestaudio/best + # do not send that through the HE tunnel (ignore if you do not have this) + ytdl-raw-options=force-ipv4= + +Keep in mind that some streams might not work with mpv under OpenBSD (my OS of +choice). That's because `ffmpeg` does not come with DASH demuxing compiled in +by default. I sent a patch to the port maintainer some time ago. I hope it will +be commited soon. In the mean time contact me if you need that functionality +and I'll send you the patch and instructions. + +## Conclusion + +So those are the programs I use to try to stay away from the browser as much as +possible. If you have other alternatives or suggestions, contact me and I'll +add them here. + +--- +[1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1548973 +[2]: https://lynx.invisible-island.net/ +[3]: https://github.com/RadhiFadlillah/shiori +[4]: https://curl.haxx.se/ +[5]: https://www.gnu.org/software/wget/ +[6]: https://rarbg.com/ +[7]: https://torrentapi.org/ +[8]: https://metacpan.org/pod/Rarbg::torrentapi +[9]: https://transmissionbt.com/ +[10]: https://newsboat.org/ +[11]: https://tt-rss.org/ +[12]: https://feh.finalrewind.org/ +[13]: https://mpv.io/ +[14]: https://youtube-dl.org/ + +Last update: XXlastXX