在B站笔记中,时间戳快捷键:Ctrl+←,截图+时间戳快捷键:Ctrl+↓,截图快捷键:Ctrl+→,打开笔记快捷键:Ctrl+↑
目前為
// ==UserScript==
// @name B站笔记快捷键←↓→
// @namespace indefined
// @version 1.7
// @description 在B站笔记中,时间戳快捷键:Ctrl+←,截图+时间戳快捷键:Ctrl+↓,截图快捷键:Ctrl+→,打开笔记快捷键:Ctrl+↑
// @author 大王鹅鹅鹅
// @match http*://www.bilibili.com/video/*
// @icon https://static.hdslb.com/images/favicon.ico
// @grant none
// @license AGPL License
// ==/UserScript==
(function() {
'use strict';
// JS监听键盘快捷键事件
document.addEventListener('keydown', function (event)
{
if (event.ctrlKey && event.keyCode == 37) {//时间戳——快捷键:Ctrl+←
document.querySelector('i.bili-note-iconfont.iconicon_flag_L').click();
setTimeout( function(){
document.querySelector('div.dialog-btn.tag-dialog__btn--confirm:nth-child(2)').click();
}, 5 * 100 );
};
if (event.ctrlKey && event.keyCode == 38) {//打开笔记——快捷键:Ctrl+↑
document.querySelector('div.note-btn.note-btn__blue:nth-child(2)').click();
document.querySelector('div.note-list-footer > div.note-list-btn').click()
};
if (event.ctrlKey && event.keyCode == 39) {//截图——快捷键:Ctrl+→
document.querySelector('i.bili-note-iconfont.iconcapture-app').click();
};
if (event.ctrlKey && event.keyCode == 40) {//截图+时间戳——快捷键:Ctrl+↓
document.querySelector('i.bili-note-iconfont.iconcapture-app').click();
new Promise((resolve,reject)=>{
document.querySelector('i.bili-note-iconfont.iconicon_flag_L').click();
return resolve();
}).then(()=>{
setTimeout( function(){
document.querySelector('div.dialog-btn.tag-dialog__btn--confirm:nth-child(2)').click();
var parentNode=document.querySelector('div.editor-innter.ql-container.ql-snow > div.ql-editor');
var childN=parentNode.childNodes;
for(var i=0;childN.length;i++){
if(childN[i].innerHTML=="<br>" && childN[i].nextSibling.innerHTML!="<br>" && childN[i].nextSibling.nodeName == "P" && childN[i].previousSibling.nodeName == "DIV"){
childN[i].remove();
}
}
},1500);
});
};
});
})();