Greasy Fork is available in English.

kib-key

Store API key

لا ينبغي أن لا يتم تثبيت هذا السكريت مباشرة. هو مكتبة لسكبتات لتشمل مع التوجيه الفوقية // @require https://update.greasyfork.org/scripts/479408/1277647/kib-key.js

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

const storeKey = (storageKey, scriptName) => {

    const display_status = (element) => {
        const key = localStorage.getItem(`${storageKey}-key`);
        let innerHTML = "";
        innerHTML += `<div>`;
        innerHTML += `<b>[${scriptName}]</b> API key used <span style="font-family: monospace; font-weight: bold;">${key}</span>`;
        if (key) {
            innerHTML += ` | Status <b id="${storageKey}-status" style="color: var(--default-green-color); font-weight: bold;">enabled</b>`;
            innerHTML += ` | Click <span id="${storageKey}-api-key-rm" class="t-blue" style="cursor: pointer;">here to disable</span> the script`;
        } else {
            innerHTML += ` | Status <b id="${storageKey}-status" style="color: var(--default-red-color); font-weight: bold;">disabled</b>`;
            innerHTML += ` | Click on a key to enable the script`;
        }
        innerHTML += `</div>`;
        innerHTML += `<div class="clear"></div>`;
        innerHTML += `<hr class="page-head-delimiter m-top10 m-bottom10">`;
        element.innerHTML = innerHTML;
    };

    waitFor(document, "div.preferences-container").then(div => {

        let injected = false;
        const display_element = document.createElement("div");
        div.insertAdjacentElement('beforebegin', display_element);

        // triggered by clicking on crimes tab
        const callback = (mutations, observer) => {
            [...mutations].forEach(mutation => {
                [...mutation.addedNodes].filter(n => n.className && n.className.includes("keyRow___")).forEach(node => {
                    const key_node = node.querySelector("input");
                    key_node.style.cursor = "pointer";
                });
            });
            if (!injected) {
                display_status(display_element);
                injected = true;
            }
        };
        const observer = new MutationObserver(callback);
        observer.observe(div, { childList: true, subtree: true });

        document.querySelector("div.content-wrapper").addEventListener('click', e => {
            const button = e.target;
            if (button.tagName == 'INPUT' && button.id.includes('key-row') && !localStorage.getItem(`${storageKey}-key`)) {
                localStorage.setItem(`${storageKey}-key`, button.value);
            }
            else if (button.tagName == 'SPAN' && button.id == `${storageKey}-api-key-rm`) {
                clearLocalStorage(`${storageKey}`)
            }
            display_status(display_element);
        });

    });
}