atcoder-keyboard-shortcuts

atcoder keyboard shortcuts

اعتبارا من 11-03-2020. شاهد أحدث إصدار.

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 or Violentmonkey 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 لتثبيت هذا النمط.

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

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

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

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

// ==UserScript==
// @name         atcoder-keyboard-shortcuts
// @namespace    https://halmk.github.io/
// @version      0.1
// @description  atcoder keyboard shortcuts
// @author       springroll
// @match        https://atcoder.jp/contests/*/tasks/*
// @grant         none
// @require       https://unpkg.com/hotkeys-js/dist/hotkeys.min.js
// ==/UserScript==

(function() {
    'use strict';
    var copySample = function(index) {
        window.getSelection().removeAllRanges();
        try {
            var range = document.createRange();
            range.selectNode($('#pre-sample'+(2*(index-1))).get(0));
            window.getSelection().addRange(range);
            document.execCommand('copy');
        } catch (err) {
            console.log(err);
        }
        alert("Copied Sample" + index + ".");
        window.getSelection().removeAllRanges();
    }
    hotkeys('shift+1,shift+2,shift+3,shift+4,shift+5', function (event, handler){
        switch (handler.key) {
            case 'shift+1':
                copySample(1);
                break;
            case 'shift+2':
                copySample(2);
                break;
            case 'shift+3':
                copySample(3);
                break;
            case 'shift+4':
                copySample(4);
                break;
            case 'shift+5':
                copySample(5);
                break;
            default: alert(event);
        }
    });

})();