新規作成時に日付タグを挿入するUserScript
新規作成ボタンを押して作成したページに、予め日付タグを挿入しておくUserScript
作成動機と過程はNew Buttonで開くページを変更するを参照
2021-09-29
07:37:16
日付操作ライブラリをdate-fns.min.jsに変更
検索欄に記入されている文字列をタイトルとして使う
setInterval()で時刻を更新する
code:script.js
import {lightFormat} from "../date-fns.min.js/script.js";
setInterval(() => {
for (const button of document.getElementsByClassName("new-button")) {
const title = document.getElementsByClassName("form-control")?.0?.value;
const timestamp = #${lightFormat(new Date(), "yyyy-MM-dd HH:mm:ss")};
button.href = `/${scrapbox.Project.name}/${title || "new"}?body=${encodeURIComponent([
"",
"",
timestamp,
].join("\n"))}`;
}
}, 1000);
console.log('The hrefs of "New Button" have been changed.');
https://gyazo.com/b3d45a35630fa1ae2ef5f8afa78d75bf
/icons/よさそう.icon
#2021-09-29 07:25:13
#2021-02-04