Extra keyboard shortcuts for Kanka Entities.

Adds keyboard shortcuts

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Extra keyboard shortcuts for Kanka Entities.
// @namespace    http://tampermonkey.net/
// @license      MIT
// @version      0.4
// @description  Adds keyboard shortcuts 
// @author       Idealien
// @match        https://app.kanka.io/*/entities/*
// @icon         https://www.google.com/s2/favicons?domain=kanka.io
// ==/UserScript==

/* Usage:
 * p = New Post
 * f = Edit First Post
 */
 
document.onkeyup = function(e) {
    var key = e.which || e.keyCode;
    //console.log('KEY Pressed: ' + key );

    // p = New Post
    if ( key == 80  && document.querySelector(".row-add-note-button .btn-new-post") ) {
        document.querySelector(".row-add-note-button .btn-new-post").click();
    }
    // f = Edit First Post
    if ( key == 70 ) {
        // Special case if the entry is not the first block
        if ( document.querySelector(".post-block.post-position--1") ) {
            document.querySelector('.post-block.post-position--1 .dropdown-menu a').click();
        }
        else if ( document.querySelector(".post-block.post-position-1") ) {
            document.querySelector('.post-block.post-position-1 .dropdown-menu a').click();
        }
    }
}