me.fier.gawk/user/addon/history/_main.py

29 lines
675 B
Python

import os
eventHandler = mfp.Bunch()
browser = mfp.require("browser")
config = mfp.require("config")
if not os.path.isdir(config.paths[0]):
try:
os.makedirs(config.paths[0])
except Exception: pass
fh = open(os.path.join(config.paths[0],"history.txt"),"a")
def onUrlChanged(obj,_):
url = obj.get_uri()
if url == None: return
fh.write("\n" + url)
fh.flush()
def onTitleChanged(obj,_):
url = obj.get_uri()
if url == None: return
fh.write("\n" + url + " " + obj.get_title())
fh.flush()
def onWebviewCreated(webView):
webView.connect("notify::title",onTitleChanged)
webView.connect("notify::uri",onUrlChanged)
eventHandler["webview:created"] = onWebviewCreated