(async()=>{const regexpEscape=s=>s.replace(/[\\^$.*+?()[\]{}|]/g,'\\$&');const regexp=new RegExp(regexpEscape("https://b.hatena.ne.jp/entry/")+"(s/)*(.+)");const BtoURL=s=>s.replace(regexp,((_,p1,p2)=>(p1?"https://":"http://")+p2));const{bookmarks:bookmarks,eid:eid}=await(await fetch('https://b.hatena.ne.jp/entry/jsonlite/?url='+encodeURIComponent(BtoURL(prompt('比較ブクマURL',''))))).json();const{bookmarks:origBookmarks,eid:origEid}=await(await fetch('https://b.hatena.ne.jp/entry/jsonlite/?url='+encodeURIComponent(BtoURL(location.href)))).json();const blob=new Blob([bookmarks.flatMap((bookmark=>{const origBookmark=origBookmarks.find((origBookmark=>origBookmark.user===bookmark.user));if(!origBookmark)return[];return[`
\n* ${bookmark.user}\n>>\n${bookmark.comment}\nhttps://b.hatena.ne.jp/entry/${eid}/comment/${bookmark.user}\n<<\n>>\n${origBookmark.comment}\nhttps://b.hatena.ne.jp/entry/${origEid}/comment/${origBookmark.user}\n<<\n`]})).join('')],{type:"text/html;charset=utf-8"});const url=URL.createObjectURL(blob);window.open(url);URL.revokeObjectURL(url)})();