参考:WorkFlowyまたはDynalistからScrapboxのページを作成するスクリプト - MARUMI blog
上のスクリプトを元にChatGPT頼りつつ改造。
▼ コード
javascript:(function(){function DL2CS(projectName, indentLinks){function formatQuote(note){return note.split(/\r\n|\r|\n/).map(line=>"> "+line).join("\n")+"\n"}function convertMarkdownLinks(text){return text.replace(/\[(.?)\]\((.?)\)/g,'[$1 $2]')}if(location.host==="dynalist.io"&&projectName){const root=DYNALIST.app.app_document.ui.current_root;const meta=root.get_meta_object();const content=meta.get_content()||"Undefined";const note=meta.get_note()?formatQuote(meta.get_note()):"";const children=(function getChildren(indentation,items){return items.map(item=>{const childMeta=item.get_meta_object();return indentation+childMeta.get_content()+"\n"+(childMeta.get_note()?formatQuote(childMeta.get_note()):"")+getChildren(indentation+" ",item.get_children().children);}).join("")}(indentLinks?" ":"",root.get_children().children));const url="https://scrapbox.io/"+projectName+"/"+encodeURIComponent(content);const body=convertMarkdownLinks(note+children);window.open(url+"?body="+encodeURIComponent(body),'_blank')}}DL2CS("YOUR-PROJECT",true);})();
機能
- ズームした項目をタイトル、その子項目以下を本文としてCosenseに転記
- 階層はそのまま
- ノートは引用符
- マークダウンのリンクをCosenseの記法に置換
使用方法
- 末尾のYOUR-PROJECTを転記したいプロジェクト名に変更してください
- その後ろのtrue/falseは最上位項目をインデントするかどうかを決めます