Print Own Code on $

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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.

You will need to install an extension such as Stylus to install this style.

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

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

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

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

// ==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);
})();