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

Feat bolden newly added text nodes on dynamic sites automatically #107

Merged
merged 7 commits into from
Jun 3, 2022

Conversation

asieduernest12
Copy link
Collaborator

@asieduernest12 asieduernest12 commented Jun 1, 2022

you can verify this on sites such as
youtube.com
angular.io
reactjs.com

open any of the links above and have toggle on then navigate around, new pages elements loaded dynamically should have all their text nodes bold-end.

fix #92

sites like facebook, twitter and angular.io insert new elemnts into the dom try while a user interacts with the site which previously were not boldend resulting in all new text looking plain. This new feature now watches the dom tree for new text nodes through the observer and boldens them accordingly
@asieduernest12 asieduernest12 requested review from X140Yu and ansh June 1, 2022 05:14
@asieduernest12
Copy link
Collaborator Author

also fixes #8

Copy link
Contributor

@X140Yu X140Yu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on this branch, and it works pretty nice!

src/ContentScript/observer.js Outdated Show resolved Hide resolved
src/ContentScript/observer.js Outdated Show resolved Hide resolved
src/ContentScript/observer.js Outdated Show resolved Hide resolved
@X140Yu
Copy link
Contributor

X140Yu commented Jun 1, 2022

Found a weird bug in https://duckduckgo.com/?q=youtube&t=h_&ia=web

Screen.Recording.2022-06-02.at.00.14.58.mov

@ansh
Copy link
Owner

ansh commented Jun 1, 2022

This works pretty well!

Facing the same bug as @X140Yu though.

@asieduernest12
Copy link
Collaborator Author

@ansh @X140Yu the duckduckgo bug exist on build 0.0.3. duckduckgo must have some implementation that inserts text into specific elements when the element has no text present in it.
their logic and ours is causing a infinite loop behaviour where we wrap the text of elements in br-span
from my guess; their code finds no text node in the span and re-inserts the text value again

our mutation observer will also execute when the dom changes and looks for text nodes not in a br-span, br-bold or br-fixation

and wraps any new text nodes into br-spans

this then causes duckduckgo's code to assume the element has no text and reinsert the text again

mostly happens when the element is hovered.

i can't find a trivial fix so presently i suggest we warn users about the behaviour and keep a ticket open for it separately.

@paxelpixel
Copy link
Contributor

I can replicate on build 0.0.3 too. I tried inserting a random text node next to the br span and it still inserted the text value again. so its not just looking for a text node. its actually looks like its doing some diffing of the value and if it doesnt match the state, it inserts that text node value again.

very interesting problem.

@ansh
Copy link
Owner

ansh commented Jun 3, 2022

@asieduernest12 I agree let's merge this PR but keep an issue open as we research it.

@asieduernest12 asieduernest12 merged commit 2f1d48c into ansh:master Jun 3, 2022
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

Successfully merging this pull request may close these issues.

elements added dynamically after first run of br bolding are not bollded
4 participants