You are viewing a single comment's thread from:

RE: Programming Diary #26: Displaying voting power on Steemit.com and other condenser sites

in #javascript2 months ago

Thanks for the mention and processing.

I tested your version ... and then adapted it a little. :-)

I had noticed that you called the modifyUserElement function with every mutation. That was a bit much and should be stopped. So I added a check so that the function is only called if it is the element we need. I also passed it to the function so that we don't have to search for it again.

Also, you had the call to highLight in both the then and else branches, which wasn't necessary. I have now placed the call outside the mutation loop so that the function is not executed for every mutated element.

I have also removed my test API node again. It shouldn't actually be there. :-)

I made a PR on your fix-branch. So you can merge it.
https://github.com/remlaps/Steem-Curation-Extension/pull/4

This cooperation is fun... and makes me want more :-)

Sort:  

Nice. The mutation observer is very-much improved. I knew it was checking too much, but my main focus was on getting rid of the event handlers. I'm glad you took the next step and cleaned it up. Thank you.

I have also removed my test API node again. It shouldn't actually be there. :-)

I'm actually not sure if any of those host permissions are necessary at all... I don't remember when or why I put them in there, but when I remove that whole section, it seems to keep working without issue. Is that section needed for Firefox?

I can't really finish testing right now 'cause Steemit seems to be having site issues, but maybe I'll take a look at removing that block in manifest.json(?). In any case, I think SteemWorld is the only one that would be in active use at this point.

This cooperation is fun... and makes me want more :-)

I totally agree. Thanks again!

Is that section needed for Firefox?

The host_permissions should ensure that the fetching of data from these sources is permitted. The servers used should therefore be included there.
However, there is a difference between Firefox and Chrome. Firefox complains about violation of CORS guidelines, while Chrome runs the extension without any problems.
I've just thought of something I need to check.

Something else occurred to me this morning: We don't actually need the mutation loop at all. When mutations are done, we can only look for the usermenuDropdown element and continue working with it if it exists. We don't have to go through the individual mutations at all.

By the way, I actually wanted to write yesterday that the idea of the MutationOberserver was very brilliant!
What I forgot yesterday at a late hour: The disconnect should not be done, otherwise the MutationOberserver will not register the changes when logging off and on again.

Update:
Firefox cannot be persuaded to ignore the CORS policies of the Condenser for the extension. I will add the domain sds.steemworld.org to the CORS policies on my server next time.

I merged your changes into my branch the other day, and then merged into main tonight. Thank you very much. The solution without looping is a huge improvement!

By the way, I actually wanted to write yesterday that the idea of the MutationOberserver was very brilliant!

I wish I could take credit, but it came from one of the AIs. Claude, I think, but maybe ChatGPT. I didn't even know that mutation observers existed before that. My part was just stumbling into the right question. ;-)

The host_permissions should ensure that the fetching of data from these sources is permitted.

Yeah, that's how I understood it, but my browser doesn't seem to care whether those settings are actually there or not. I left them in, and added justyy's load balancer, too - just in case we want to use them later. I'm still not clear on why it doesn't really seem to be needed in Brave, though.