CleverTap session extender

Protects against irritating and dangerously short session inactivity timeouts, which can lead to losing progress when editing campaigns.

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         CleverTap session extender
// @version      1.0
// @description  Protects against irritating and dangerously short session inactivity timeouts, which can lead to losing progress when editing campaigns.
// @author       Christopher Orr <chris@website>
// @website      https://klima.com/
// @namespace    https://klima.com/
// @license      MIT
// @match        https://*.dashboard.clevertap.com/*
// @icon         https://www.google.com/s2/favicons?sz=128&domain=clevertap.com
// @run-at       document-idle
// @grant        GM_xmlhttpRequest
// @connect      self
// ==/UserScript==

(function() {
    'use strict';

    const cleverTapRefresh = () => {
        console.log('UserScript: Keeping CleverTap session alive in the background…');

        // Fetch the top-level URL every 5–10 minutes, i.e. much more often than the ~45-minute session inactivity timeout.
        // This redirects to the main dashboard page, and so should prolong the current logged-in session
        GM_xmlhttpRequest({ url: '/' });

        // Repeat so long as this tab is open
        const intervalMs = 5 * 60 * 1000;
        return setTimeout(cleverTapRefresh, intervalMs + (intervalMs * Math.random()));
    };

    cleverTapRefresh();
})();