Is there a way to sync from the browser console?

During the app development, I want to quickly sync the changes I have made to the configuration. For that, I need to go to the menu and click on Sync now.

Is there any command that I can run on the browser console which triggers the sync?

@binod - this is a bit of a hack, but this worked for me:

document.getElementById("header-dropdown").children[6].children[0].click(); 

The reason it is a hack is it is brittle so when the DOM changes, this won’t work. However, for now - you should be good to go!

Here it is in action:

1 Like

Thank you, @mrjones!
The magic number for me was 13, but it worked! It will save me a couple of clicks. The best part is that it also works in the mobile view where the menu button is not even visible.

@binod - happy that worked for you!

But, it sounds like it already broke for you and you had to specify a different child element? Can you let us know which was your specific click() call? If we do a little more prototyping, I suspect we can get it working in which it is more flexible based on different DOMs!

This is what worked for me:
document.getElementById("header-dropdown").children[13].children[0].click();

However, it does not work right away. It starts working only after I have opened the menu once. I don’t have to keep the menu open though.

Aha! The reason the index is lower for me is that 4.1 moved the sync to the top, away from “Log out”.

With this in mind, we can be a little more flexible (but not a lot, b/c we’re still tightly coupled to the DOM here). We can “initialize” things by clicking the hamburger menu. You only need to do this once per session:

document.getElementById("header-dropdown-link").click();

Now that the menu is in the DOM (and currently showing), you should be able to call this when ever you need to sync. By coupling it to the fa-refresh class, of which there’s only one in the DOM, we gain the flexibility of it being anywhere on the page:

document.getElementsByClassName("fa-refresh")[0].click();

Again - this will likely break in the future, but I successfully tested this on 3.17, 4.0.1 and 4.1.0 so if you’re in those versions, it should work for you! I did a spot check and 3.9 doesn’t work with this (but we could adapt it easily enough!)

1 Like