Skip to content

Instantly share code, notes, and snippets.

@cyio
Last active September 9, 2015 07:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyio/9daacb0e2e8bdaa97c98 to your computer and use it in GitHub Desktop.
Save cyio/9daacb0e2e8bdaa97c98 to your computer and use it in GitHub Desktop.
【用户脚本】为印象笔记网页版添加“插入待办事项”的快捷键

支持在印象笔记中,按快捷键(ctrl-alt-k)插入待办事项

原作者:Jason Stillwell
经由Oaker修改,支持印象笔记。根据本脚本,也可为其它编辑功能绑定快捷键。

// ==UserScript==
// @name Checkbox Shortcut For Yinxiang
// @namespace http://github.com/cyio
// @version 0.1
// @description Adds a shortcut (ctrl-alt-k) to create a checkbox in the note.
// @author Jason Stillwell
// @author Oaker
// @description 支持在印象笔记中,按快捷键(ctrl-alt-k)插入待办事项
// @match https://app.yinxiang.com/*
// @grant unsafeWindow
// ==/UserScript==
var str = window.location.href
// var checkbox_class = 'GEFR-03HYE';
var checkbox_class = 'GIK1NLCDF-E'
var iframe_id
if (/view\/notebook/.test(str)) {
iframe_id = 'entinymce_83_ifr';
}else{
iframe_id = 'entinymce_677_ifr';
}
function TM_Retry() {
window.setTimeout(TM_Wait,100);
}
function TM_Wait() {
if(typeof unsafeWindow.jQuery == 'undefined') {
TM_Retry();
return;
}
var $ = unsafeWindow.jQuery;
var ifr = $('#' + iframe_id);
if(ifr.size() == 0) {
TM_Retry();
return;
}
ifr.contents().keydown(function(evt){
if (evt.keyCode==75 && evt.altKey && evt.ctrlKey){
evt.preventDefault();
$("." + checkbox_class)[0].click();
}
});
}
TM_Wait();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment