F12は使わせて!!

    
      
  • /*
     * @title F12は使わせて!!
     * @description [F12]ほか制限されている幾つかのキー操作を可能に
     * @include http://*
     * @include https://*
     * @license MIT License
     * @require 
     * @javascript_url
     */
    
    ( () => {
    const
        allowd_keycode_map = {
            122 : { // F11
                combinations : []
            },
            123 : { // F12
                combinations : []
            },
            68 : { // D
                combinations : [ 'altKey', ]
            },
            69 : { // E
                combinations : [ 'ctrlKey', ]
            },
            76 : { // L
                combinations : [ 'ctrlKey', 'metaKey', ]
            },
        },
        
        on_key_event = ( event ) => {
            if ( ( event.isComposing ) || ( event.keyCode == 229 ) ) {
                // IME入力中は無視
                return;
            }
            
            let allowd_key_info = allowd_keycode_map[ event.keyCode ];
            
            if ( ! allowd_key_info ) {
                return;
            }
            
            let combinations = allowd_key_info.combinations || [];
            
            if ( 0 < combinations.length ) {
                let match_number = combinations.filter( key_names => {
                        if ( typeof key_names == 'string' ) {
                            key_names = [ key_names ];
                        }
                        
                        return key_names.length == key_names.filter( key_name => event[ key_name ] ).length;
                    } ).length;
                
                if ( match_number < 1 ) {
                    return;
                }
            }
            event.stopPropagation();
        };
        
    document.addEventListener( 'keydown', on_key_event, true );
    document.addEventListener( 'keyup', on_key_event, true );
    
    } )();
    
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2020/04/14 22:44:20 - 2020-04-14
  2. 2020/04/14 22:40:50 - 2020-04-14
  3. 2020/04/09 22:08:02 - 2020-04-09
  4. 2020/04/09 22:05:57 - 2020-04-09
  5. 2020/04/09 21:48:28 - 2020-04-09
  6. 2020/04/09 20:59:50 - 2020-04-09
  7. 2020/04/07 20:24:29 - 2020-04-07
  8. 2020/04/07 20:16:16 - 2020-04-07