script_disable.js scrapbox.PageMenu.addMenu({
title: 'CREATE HEADLINES w/URL',
image: 'https://gyazo.com/0494577c10f60b594cf4ce730b31414e/raw',
onClick: () => {
var headlines = [];
for (let line of scrapbox.Page.lines) {
if (!line.section.start) continue
var title = line.text
title = title.replace(/^\[[\_\*]+ (.+)\]$/,"$1");
var firstIcon = title.match(/^\[([^\[\]]+)\.icon\]/);
title = title.replace(/^\[([^\[\]]+)\.icon\]/,"");
var lastIcon = title.match(/\[([^\[\]]+)\.icon\]$/,"$1");
title = title.replace(/\[([^\[\]]+)\.icon\]$/,"");
var headline = "";
if ( firstIcon !=null){
headline = firstIcon[0];
}
title = title.replace( /\[([^\[\]]+)\.icon\]/g,"($1)");
title = title.replace( /\[([^\[\]]+)\]/g,"$1");
if(title == ""){
title = "link"
}
var url = location.href
url = url.replace(/#.+$/g,"");
url = url + "#"+ line.id;
headline += "[" + title + " " + url + "]"
if ( lastIcon !=null){
headline += lastIcon[0];
}
headlines.push(headline);
}
console.log(headlines);
if(navigator.clipboard){
navigator.clipboard.
writeText(headlines.join('\n'));
}
}
})