Mini-coding adventure: Explorations with a command line browser
2025-03-03
So last weekend I was a bit tired of the internet. Which will probably be another post at some point. But suffice it to say that the invasive tracking browsers are up to just turns my stomach.
Which lead me back to an old desire of mine, building my own web browser. I've never gotten very far. Browsers are so very very complex and as soon as I get started I get overwhelmed. So maybe instead of tackling something so gargantuan, I start a bit smaller.
That lead me down a rabbit hole of text-based browsers. The one that struck me the most was Offpunk[1]. I liked how it incorporated feeds, the simple text interface, and the concept of offline first. Which got me thinking.... What could I pull off in a couple of hours?
Deno has some libraries to help with a command line tool. I ended up grabbing deno-cliffy[2] to start. I ran into some issues with getting it to import but eventually figured out that running deno add jsr:@cliffy/command@^1.0.0-rc.7 worked instead of using the import in the main.js file.
Now that was situated I grabbed an rss parser and a feed from a blog I enjoyed. I did a quick fetch to grab the feed and then parsed it using the tool.
Turns of cliffy lets you pass in a list of suggestions with a paging interface. Sweet...
const xml = await response.text();
const feed = await parseFeed(xml);
const postSelection = await Input.prompt({
message: "Choose a post",
info: true,
list: true,
maxRows: 20,
suggestions: feed.entries.map(f => f.title.value)
});
[3]
As you can see, the list of items in the RSS feed are displayed and you can type/filter down to the one you want to view.
Once selected I fetched the actual post.
But displaying a bunch of HTML on the command line isn't my idea of a good reading experience.
That where another library came in html-to-text from npm[4]
A little bit of configuration later and I have....
[5]
Which is actually pretty nice to read. The big drawback is I don't have paging and I find scrolling up on the command line to be distracting. Maybe I could pipe it to less or something.
Where to next?
I thought this was a nice and quick proof of concept that building something out like a text-based browser could be in my grasp (assuming I'm sticking to just getting text and not having to support forms)
But that doesn't solve... I want my cool new browser on my android phone.
And I also want it without using web-view anything. My trust in the browser is waning. That strikes out almost all of the javascript -> cross platform apps tools.
Deno included.
Little Side Quest
There is a SDL2 deno[6] project that I found in my quest to see if Deno could do desktop apps. The documentation is a bit poor and it took some major head scratching to get the dependencies squared away on Windows. But I was able to get a little "Hello World" up and running
[7]
Some idle thoughts
I do want to pursue this browser idea a bit further. I recently got the cross platform GUI library python Kivy[8] up and running with a little test project. I may pull out my little idea sketchbook and see what I can come up with. What could a browser be... if we didn't use the current browser kings as a blueprint?
Could RSS reign supreme? Bookmarks and link graphs?
Dear reader, have you ever thought about it?
=^..^= =^..^= =^..^= =^..^= =^..^= =^..^= =^..^=
You can always strike up a conversation if you would like, You should try:
Yours truly, Loura 👩🚀