KeyLogger

    @@ -11,10 +11,10 @@ window.__KeyLogger_finish(); return; } - let events = ['timestamp\tkey\tcode\tkeyCode\ttarget']; + let events = ['timestamp (JST)\tkey\tcode\tkeyCode\ttarget']; const listener = e => { if (e.isComposing || e.repeat || ['Control','Shift','Alt','Meta'].includes(e.key)) return; - const ts = new Date().toLocaleString('ja-JP', { hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' }); + const ts = new Date().toLocaleString('ja-JP', { timeZone: 'Asia/Tokyo', hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' }); const shortStr = [e.ctrlKey && 'Ctrl', e.shiftKey && 'Shift', e.altKey && 'Alt', e.metaKey && 'Meta', e.key].filter(x => x).join('+'); events.push([ts, shortStr, e.code, e.keyCode, e.target.localName].join('\t')); };
  • /*
     * @title KeyLogger
     * @description Simple Key Logger (w/o modifiers, composition)
     * @include http://*
     * @license MIT License
     * @javascript_url 
     */
    
    (() => {
      if (window.__KeyLogger_finish) {
        window.__KeyLogger_finish();
        return;
      }
      let events = ['timestamp (JST)\tkey\tcode\tkeyCode\ttarget'];
      const listener = e => {
        if (e.isComposing || e.repeat || ['Control','Shift','Alt','Meta'].includes(e.key)) return;
        const ts = new Date().toLocaleString('ja-JP', { timeZone: 'Asia/Tokyo', hour12: false, year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' });
        const shortStr = [e.ctrlKey && 'Ctrl', e.shiftKey && 'Shift', e.altKey && 'Alt', e.metaKey && 'Meta', e.key].filter(x => x).join('+');
        events.push([ts, shortStr, e.code, e.keyCode, e.target.localName].join('\t'));
      };
      window.addEventListener('keydown', listener, { capture: true });
      window.__KeyLogger_finish = () => {
        window.removeEventListener('keydown', listener, { capture: true });
        const resultdoc = window.open().document;
        const resultarea = resultdoc.body.appendChild(resultdoc.createElement('textarea'));
        resultarea.style = 'position: fixed; width: 100%; height: 100%; top: 0; left: 0;';
        resultarea.textContent = `---- 押されたキー ----\n${events.join('\n')}\n---- 環境情報 ----\nURL: ${location.href}\n環境: ${navigator.userAgent}`;
        delete window.__KeyLogger_finish;
      };
      alert('このページで押されたキーの記録を開始しました。記録結果を表示するにはもう一度このブックマークレットを実行してください。');
    })();
  • Permalink
    このページへの個別リンクです。
    RAW
    書かれたコードへの直接のリンクです。
    Packed
    文字列が圧縮された書かれたコードへのリンクです。
    Userscript
    Greasemonkey 等で利用する場合の .user.js へのリンクです。
    Loader
    @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
    Metadata
    コード中にコメントで @xxx と書かれたメタデータの JSON です。

History

  1. 2021/06/16 22:29:28 - 2021-06-16
  2. 2021/06/16 22:16:39 - 2021-06-16
  3. 2021/06/16 22:14:06 - 2021-06-16
  4. 2021/06/16 22:11:46 - 2021-06-16
  5. 2021/06/16 22:09:58 - 2021-06-16
  6. 2021/06/16 21:52:53 - 2021-06-16
  7. 2021/06/16 21:21:23 - 2021-06-16
  8. 2021/06/16 21:17:55 - 2021-06-16
  9. 2021/06/16 21:15:27 - 2021-06-16