-
-
Save nora-tetsu/68cabe5bbf8e7e2d51a2a247eefc83ec 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 () { | |
// 取得したいコードブロックの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