Score:1

Getting the URL of the curent active tab in Firefox

lt flag
XYZ

I'm trying to write a script where I can run mpv [youtube link] to watch youtube videos. For this I would like to detect the current active tab on Firefox and fill in the youtube link with it in the script. I would also highly prefer if I could do this without a firefox extension (I want to minimize my fingerprintability -- not sure that's a real word).

So far I've written a script like this:

#! /bin/bash

currentURL=$(lz4jsoncat ~/.librewolf/*.default-default/sessionstore-backups/recovery.jsonlz4 |
jq -r ".windows[0].tabs |
sort_by(.lastAccessed)[-1] |
.entries[.index-1] |
.url")

mpv $currentURL

To clarify, lz4jsoncat is a small util from here that basically unpacks the firefox jsonlz4 file.

And while this works and it detects the current active tab, there's one big problem with it: there's a ~10 second delay, because it seems firefox has a delay in updating the session file, and that defeats the whole purpose of the script.

Is there a way to detect the current tab's url almost instantaneously through the terminal?

ec flag
**Welcome to the Ask Ubuntu community.** It appears that this question really isn't related to the Ubuntu OS, but instead a scripting issue. You may have better luck working with the [Unix & Linux community](https://unix.stackexchange.com/).
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.