Created
May 1, 2023 08:43
-
-
Save yuki2021/5ca6c1f7470cf63a5b771378b5138e54 to your computer and use it in GitHub Desktop.
Tampermonkeyにて、Scrapboxの日記ページを開くためのUserScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name scrapbox_open_diary | |
// @version 1.0 | |
// @description Scrapboxでその日の日付の日記ページを開く | |
// @author yuki2021 | |
// @match https://scrapbox.io/* | |
// ==/UserScript== | |
var optDown = false; | |
document.addEventListener('keydown', function(event) { | |
// Option + Oが押された時はその日の日記ページを開く | |
if (event.altKey && event.code === 'KeyO') { | |
var d = new Date(); | |
var year = d.getFullYear(); | |
var dt = d.getDate(); | |
var month = d.getMonth() + 1; | |
var date = [ | |
year, | |
('00' + month).slice(-2), | |
('00' + dt).slice(-2) | |
]; | |
var title = date.join('/'); | |
var scrapboxProject = location.href.match(/scrapbox.io\/([^\/.]*)/)[1]; | |
var scrapboxUrl = 'https://scrapbox.io/' + scrapboxProject + '/' + encodeURIComponent(title); | |
// 今現在の時刻をbodyに入れる | |
var now = new Date(); | |
var hour = now.getHours(); | |
var minute = now.getMinutes(); | |
var second = now.getSeconds(); | |
var body = encodeURIComponent('\t' + date.join('/') + ' ' + hour + ':' + minute + ':' + second); | |
window.open(scrapboxUrl + '?body=' + body); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment