Greasy Fork is available in English.

Print Own Code on $

Print the code of this user script when you press the $ key

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
// ==UserScript==
// @name         Print Own Code on $
// @namespace    your-namespace
// @version      1.0
// @description  Print the code of this user script when you press the $ key
// @match        *://*/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Function to print the script code
    function printScriptCode() {
        const scriptElements = document.querySelectorAll('script');
        for (const script of scriptElements) {
            if (script.src === '' && script.textContent.includes('// ==UserScript==')) {
                console.log(script.textContent);
            }
        }
    }

    // Function to handle the keyboard event
    function handleKeyPress(event) {
        if (event.key === '$') {
            printScriptCode();
        }
    }

    // Add a keyboard event listener
    document.addEventListener('keydown', handleKeyPress);
})();