Skip to content

Instantly share code, notes, and snippets.

@nora-tetsu
Created February 23, 2023 08:38
Show Gist options
  • Save nora-tetsu/68cabe5bbf8e7e2d51a2a247eefc83ec to your computer and use it in GitHub Desktop.
Save nora-tetsu/68cabe5bbf8e7e2d51a2a247eefc83ec to your computer and use it in GitHub Desktop.
Page Menuから特定のコードブロックの内容を呼び出すUserScript
(function () {
// 取得したいコードブロックのURL
const url = '/api/code/noratetsu/●PageMenu:任意のコードブロックの中身をalertで表示する/sample.txt';
scrapbox.PageMenu.addMenu({
title: 'コードブロック表示',
image: 'https://i.gyazo.com/7057219f5b20ca8afd122945b72453d3.png', // Scrapboxアイコン
onClick: () => {
// fetchで指定した場所のデータを取得し、thenの中で任意の処理を実行
fetch(url)
.then(response => response.text()) // データから文字列を取り出す
.then(text => {
alert(text); // 指定したコードブロックの中身のテキストを表示する
});
},
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment