0

I want to send command via some messenger's api bot (for example telegram bot) and get response with specific tab(link to some site) but i don't know how to realize that part about taking out firefox tabs

Is there any not so sophisticated way to do it? Please give some advise and sorry if it's a dumb question.Thanks in advance.

1
  • Welcome to AskUbuntu! Please, develop a bit more your question so your problem can be understood easily.
    – 0x2b3bfa0
    Sep 1, 2018 at 20:24

1 Answer 1

1

You can use Python to accomplish this task by this rather inelegant solution:


#!/usr/bin/env python3

"""
Copyright (c) 2018 Helio Machado <0x2b3bfa0>

This program is free software: you can redistribute it and/or modify  
it under the terms of the GNU General Public License as published by  
the Free Software Foundation, version 3.

This program is distributed in the hope that it will be useful, but 
WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
General Public License for more details.

You should have received a copy of the GNU General Public License 
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""

import json
from pathlib import Path
from lz4.block import decompress


def load_recovery(path):
    """
    Loads the recovery.jsonlz4 file from the path specified and
    parses the json data to a native structure. This file contains
    the current tabs of the browser.
    """
    with open(str(path), "rb") as recovery_file:
        assert recovery_file.read(8) == b"mozLz40\0"
        compressed_data = recovery_file.read()
    json_data = decompress(compressed_data)
    recovery = json.loads(json_data.decode())
    return recovery


def recovery_path():
    """
    Get the path to the recovery.jsonlz4 file.
    """
    firefox_path = Path.home() / ".mozilla" / "firefox"
    profile_path = list(firefox_path.glob("*.default"))[0]
    session_path = profile_path / "sessionstore-backups"
    return session_path / "recovery.jsonlz4"


windows = load_recovery(recovery_path())["_closedWindows"]
tabs = [tab for window in windows for tab in window["tabs"]]
urls = [tab["entries"][0]["originalURI"] for tab in tabs]

# Here you go!
print("\n".join(urls))

License: GPLv2


This should be a good start point; even if your question is not as dumb as you may suppose, I think that you should try a bit harder at finding solutions and post your research results along with the question.

I'll leave the question unmaintaned and as Community Wiki.

Not the answer you're looking for? Browse other questions tagged .