支持在印象笔记中,按快捷键(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(); |