コンビニ3社の店舗番号を取り出すブックマークレット
URLに店番が含まれた状態のページで実行すると店番をいい感じにして取り出す
ソースコード
code:javascript
(() => {
const hostname = location.hostname;
const toHalfWidth = (str) => str.replace(/A-Za-z0-9/g, (s) => String.fromCharCode(s.charCodeAt(0) - 0xFEE0)); if (hostname.indexOf('seven-eleven.areamarker.com') !== -1) {
// セブンイレブン
const match = location.search.match(/shopid=(\d+)/);
if (match === null) {
alert('店番を取得出来ませんでした');
return;
}
const storeName = toHalfWidth(document.querySelector('.c-shopname').innerText);
window.prompt('セブンイレブン 店舗名+店舗番号', ${storeName}店_${storeID});
} else if (hostname.indexOf('store.family.co.jp') !== -1) {
// ファミリーマート
const match = location.pathname.match(/points\/(\d+)/);
if (match === null) {
alert('店番を取得出来ませんでした');
return;
}
const storeName = toHalfWidth(document.querySelector('#contents-header .name').innerText);
window.prompt('ファミリーマート 店舗名+店舗番号', ${storeName}_${storeID});
} else if (hostname.indexOf('e-map.ne.jp') !== -1) {
// ローソン
const pathname = location.pathname;
const match = pathname.match(/(\d+)\/$/);
if (match === null) {
alert('店番を取得出来ませんでした');
return;
}
const storeID = match1.match(/(1-9\d+)/)1; window.prompt('ローソン 店舗番号', storeID);
} else {
// 未対応
alert('未対応サイト');
}
})();
圧縮版
code:javascript
(()=>{let e=location.hostname,t=e=>e.replace(/A-Za-z0-9/g,e=>String.fromCharCode(e.charCodeAt(0)-65248));if(-1!==e.indexOf("seven-eleven.areamarker.com")){let r=location.search.match(/shopid=(\d+)/);if(null===r){alert("店番を取得出来ませんでした");return}let n=t(document.querySelector(".c-shopname").innerText),a=r1;window.prompt("セブンイレブン 店舗名+店舗番号",${n}店_${a})}else if(-1!==e.indexOf("store.family.co.jp")){let l=location.pathname.match(/points\/(\d+)/);if(null===l){alert("店番を取得出来ませんでした");return}let m=t(document.querySelector("#contents-header .name").innerText),o=l1;window.prompt("ファミリーマート 店舗名+店舗番号",${m}_${o})}else if(-1!==e.indexOf("e-map.ne.jp")){let p=location.pathname,i=p.match(/(\d+)\/$/);if(null===i){alert("店番を取得出来ませんでした");return}let c=i1.match(/(1-9\d+)/)1;window.prompt("ローソン 店舗番号",c)}else alert("未対応サイト")})();