How to Inject JavaScript in Web Page to Automatically Hit Refresh Button

37
October 15, 2021, at 07:20 AM

I want to update the given dataset every 1 min. ideally, so far I've understood the best scenario is either every 1h or every 15min from Power BI. I've noticed, however, that if I click the 'refresh now' button in my workspace, then subsequently the respective dashboard and report will get updated every single time that button is hit!-although those pages need to be reloaded, this could be solved with tools like the Auto Refresh Plus extension that can do the job.

Hence, is there a way to embed JavaScript in the webpage of the screenshot below, that will automatically click the 'refresh now' button every e.g. 1min? The 'refresh now' button is just left to the 'Dataset' in the grey frame (it cannot be seen due to screenshot), right of the 'test_rig_dashboard'.

The most similar approach I've researched is this with the following JavaScript insertion:

javascript:if(window.autoRefreshInterval) { clearInterval(window.autoRefreshInterval); };
window.autoRefreshInterval = setInterval(function() { jQuery(".refresh").click(); },60000)

Any ideas on how can that be implemented here? I appreciate any help!

Answer 1
  • Right-click on element of interest and click "Inspect". Should open your browser dev tools where you can see something like this.
  • Right-click on the element's corresponding html and click "Add Attribute", then add an id attribute making sure it doesn't already exist. Your element should now look like this.
  • To verify that your element can now be selected, go to the console tab of the dev tools and use the document.getElementById() method.
  • Finally, use the click() method of your selection inside a setInterval() to simulate clicking on the element periodically like this. The second parameter is time in milliseconds, so in your case it should amount to 60*1000.
READ ALSO
How to handle duplicate dates in dates ranges in python

How to handle duplicate dates in dates ranges in python

Imagine an employee that has worked for different companies and you want to know how many months he worked for each companyThe problem is that he may have worked for two companies, overlapping some time (case of companies D and C)

53
Add foldable sections to HTML email?

Add foldable sections to HTML email?

When looking for how webpages can make foldable sections, usually they dive straight into JavaScript and customizing the design

45
Cannot load drawable in image view Android Studio

Cannot load drawable in image view Android Studio

I am trying to capture a url from a EditText, download the image with that url and set it to an ImageViewI don't know why but it doesn't show any image when I run the program

75
React Framer-motion: Trying to add animation based on navigating back or forward

React Framer-motion: Trying to add animation based on navigating back or forward

I have made a replica of my component in the code sandbox link below:

61