Smile4ever / Double-Click-On-Page-Closes-Tab

Firefox extension - Double click on a page to close the current tab.
0 stars 0 forks source link

Feature request: only close tab when double-clicking on empty space #1

Closed odebroqueville closed 10 months ago

odebroqueville commented 5 years ago

Hi Geoffrey, I hope this message finds you well. I was looking at this review:

It works! The downside is that any double click (enlarging a map or highlighting a link) also closes the tab. If the sensitivity or the timing of the clicks could be adjusted it would be a really helpful extension. Sadly I had to disable it. Way too many tabs disappeared.

and also thought that it would be nice if default double-click behaviours (e.g. highlighting a word when double-clicking on text) weren't prevented. Maybe you could give your users the option to only close tabs when double-clicking on empty space on a web page.

Smile4ever commented 5 years ago

Thank you for your suggestion. I thought of this already, but I found it hard to implement.

However, I looked further and found https://stackoverflow.com/questions/34611711/how-to-detect-an-empty-space-on-a-web-page which suggests using https://html2canvas.hertzen.com/

This is possible, but requires some more work and investigation.

odebroqueville commented 5 years ago

Perhaps you can check the node type of e.target onclick. If it's different to text (3), then close the tab on next click(if e.clientX and e.clientY coordinates haven't changed) . https://www.w3schools.com/jsref/prop_node_nodetype.asp Although this isn't a full proof solution because it doesn't account for html elements (e.g. resizing of maps) where you wouldn't want to close tabs when double-clicking.

Smile4ever commented 5 years ago

The nodetype returns 1 (element) most of the time, so that's of no use.

You gave me an idea though. element.innerText == "" seems to cover a lot of cases where you want to close the tab.

odebroqueville commented 5 years ago

Sounds like the way to go. https://www.w3schools.com/jsref/prop_node_textcontent.asp

Smile4ever commented 5 years ago

I will try with textContent instead, but innerText doesn't cover all cases.