-
-
Save nora-tetsu/8a47788d0740443eb9fdf98cb4c95cb8 to your computer and use it in GitHub Desktop.
Page Menuから指定したキーワードをタイトルに含むページの一覧を追記する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
(function () { | |
scrapbox.PageMenu.addMenu({ | |
title: 'タイトル抽出', | |
image: 'https://i.gyazo.com/7057219f5b20ca8afd122945b72453d3.png', // Scrapboxアイコン | |
onClick: () => { | |
const keyword = prompt('ピックアップする文字列を入力してください。'); | |
if (!keyword) return; | |
// 現在のプロジェクトの全ページについて、指定した文字列をタイトルに含むか判定する | |
let body = `「${keyword}」を含むページ\n`; | |
scrapbox.Project.pages.forEach(data => { | |
if (!data.exists) return; // 空リンクはスキップ | |
if (!data.title.includes(keyword)) return; | |
body += `\t[${data.title}]\n`; | |
}) | |
// 追記内容を現在のページのURLに付与して別ウインドウで開く | |
const write = window.open(`https://scrapbox.io/${scrapbox.Project.name}/${scrapbox.Page.title}?body=${encodeURIComponent(body)}`); | |
setTimeout(() => write.close(), 15000); // 15秒後に閉じる(長過ぎるようなら短くする) | |
}, | |
}) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment