ページの全文をショートカットAppに受け渡す_選択部分をショートカットAppに受け渡すボタンを追加する
code:script.js
- //全文をショートカットappに受け渡す(その後、markdownに変換に、クリップボードに)
- scrapbox.PageMenu.addMenu({
- title: 'NewButton',
- image: 'https://i.gyazo.com/7057219f5b20ca8afd122945b72453d3.png',
- onClick: () => {
- const title = scrapbox.Page.title;
- const url = "https://scrapbox.io/api/pages/choiyaki/" + title;
- fetch(url)
- .then(response => {
- if (!response.ok) {
- throw new Error(
HTTP error! Status: ${response.status});
- throw new Error(
- }
- return response.json();
- if (!response.ok) {
- })
- .then(d => {
- let s = d.title + "\n\n";
- for (let i = 1; i < d.lines.length; i++) {
- s += d.linesi.text + "\n";
- }
- location="shortcuts://run-shortcut?name=StoM&input=" + encodeURIComponent(s)
- })
- .catch(error => {
- console.error("Error fetching Scrapbox page:", error);
- alert("データの取得に失敗しました。");
- });
- .then(response => {
- }
- });
- // 選択された文字列をショートカットappに受け渡す(その後 markdownに変換)
- scrapbox.PopupMenu.addButton({
- title: 'mdコピー',
- onClick: function (text) {
- var projectName = 'daiiz';
- window.open("shortcuts://run-shortcut?name=StoM&input=" + encodeURIComponent(text));
- }
- });