-
-
Save nora-tetsu/ace95fcf7d15612b4f1a23339dbf5f45 to your computer and use it in GitHub Desktop.
Scrapboxの今日の日付のページに任意の文字列を追記する
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
(function (){ | |
const projectName = prompt('プロジェクトURLを入力してください。'); | |
if(!projectName) return; // 未記入ならreturn | |
const today = new Date(); // 現在日時のDateオブジェクト | |
const year = today.getFullYear(); // 年(四桁) | |
const month = ('00' + (today.getMonth() + 1)).slice(-2); // 月(常に二桁表示になるように加工) | |
const date = ('00' + today.getDate()).slice(-2); // 日(常に二桁表示になるように加工) | |
const pageTitle = encodeURIComponent(`${year}/${month}/${date}`); // タイトルを作ってエンコードする | |
let url = `https://scrapbox.io/${projectName}/${pageTitle}`; // プロジェクトURLとページタイトルからURLを作る | |
const text = prompt('ページに追記する文字列を入力してください。'); | |
if(text) url += `?body=${encodeURIComponent(text)}`; // 追記する文字列があればURLに加える(なければただページを開く) | |
window.open(url); // Scrapboxを開く | |
})(); | |
/* | |
javascript:(function(){const projectName=prompt('プロジェクトURLを入力してください。');if(!projectName)return;const today=new Date();const year=today.getFullYear();const month=('00'+(today.getMonth()+1)).slice(-2);const date=('00'+today.getDate()).slice(-2);const pageTitle=encodeURIComponent(`${year}/${month}/${date}`);let url=`https://scrapbox.io/${projectName}/${pageTitle}`;const text=prompt('ページに追記する文字列を入力してください。');if(text)url+=`?body=${encodeURIComponent(text)}`;window.open(url)})() | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment