Attempt to restore Tridactyl if document.open, write or writeln are called#5261
Attempt to restore Tridactyl if document.open, write or writeln are called#5261Chic-Tweetz wants to merge 7 commits into
Conversation
|
Thanks. One thing that is making me nervous is that we need to remember to put any future things we add to the page within this wrapper. Is there any kind of function we can make that wraps such calls and adds them to a kind of registry so that they get readded? then some linting rules to make sure we call that function? edit: i guess the wrapper would need to run at transpile time just in case the page got killed before they could first be called? |
|
Yeah I initially just wanted to call the existing A registry sounds good, most of the listening functions could be simply looped through and called. Readding the styles is a bit of a special case because they're originally inserted as part of the content script. I suppose the command line and status indicator could be added to a sort of element registry too? You're right that it won't work if the page is killed too soon... or would the whole content script just run blissfully unaware there was a document that died before? I'm not sure actually. Is there anything else in Tridactyl that has to run at transpile time? |
yeah, the it is more or less witchcraft, if it's too tricky we can just do it runtime like you're doing at the moment edit:
yeah, this is the sort of thing i was thinking about |
|
somehow this PR seems to break interaction with Tridactyl (e.g. j/k) on https://www.opensourcealternative.to/alternativesto/davinci-resolve (and presumably other next-js/react sites) which is the opposite of what I was expecting :) I thought maybe there was a small chance it would fix the commandline issue. |
|
oh dang really? I've been using a build with this PR (from before I added the basic registry stuff) and the changes from #5260 and it's still working for me. I may have broken something with those registry functions (I don't think I meant to push that yet actually...) |
|
i was surprised too - enough to check it three times :) I can try bisecting it when I get a chance but it's probably just your registry commits from what you're saying |
8764b11 to
faeebd8
Compare
faeebd8 to
1b695c7
Compare
|
I believe a conflict removed the lines which added the listener in content.ts to actually get the fix to work. In my haste I made an absolute mess with the commits here. I don't think this PR wants to try and change every file in the world now and #5260 should work again. I should note that although the registry functions exist, I haven't added any linter rules or made it clear what they're for. I'll change this to a draft for now :) |
Regarding #5259.
Some sites use the (deprecated)
document.open/document.write/document.writelnfunctions which create entirely newdocumentobjects. Event listeners and elements are consequently lost.This hijacks those functions to
dispatch an eventcall an exported function before thedocumentis replaced, allowing us to readd listeners, the commandline and status indicator.I'm not sure that I've found every listener which needs re-listening.
This also assumes that
document.closewill be promptly called, as that's when everything will be readded.