Cache Clear Link

/cache-clear

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name         Cache Clear Link
// @namespace    cache clear
// @version      1.2
// @description  /cache-clear
// @match        *://*/*
// @grant        none
// @license     MIT
// @author      Samuel Araújo
// @icon        https://www.tiptip.pt/public/img/iconTiptip.png
// @description corre rota de cache-clear
// ==/UserScript==


(function () {
  if (window.top !== window.self) return;

  if (window.top.__clearCacheButtonInjected) return;
  window.top.__clearCacheButtonInjected = true;

  const originalUrl = location.href;

  const link = document.createElement('a');
  link.id = 'clear-cache-link';
  link.href = '#';
  link.textContent = 'clear';
  Object.assign(link.style, {
    position: 'fixed',
    bottom: '20px',
    left: '0px',
    zIndex: '9999',
    padding: '3px 6px',
    background: '#f00',
    color: '#fff',
    textDecoration: 'none',
    borderRadius: '4px',
    fontSize: '10px',
  });

  link.addEventListener('click', function (e) {
    e.preventDefault();

    fetch(`${location.origin}/cache-clear`)
      .then(() => {
        location.href = originalUrl;
      })
      .catch(() => {
        location.href = originalUrl;
      });
  });

  window.top.document.documentElement.appendChild(link);
})();