Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Not caching every text for some certain websites #138

Open
crnkv opened this issue Jan 6, 2025 · 3 comments
Open

[Bug] Not caching every text for some certain websites #138

crnkv opened this issue Jan 6, 2025 · 3 comments

Comments

@crnkv
Copy link
Contributor

crnkv commented Jan 6, 2025

If I understand the codes correctly, the new TextareaCache saves text-cache objects by a unique key `${sessionKey} ${url} ${id}`, so that newer contents of the same textarea simply overwrite older contents.

That's a good feature, but I'm afraid that there're exceptions.

Bilibili seems to be implementing a new UI design that re-use the same textarea element for different replies.

For example, if a userA and a userB have left their comments for a video, then I can see a "reply" button on each of their comments. By clicking the "reply" of userA, a textarea element shows up. After I write my comment and click "send", the textarea element disappears (becomes hidden). Then I click the "reply" of userB, the textarea element shows up again, with the text I wrote the last time. I'll have to clear it to write my comment for userB and click "send". As a result, TextareaCache only keeps the last piece of text.

To fix this (at least temporarily), I hope there'll be an option to switch back to the logic before - check all textarea and save all modifications of their contents.
(If that's too much, there's a better logic - overwrite older contents of the same textarea if and only if the older string is included in the newer string, otherwise save the newer content as well as the older one)

Required:

  • System OS: win10
  • Firefox version: firefox 133.0.3
  • Textarea Cache version: 4.10.2
@GHolk
Copy link
Collaborator

GHolk commented Jan 7, 2025

Interesting, but the old behavior will not fix this this issue.

@GHolk
Copy link
Collaborator

GHolk commented Jan 7, 2025

Maybe you can try to change the data-tc-id on every focusin event (or intervally) with greasemonkey or something else to by pass this issue.

I have no idea about how to deal with this issue.
Change the textarea-cache-id if the text's length change too much?

@crnkv
Copy link
Contributor Author

crnkv commented Jan 7, 2025

I, too, don't have a perfect solution.
Maybe, renew the cache-id when the content string is found to be empty (strip(save_info.val).length == 0) while there once was something (ta_database.get(`${tcl.sessionKey} ${location.href} ${event.target.dataset['tcId']}`) !== undefined).
Now that the saveToStorage method is called upon 'keyup' events, the cleanning-up-textarea-like changes should be able to be captured as expected.
I just hope people remember to delete their textarea contents before writing new comments on websites like Bilibili. Maybe add a remark in the addon's description string.
As for the side-effects (unwanted cases) on other websites, I guess it would be minor...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants