vimb icon indicating copy to clipboard operation
vimb copied to clipboard

url in window title

Open JJK96 opened this issue 7 years ago • 8 comments

Is it possible to have more control about what is shown in the window title, for example it would be useful to have the url of the current page in there so that keepass auto-type works better.

JJK96 avatar Jan 08 '18 20:01 JJK96

@JJK96 I've already thought about something like this to allow the user to configure seomthing like the set statusline in vim. How does the keepass auto-type work? And how does it communicate with vimb?

fanglingsu avatar Jan 10 '18 10:01 fanglingsu

Keepass looks at the title of a window (any window, not specifically vimb) and compares that to the data you have stored with the key. So for example if the title contains the word github it will enter your github password.

Now, some websites dont have a very descriptive title, something like "Log in", for those websites it would be useful to have the url in the title so that keepass can also compare that.

JJK96 avatar Jan 10 '18 10:01 JJK96

Sounds interesting! At the time you could change the title by hand (:e! document.title="The new title"), until we have a generic solution, so that the keepass can pick this up. I know that this is more a workaround, but with some key binding this is done really fast.

fanglingsu avatar Jan 10 '18 13:01 fanglingsu

thanks for the hint, I have found another solution, I placed

document.title+=' '+document.URL 

in scripts.js, which does exactly what I suggested.

edit: I just noticed that this does not work for when I open a page through a link. Is that intended behaviour?

JJK96 avatar Jan 10 '18 13:01 JJK96

Oh, this is even better. If you have vimb compiles with autocmd support, following should help you to do this automatically.

augroup titlechange
autocmd LoadFinished * e! document.title+=' '+document.URL;
augroup end

I think id does not work properly in scripts.js, because it's not ensured that the dom is available at the time the script is executed. But you might observe the dom:loaded event.

fanglingsu avatar Jan 10 '18 14:01 fanglingsu

That works even better indeed, I changd LoadFinished to LoadCommitted however

JJK96 avatar Jan 10 '18 15:01 JJK96

If LoadCommitted work, fine. But the LoadCommited might be fired before the DOM and the title are available.

fanglingsu avatar Jan 10 '18 15:01 fanglingsu

I noticed that indeed it did not go correctly for every website.

Thank you for your support, I think that this fixes my problem and any other problem where the title has to be edited.

JJK96 avatar Jan 10 '18 15:01 JJK96