日記ボタンを追加するUserScript
/customize/週記のページを開く/なければ作成するボタン
より改変
code:script.js
(function() {
// ボタンのスタイル
const buttonStyle = {
position: 'fixed',
bottom: '20px',
right: '10px',
width: '80px',
height: '80px',
backgroundColor: '#000000',
'border-radius': '50%',
color: 'black',
fontSize: '16px',
cursor: 'pointer',
'z-index': '2',
};
// ボタン要素を作成
const button = document.createElement('button');
button.textContent = '日記';
button.style.cssText = Object.keys(buttonStyle).map(key => ${key}: ${buttonStyle[key]}).join(';');
// ボタンクリック時の処理
button.addEventListener('click', () => {
//console.log("hogehoge");
/* 今日の日付 */
const now = new Date()
const year = now.getFullYear()
const month = ('0' + (now.getMonth()+1)).slice(-2)
const day = ('0' + now.getDate()).slice(-2)
const ymd = ${year}/${month}/${day}
const a = document.createElement('a');
a.href = https://scrapbox.io/${cosense.Project.name}/${ymd};
document.body.appendChild(a);
a.click();
a.remove();
});
// ボタンをbody要素に追加
document.body.appendChild(button);
})();
UserScript.icon