import
code:test
import "../../hoshihara/import/script.js";
自分のページのscript.jsに上のコードを貼り付ければ使える
文字数カウント
code:script.js
import '/api/code/shokai/文字カウント/page.js'
import '/api/code/shokai/文字カウント/popup.js'
年月日ショートカット
code:script.js
scrapbox.TimeStamp.removeAllFormats()
scrapbox.TimeStamp.addFormat('HH:mm')
scrapbox.TimeStamp.addFormat('YYYY-MM-DD')
scrapbox.TimeStamp.addFormat('YYYY-MM-DD HH:mm:ss')
scrapbox.TimeStamp.addFormat('#YYYY-MM-DD HH:mm:ss')
空白削除
code:script.js
scrapbox.PopupMenu.addButton({
title: '空行・空白削除',
onClick: text => text.split(/\n/).filter(line => !line.match(/^\s*$/)).join('\n')
})
Twitter埋め込み
code:script.js
scrapbox.PopupMenu.addButton({
title : 'Embed Tweet',
onClick : text => {
const convertContent = (content, indent) => {
const replaced = content
.replace(/<a href="(https?:.*?)">(.*?)<\/a>/g, '$1 $2') .replace(/<br>/g, \n${indent});
const elem = document.createElement('div');
elem.innerHTML = replaced;
return indent + elem.innerText;
}
const tweetRegex = /(?<spaces>\t *)<blockquote\w"\-= *><p\w"\-= *>(?<content>.*)<\/p>—(?<author>.*)(?<link><a.*>)<\/blockquote>\n\t *<script.*?><\/script>/; const match = text.match(tweetRegex);
if(!match) return;
const {spaces, content, author, link} = match.groups;
const ind = ${spaces}>;
return text.replace(tweetRegex, convertContent(content, ind) + '\n' + convertContent(\t—${author} ${link}, ind));
}
})
code:script.js
import { mount } from "../../hoshihara/scrapbubble/mod.js";