Auto Reload Every X Seconds

Perform auto reload on nocodb table

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

You will need to install an extension such as Tampermonkey to install this script.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Auto Reload Every X Seconds
// @namespace    https://udun.mordorintelligence.com
// @version      0.2
// @description  Perform auto reload on nocodb table
// @author       Rishabh Nishad
// @match        https://udun.mordorintelligence.com/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license      MIT
// ==/UserScript==

const delayToAutoReloadInMilliseconds = 60*1000;
const reloadCSSSelector = 'div.ml-1:nth-child(6) > svg.nc-icon';

setInterval(performReloadClick, delayToAutoReloadInMilliseconds);

async function performReloadClick() {

      if(!/https:\/\/udun\.mordorintelligence\.com\/dashboard\/.*\/.*\/.*\/.*/igm.test(window.location.href)) return;

      await waitForElement(reloadCSSSelector);
      //console.log('Reload icon is ready');

      var divElement = document.querySelector(reloadCSSSelector);

      if(!divElement) return;
      //console.log("divElement",divElement);


        var clickEvent = new Event('click');
        divElement.dispatchEvent(clickEvent);
        //console.log("Clicked Reload");

}




function waitForElement(selector) {
    return new Promise(resolve => {
        if (document.querySelector(selector)) {
            return resolve(document.querySelector(selector));
        }

        const observer = new MutationObserver(mutations => {
            if (document.querySelector(selector)) {
                observer.disconnect();
                resolve(document.querySelector(selector));
            }
        });

        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });
}