週記を開くbookmarklet
code:code.js
javascript:(function(){const t=new Date();const getSunday=d=>{const n=new Date(d);n.setDate(n.getDate()-n.getDay());return n;};const getSaturday=d=>{const s=getSunday(d);const sat=new Date(s);sat.setDate(s.getDate()+6);return sat;};const getISOWeek=d=>{const n=new Date(d);n.setHours(0,0,0,0);n.setDate(n.getDate()+4-(n.getDay()||7));const y=new Date(n.getFullYear(),0,1);return Math.ceil((((n-y)/86400000)+1)/7);};const getWeekNum=d=>{const s=getSunday(d);if(s.getMonth()===11&&getISOWeek(s)===1)return 1;const m=new Date(s);m.setDate(s.getDate()+1);return getISOWeek(m);};const formatMMDD=d=>{const mm=String(d.getMonth()+1).padStart(2,'0');const dd=String(d.getDate()).padStart(2,'0');return ${mm}/${dd};};const sun=getSunday(t);const sat=getSaturday(t);const y=sun.getFullYear();const w=getWeekNum(t);const start=formatMMDD(sun);const end=formatMMDD(sat);const title=週記_${y}_W${String(w).padStart(2,'0')}_${start}~${end};const url=https://scrapbox.io/projectName/${encodeURIComponent(title)};window.open(url,'_blank');})();