var url_no_display_buffer = [ ]; var url_check_string = ["tag=jword","af_115_0_10001685","afvc_shp_2108132","tag=kaipoke-cart-22"]; var url_buffer_len = 10; var url_buffer_flush_Sec_close = 10 * 60;// 閉じるボタン押下時の制御 var url_buffer_flush_Sec_click = 5 * 60;// 通知バー押下時の制御 var BUFFER_TYPE_BAR_CLOSE = 0; var BUFFER_TYPE_BAR_CLICK = 1; function update_no_display_buffer(nowDate){ for( i = 0; i < url_no_display_buffer.length; i++ ){ var check_sec = url_buffer_flush_Sec_close; if( url_no_display_buffer[i].type == BUFFER_TYPE_BAR_CLICK ){ check_sec = url_buffer_flush_Sec_click; } // 非表示時間切れ if( (nowDate-check_sec) >= url_no_display_buffer[i].time ){ url_no_display_buffer.splice(i,1); } } } function addUrlBuffer(url,type){ var date = new Date(); var nowDate = Math.floor(date.getTime() / 1000); update_no_display_buffer(nowDate); var data = { data:url , time:nowDate , type:type}; // バッファサイズを超えた時は最初のものを消す if( url_no_display_buffer.length > url_buffer_len ) { url_no_display_buffer.shift(); } // お尻に追加 url_no_display_buffer.push(data); } // false (表示しない) true (表示して良い) function checkUrlForDisplayKaipokeBar(currenturl){ var date = new Date(); var nowDate = Math.floor(date.getTime() / 1000); update_no_display_buffer(nowDate); for( t = 0 ; t < url_check_string.length; t++ ){ if( -1 != currenturl.indexOf(url_check_string[t]) ){ return false; } } for( i = 0 ; i < url_no_display_buffer.length ; i++ ){ // 非表示URLと完全一致した場合は、とにかく非表示 if( currenturl == url_no_display_buffer[i].data ){ return false; } // クリックした後のURLは非表示(URLにurl_check_stringが含まれるはずなので、チェックする) if ( url_no_display_buffer[i].type == BUFFER_TYPE_BAR_CLICK ){ for( t = 0 ; t < url_check_string.length; t++ ){ if( -1 != currenturl.indexOf(url_check_string[t]) ){ return false; } } } } return true; } /** * URLからQueryCodeへ変換します * * @return string|undefined * @param url */ function encodeQueryCode(url) { if (typeof url !== "string") { return; } var patternReplacements = [ // amazon { pattern: new RegExp("^https://www\\.amazon\\.co\\.jp.*/dp/(?:product/)?([a-z0-9]{10})/?.*$", "i"), replacement: "amazon:$1" }, { pattern: new RegExp("^https://www\\.amazon\\.co\\.jp.*/reader/([a-z0-9]{10})/?.*$", "i"), replacement: "amazon:$1" }, { pattern: new RegExp("^https://www\\.amazon\\.co\\.jp.*/gp/product/([a-z0-9]{10})/?.*$", "i"), replacement: "amazon:$1" }, { pattern: new RegExp("^https://www\\.amazon\\.co\\.jp.*/asin/([a-z0-9]{10})/?.*$", "i"), replacement: "amazon:$1" }, { pattern: new RegExp("^https://www\\.amazon\\.co\\.jp.*/gp/product?ASIN=([a-z0-9]{10})&?.*$", "i"), replacement: "amazon:$1" }, { pattern: new RegExp("^https://www\\.amazon\\.co\\.jp/exec/obidos/tg/detail/offer-listing/-/([a-z0-9]{10})/.*$", "i"), replacement: "amazon:$1" }, { pattern: new RegExp("^https://www\\.amazon\\.co\\.jp/gp/product/([a-z0-9]{10})/?.*$", "i"), replacement: "amazon:$1" }, { pattern: new RegExp("^https://www\\.amazon\\.co\\.jp/gp/product/[^?]+?[^&]*ASIN=([a-z0-9]{10}).*$", "i"), replacement: "amazon:$1" }, { pattern: new RegExp("^https://www\\.amazon\\.co\\.jp/exec/obidos/ASIN/([a-z0-9]{10})/.*$", "i"), replacement: "amazon:$1" }, { pattern: new RegExp("^https://www\\.amazon\\.co\\.jp.*/offer-listing/([a-z0-9]{10})/?.*$", "i"), replacement: "amazon:$1" }, { pattern: new RegExp("^https://www\\.amazon\\.co\\.jp.*[&?]ASIN=([a-z0-9]{10}).*$", "i"), replacement: "amazon:$1" }, // yahoo shopping { pattern: new RegExp("^https?://store\\.shopping\\.yahoo\\.co\\.jp/+([^/?]+)/+([^.]+).html.*$", "i"), replacement: "yahoo_shopping:$1/$2" }, // yahoo auctions { pattern: new RegExp("^https://page\\.auctions\\.yahoo\\.co\\.jp/(jp/+)?auction/([a-z0-9]{8,12}).*$", "i"), replacement: "yahoo_auction:$1$2" }, // paypaymall { pattern: new RegExp("^https://paypaymall\\.yahoo\\.co\\.jp/store/([^/?]+)/item/([^/?]+)/?.*$", "i"), replacement: "yahoo_paypaymall:$1/$2" }, // rakuten ichiba { pattern: new RegExp("^https://item\\.rakuten\\.co\\.jp/([^/?]+)/+([^/?]+)/*.*$", "i"), replacement: "rakuten_ichiba:$1/$2" }, // rakuten books { pattern: new RegExp("^https://books\\.rakuten\\.co\\.jp/(r[bk])/([^/?]+)/.*$", "i"), replacement: "rakuten_books:$1/$2" }, // rakuten 商品比較 { pattern: new RegExp("^https://product\\.rakuten\\.co\\.jp/product/-/+([^/?]+)/.*$", "i"), replacement: "rakuten_product:$1" }, // rakuten biccamera { pattern: new RegExp("^https://biccamera\\.rakuten\\.co\\.jp/item/([^/?]+)/?.*$", "i"), replacement: "rakuten_biccamera:$1" }, // rakuten supermarket(ネットマーケット) { pattern: new RegExp("^https://sm.rakuten.co.jp/item/([^/?]+)/?.*$", "i"), replacement: "rakuten_sm:$1" }, // rakuten ファッション { pattern: new RegExp("https://brandavenue\\.rakuten\\.co\\.jp/item/([^/?]+)/?.*$", "i"), replacement: "rakuten_brandavenue:$1" }, // kakaku.com { pattern: new RegExp("^https://kakaku\\.com/item/([^/?]+).*$", "i"), replacement: "kakaku:$1" }, // kakaku.com 特殊パターン (bike, reformなど?) { pattern: new RegExp("^https://kakaku\\.com/([^/?]+)/item/([^/?]+).*$", "i"), replacement: "kakaku:$1/$2" }, // ZOZOTOWN { pattern: new RegExp("^https://zozo\\.jp/shop/([^/?]+)/goods(?:-sale)?/([^/?]+)/.*$", "i"), replacement: "zozo:$1/$2" }, // mercari { pattern: new RegExp("^https://(?:www\\.)?mercari\\.com/([^/?]+)/items/([^/?]+)/.*$", "i"), replacement: "mercari:$1/$2" } ]; for (var _i = 0, patternReplacements_1 = patternReplacements; _i < patternReplacements_1.length; _i++) { var patternReplacement = patternReplacements_1[_i]; if (url.match(patternReplacement["pattern"])) { return url.replace(patternReplacement["pattern"], patternReplacement["replacement"]); } } } /** * QueryCodeからURLへ変換します * * @return string|undefined * @param queryCode */ function decodeQueryCode(queryCode) { if (typeof queryCode !== "string") { return; } var patternReplacements = [ // amazon { pattern: new RegExp("^amazon:([^/]+)$", "i"), replacement: "https://www.amazon.co.jp/dp/$1" }, // yahoo shopping { pattern: new RegExp("^yahoo_shopping:([^/]+)/([^/]+)$", "i"), replacement: "https://store.shopping.yahoo.co.jp/$1/$2.html" }, // yahoo auctions { pattern: new RegExp("^yahoo_auction:([^/]+)$", "i"), replacement: "https://page.auctions.yahoo.co.jp/auction/$1" }, { pattern: new RegExp("^yahoo_auction:([^/]+)/([^/]+)$", "i"), replacement: "https://page.auctions.yahoo.co.jp/$1/auction/$2" }, // paypaymall { pattern: new RegExp("^yahoo_paypaymall:([^/]+)/([^/]+)$", "i"), replacement: "https://paypaymall.yahoo.co.jp/store/$1/item/$2/" }, // rakuten ichiba { pattern: new RegExp("^rakuten_ichiba:([^/]+)/([^/]+)$", "i"), replacement: "https://item.rakuten.co.jp/$1/$2/" }, // rakuten books { pattern: new RegExp("^rakuten_books:([^/]+)/([^/]+)$", "i"), replacement: "https://books.rakuten.co.jp/$1/$2/" }, // rakuten 商品比較 { pattern: new RegExp("^rakuten_product:([^/]+)$", "i"), replacement: "https://product.rakuten.co.jp/product/-/$1/" }, // rakuten biccamera { pattern: new RegExp("^rakuten_biccamera:([^/]+$)", "i"), replacement: "https://biccamera.rakuten.co.jp/item/$1/" }, // rakuten supermarket(ネットマーケット) { pattern: new RegExp("^rakuten_sm:([^/]+)$", "i"), replacement: "https://sm.rakuten.co.jp/item/$1/" }, // rakuten ファッション { pattern: new RegExp("^rakuten_brandavenue:([^/]+)$", "i"), replacement: "https://brandavenue.rakuten.co.jp/item/$1/" }, // kakaku.com { pattern: new RegExp("^kakaku:([^/]+)$", "i"), replacement: "https://kakaku.com/item/$1/" }, // kakaku.com 特殊パターン { pattern: new RegExp("^kakaku:([^/]+)/([^/]+)$", "i"), replacement: "https://kakaku.com/$1/item/$2" }, // ZOZOTOWN { pattern: new RegExp("^zozo:([^/]+)/([^/]+)$", "i"), replacement: "https://zozo.jp/shop/$1/goods/$2/" }, // mercari { pattern: new RegExp("^mercari:([^/]+)/([^/]+)$", "i"), replacement: "https://www.mercari.com/$1/items/$2/" } ]; for (var _i = 0, patternReplacements_2 = patternReplacements; _i < patternReplacements_2.length; _i++) { var patternReplacement = patternReplacements_2[_i]; if (queryCode.match(patternReplacement["pattern"])) { return queryCode.replace(patternReplacement["pattern"], patternReplacement["replacement"]); } } }