tridactyl / tridactyl

A Vim-like interface for Firefox, inspired by Vimperator/Pentadactyl.
https://tridactyl.xyz
Other
5.16k stars 398 forks source link

Tridactyl doesn't work on framesets #2072

Open glacambre opened 4 years ago

glacambre commented 4 years ago

Tridactyl version: 1.17.1pre3355-6facf5d Firefox version: Mozilla Firefox 71.0 Operating system: linux

This can be reproduced on this site: http://wikibook-ada.sourceforge.net/html/index.html

Basically Tridactyl adds event listeners to all frames on load, but once you click (with normal mouse clicks or with hints) on a link that loads a new document, the event listeners for the frame the new document is loaded in are lost and so Tridactyl doesn't respond to keypresses anymore.

skeeto commented 3 years ago

I recently came across this frameset site that also doesn't work with Tridactyl: https://www.geoffchappell.com/

However, this one seems to be even worse since it doesn't require any initial action to break Tridactyl.

bovine3dom commented 3 years ago

Could be as simple as adding an onload to each of the frames https://stackoverflow.com/questions/29233928/iframe-onload-javascript-event

Similar to this: https://github.com/tridactyl/tridactyl/blob/73ef32497d6b1fc7975d703753eca63de69e8af6/src/content.ts#L88

I'd be worried about breaking sites that already had an onload function though, so we should probably only do it if it's empty.

Otherwise this would be fixed by #412.

glacambre commented 3 years ago

I'd be worried about breaking sites that already had an onload function though

No reason to worry about this, x-ray vision ensures we don't overwrite anything from the page. Moreover all .onXXX events have an equivalent way of creating events with .addEventListener("XXX", ...).

bovine3dom commented 3 years ago
diff --git a/src/content.ts b/src/content.ts
index abdd21c3..c977eb63 100644
--- a/src/content.ts
+++ b/src/content.ts
@@ -85,7 +85,10 @@ function listen(elem) {
 }
 listen(window)
 document.addEventListener("readystatechange", _ =>
-    getAllDocumentFrames().forEach(f => listen(f)),
+                                   getAllDocumentFrames().forEach(f => {
+                                       listen(f)
+                                       f.addEventListener("load",() => listen(f))
+                                   }),
 )

 // Prevent pages from automatically focusing elements on load

Couldn't get it to work like this, so more thought is needed.

FWIW, pressing <C-,> lets me use Tridactyl on both of those sites : )