Отключение фильтра SD WebUI для коллаба

// ==UserScript==
// @name         SD Colab Filter Bypass
// @version      2023-06-08-2
// @description  Отключение фильтра Google Colab для StableDiffuison WebUI
// @namespace    https://2ch.hk/ai/
// @match        https://colab.research.google.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant        GM_xmlhttpRequest
// @run-at       document-start
// ==/UserScript==

const filterRegexp = /(?<=\[).*"stable-diffusion-webui".*(?=\])/;
const scriptNameRegexp = /external_polymer_binary.*\.js/;

window.addEventListener('beforescriptexecute', function(e) {
    const src = e.target.src;

    if (!scriptNameRegexp.test(src)) {
        return;
    }

    e.preventDefault();
    e.stopPropagation();

    GM_xmlhttpRequest({
        method: "GET",
        url: e.target.src,
        onload: function(response) {
            const text = response.responseText.replace(filterRegexp, '');

            const newScript = document.createElement('script');
            newScript.type = "text/javascript";
            newScript.textContent = text;

            const head = document.getElementsByTagName('head')[0];
            head.appendChild(newScript);
        }
    });
});
Edit
Pub: 02 Jun 2023 16:11 UTC
Edit: 08 Jun 2023 15:57 UTC
Views: 612