theme: dark
share: true
noti: 이 글자가 보이시는 분은 <https://www.alrimi.click/item> 로 재접속 부탁드립니다.
<head>
  <title>쿠팡 상품 가격 차트</title>
  <meta name="description" content="쿠팡 상품의 가격 차트를 조회할수 있습니다. 상품을 등록하면 가격변동, 카드할인, 재입고, 박스훼손(재포장) 상품 입고시 알림을 드립니다.">
  <meta name="keywords" content="쿠팡 가격변동,쿠팡 재포장,쿠팡 알림,쿠팡 재입고,쿠팡 박스훼손,쿠팡 카드할인,쿠팡 할인">
  <meta property="og:description" content="쿠팡 상품의 가격 차트를 조회할수 있습니다. 상품을 등록하면 가격변동, 카드할인, 재입고, 박스훼손(재포장) 상품 입고시 알림을 드립니다.">
  <style>
    body {
      height: 100%;
      margin: 0;
      font-size: 1rem;
      font-weight: 400;
      line-height: 1.5;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
      text-align: left;
      background-color: #fff;
      padding-bottom: 0px;
    }

    .table {
      width: 100%;
      margin-bottom: 1rem;
      background-color: transparent;
    }

    .table-dark {
      color: #fff;
      background-color: #212529;
    }

    .table-dark, .table-dark > td, .table-dark > th {
      background-color: #c6c8ca;
    }

    .table-dark td, .table-dark th, .table-dark thead th {
      border-color: #32383e;
    }

    .table td, .table th {
      padding: 0.75rem;
      vertical-align: top;
      border-top: 1px solid #dee2e6;
      border: none !important;
    }

    #detail_item_link {
      position: fixed;
      bottom: 56px;
      left: 0px;
      right: 0px;
      margin: 0px auto;
      display: flex;
      align-self: center;
      -webkit-box-align: center;
      align-items: center;
      -webkit-box-pack: center;
      width: 88%;
      max-width: 708px;
      height: 48px;
      z-index: 100000000;
    }

    #detail_item_link_alrimi {
      position: initial;
      bottom: 56px;
      left: 0px;
      right: 0px;
      display: flex;
      align-self: center;
      -webkit-box-align: center;
      align-items: center;
      -webkit-box-pack: center;
      justify-content: center;
      width: 50%;
      max-width: 708px;
      margin-right: 1px;
      height: 48px;
      color: rgb(0, 0, 0);
      background-color: rgb(255, 220, 73);
      text-decoration: none;
      border-radius: 8px;
      font-weight: 700;
      font-size: 16px;
      transition: all 0.3s ease 0s;
      box-shadow: rgb(55 53 47 / 40%) 0px 0px 4px 2px;
      animation: 0.8s ease 0s 1 normal none running fadeIn;
      z-index: 100000000;
    }

    #detail_item_link_shop {
      position: initial;
      bottom: 56px;
      left: 0px;
      right: 0px;
      display: flex;
      align-self: center;
      -webkit-box-align: center;
      align-items: center;
      -webkit-box-pack: center;
      justify-content: center;
      width: 50%;
      max-width: 708px;
      margin-left: 1px;
      height: 48px;
      color: rgb(0, 0, 0);
      background-color: rgb(95, 203, 228);
      text-decoration: none;
      border-radius: 8px;
      font-weight: 700;
      font-size: 16px;
      transition: all 0.3s ease 0s;
      box-shadow: rgb(55 53 47 / 40%) 0px 0px 4px 2px;
      animation: 0.8s ease 0s 1 normal none running fadeIn;
      z-index: 100000000;
    }
  </style>
  <script>
    let product_url = "<https://coupa.ng/bGwvF9>";

    $(function () {
        let type = getParam('t')

        if ('u' === type) {
            document.getElementById('detail_item_link_shop').style.width = '100%';
            document.getElementById('detail_item_link_shop').style.display = '';
            get_used_product_detail(getParam('id'), getParam('v'));
        } else {
            document.getElementById('detail_item_link_alrimi').style.display = '';
            document.getElementById('detail_item_link_shop').style.display = '';
            get_product_detail(getParam('id'));
        }
    });
    
    function getParam(name) {
      let curr_url = location.search.substr(location.search.indexOf("?") + 1);
      let svalue = "";
      curr_url = curr_url.split("&");
      for (let i = 0; i < curr_url.length; i++) {
        temp = curr_url[i].split("=");
        if ([temp[0]] == name) {
          svalue = temp[1];
        }
      }
      return svalue;
    }

    function get_product_detail(id) {
      let a_id = getParam('a_id')
      let u_id = getParam('u_id')
      fetch("<https://fnf4ts3qrj.execute-api.ap-northeast-2.amazonaws.com/default/get_product_detail?type=chart&>" +
            "id=" + id + "&u_id=" + u_id + "&a_id=" + a_id)

        .then((response) => response.json())
        .then((data) => {
          if (data == null) {
            alert("상품 조회에 실패했습니다.\\nhttps://bit.ly/쿠팡-가격변동-알리미-문의\\n위의 주소로 문의 부탁드립니다.")
          }

          document.title = data['p_nm'];
          document.getElementsByTagName("h1")[0].innerHTML = data['p_nm'];
          if (data['get_point']) {
            document.getElementById('detail_item_link_alrimi').innerHTML = "구매하러 가기 🚀 (+8 포인트 적립)"
          }

          if (!data['etc_product']) {
            product_url = data['url']
            document.getElementsByClassName('page-icon')[0].getElementsByTagName("img")[0].src = data['p_img_url']

            let high_price_list = data['high_price_list']
            let low_price_list = data['low_price_list']

            let highest_price = Math.max(...high_price_list)
            let lowest_price = Math.min(...low_price_list)

            let highest_price_index = get_last_index_by_value(high_price_list, highest_price)
            let lowest_price_index = get_last_index_by_value(low_price_list, lowest_price)

            document.getElementById('now_price').innerHTML = data['price'].toLocaleString() + '원'
            document.getElementById('highest_price').innerHTML = highest_price.toLocaleString() + '원'
            document.getElementById('lowest_price').innerHTML = lowest_price.toLocaleString() + '원'
            document.getElementById('highest_date').innerHTML = data['date_list'][highest_price_index]
            document.getElementById('lowest_date').innerHTML = data['date_list'][lowest_price_index]
            if (data['etc_price_type'] != undefined && data['etc_price_type'] != "") {
              document.getElementById('etc_price_type').innerHTML = data['etc_price_type']

              let diff_percent = (((data['etc_price'] - data['price']) / data['price']) * 100).toFixed(1)
              let diff_percent_html

              if (diff_percent > 0) {
                diff_percent_html = "<span style='color: rgb(255,115,105)'>" + data['etc_price'].toLocaleString() + "원</span><br/>"
                diff_percent_html +=
                  "<span style='color: rgb(255,115,105)'>(" + diff_percent + "%, " + (data['etc_price'] - data['price']).toLocaleString() + "원" + ")</span>"
              } else {
                diff_percent_html = "<span style='color: rgb(82,156,202)'>" + data['etc_price'].toLocaleString() + "원</span><br/>"
                diff_percent_html +=
                  "<span style='color: rgb(82,156,202)'>(" + diff_percent + "%, " + (data['etc_price'] - data['price']).toLocaleString() + "원" + ")</span>"
              }

              document.getElementById('etc_price').innerHTML = diff_percent_html
              document.getElementById('etc_description').style.display = '';
            }

            if (data['card_benefit'] == true) {
              document.getElementById('card_benefit').innerHTML = "💳 " + data['card_benefit_detail']
            }

            let show_highest_price = true
            if (highest_price === lowest_price && highest_price_index === lowest_price_index) {
              show_highest_price = false
            }

            let options = {
              series: [
                {
                  name: "최고가",
                  data: high_price_list
                },
                {
                  name: "최저가",
                  data: low_price_list
                }
              ],
              theme: {
                mode: 'dark',
                // palette: 'palette1',
                monochrome: {
                  enabled: false,
                  color: '#255aee',
                  shadeTo: 'light',
                  shadeIntensity: 0.65
                },
              },
              chart: {
                zoom: false,
                background: '#2f3437',
                height: 500,
                type: 'line',
                toolbar: {
                  show: false
                },
                events: {
                  animationEnd: function (chartContext, options) {
                    document.getElementsByClassName('apexcharts-canvas')[0].style.width =
                      document.getElementsByClassName('apexcharts-canvas')[0].clientWidth + 42 + "px";
                    // document.getElementsByClassName('apexcharts-toolbar')[0].style.marginRight = "12px";
                    document.getElementsByClassName('apexcharts-svg')[0].style.width = "100%";
                    // document.getElementsByClassName('apexcharts-toolbar')[0].style.display = '';
                  },
                  updated: function (chartContext, options) {
                    // document.getElementsByClassName('apexcharts-toolbar')[0].style.display = 'none';
                    document.getElementsByClassName('apexcharts-canvas')[0].style.width =
                      document.getElementsByClassName('apexcharts-canvas')[0].clientWidth + 42 + "px";
                    // document.getElementsByClassName('apexcharts-toolbar')[0].style.marginRight = "12px";
                    document.getElementsByClassName('apexcharts-svg')[0].style.width = "100%";
                  }
                }
              },
              dataLabels: {
                offsetX: 0,
                textAnchor: 'middle',
                // textAnchor: 'middle',    // array 개수를 기준으로 판단 필요 TODO
                enabled: true,
                formatter: function (val, opts) {
                  if (show_highest_price && opts.seriesIndex == 0 && opts.dataPointIndex === highest_price_index) {
                    return "최고가: " + val.toLocaleString('ko-KR') + "원"
                  }

                  if (opts.seriesIndex == 1 && opts.dataPointIndex === lowest_price_index) {
                    return "최저가: " + val.toLocaleString('ko-KR') + "원"
                  }
                }
              },
              colors: ["rgb(255,115,105)", "rgb(82,156,202)"],
              stroke: {
                width: [1, 1],
                curve: 'smooth'
              },
              xaxis: {
                categories: data['date_list']
              },
              tooltip: {
                y: {
                  formatter: function (value, {series, seriesIndex, dataPointIndex, w}) {
                    return value.toLocaleString('ko-KR') + "원"
                  }
                }
              },
              grid: {
                borderColor: '#f1f1f1',
              }
            };

            var chart = new ApexCharts(document.querySelector("#chart"), options);
            chart.render();

            setTimeout(function () {
              document.title = data['p_nm'];
              document.getElementsByTagName("h1")[0].innerHTML = data['p_nm'];
              product_url = data['url']
              document.getElementsByClassName('page-icon')[0].getElementsByTagName("img")[0].src = data['p_img_url']
              if (data['get_point']) {
                document.getElementById('detail_item_link_alrimi').innerHTML = "구매하러 가기 🚀 (+8 포인트 적립)"
              }

              let notionLinks = document.querySelectorAll('a.notion-link-token');

              for (let i = 0; i < notionLinks.length; i++) {
                let link = notionLinks[i];
                if (link.href === '<https://t.me/coupang_alarm_bot>') {
                  link.href = '<https://t.me/coupang_alarm_bot?start=a_p_>' + id;
                }
              }
            }, 200);
          }
        });
    }

    function get_used_product_detail(id, v_id) {
      fetch("<https://fnf4ts3qrj.execute-api.ap-northeast-2.amazonaws.com/default/get_product_detail?type=used_chart&id=>" + id + "&v_id=" + v_id)

        .then((response) => response.json())
        .then((data) => {
          if (data == null) {
            alert("상품 조회에 실패했습니다.\\nhttps://bit.ly/쿠팡-가격변동-알리미-문의\\n위의 주소로 문의 부탁드립니다.")
          }

          document.title = data['p_nm'];
          document.getElementsByTagName("h1")[0].innerHTML = data['p_nm'];
          if (data['get_point']) {
            document.getElementById('detail_item_link_alrimi').innerHTML = "구매하러 가기 🚀 (+8 포인트 적립)"
          }

          if (!data['etc_product']) {
            product_url = data['url']
            document.getElementsByClassName('page-icon')[0].getElementsByTagName("img")[0].src = data['p_img_url']

            let high_price_list = data['high_price_list']
            let low_price_list = data['low_price_list']

            let highest_price = Math.max(...high_price_list)
            let lowest_price = Math.min(...low_price_list)

            let highest_price_index = get_last_index_by_value(high_price_list, highest_price)
            let lowest_price_index = get_last_index_by_value(low_price_list, lowest_price)

            document.getElementById('now_price').innerHTML = data['price'].toLocaleString() + '원'
            document.getElementById('highest_price').innerHTML = highest_price.toLocaleString() + '원'
            document.getElementById('lowest_price').innerHTML = lowest_price.toLocaleString() + '원'
            document.getElementById('highest_date').innerHTML = data['date_list'][highest_price_index]
            document.getElementById('lowest_date').innerHTML = data['date_list'][lowest_price_index]
            if (data['etc_price_type'] != undefined && data['etc_price_type'] != "") {
              document.getElementById('etc_price_type').innerHTML = data['etc_price_type']

              let diff_percent = (((data['etc_price'] - data['price']) / data['price']) * 100).toFixed(1)
              let diff_percent_html

              if (diff_percent > 0) {
                diff_percent_html = "<span style='color: rgb(255,115,105)'>" + data['etc_price'].toLocaleString() + "원</span><br/>"
                diff_percent_html +=
                  "<span style='color: rgb(255,115,105)'>(" + diff_percent + "%, " + (data['etc_price'] - data['price']).toLocaleString() + "원" + ")</span>"
              } else {
                diff_percent_html = "<span style='color: rgb(82,156,202)'>" + data['etc_price'].toLocaleString() + "원</span><br/>"
                diff_percent_html +=
                  "<span style='color: rgb(82,156,202)'>(" + diff_percent + "%, " + (data['etc_price'] - data['price']).toLocaleString() + "원" + ")</span>"
              }

              document.getElementById('etc_price').innerHTML = diff_percent_html
              document.getElementById('etc_description').style.display = '';
            }

            if (data['card_benefit'] == true) {
              document.getElementById('card_benefit').innerHTML = "💳 " + data['card_benefit_detail']
            }

            let show_highest_price = true
            if (highest_price === lowest_price && highest_price_index === lowest_price_index) {
              show_highest_price = false
            }

            let options = {
              series: [
                {
                  name: "최고가",
                  data: high_price_list
                },
                {
                  name: "최저가",
                  data: low_price_list
                }
              ],
              theme: {
                mode: 'dark',
                // palette: 'palette1',
                monochrome: {
                  enabled: false,
                  color: '#255aee',
                  shadeTo: 'light',
                  shadeIntensity: 0.65
                },
              },
              chart: {
                zoom: false,
                background: '#2f3437',
                height: 500,
                type: 'line',
                toolbar: {
                  show: false
                },
                events: {
                  animationEnd: function (chartContext, options) {
                    document.getElementsByClassName('apexcharts-canvas')[0].style.width =
                      document.getElementsByClassName('apexcharts-canvas')[0].clientWidth + 42 + "px";
                    // document.getElementsByClassName('apexcharts-toolbar')[0].style.marginRight = "12px";
                    document.getElementsByClassName('apexcharts-svg')[0].style.width = "100%";
                    // document.getElementsByClassName('apexcharts-toolbar')[0].style.display = '';
                  },
                  updated: function (chartContext, options) {
                    // document.getElementsByClassName('apexcharts-toolbar')[0].style.display = 'none';
                    document.getElementsByClassName('apexcharts-canvas')[0].style.width =
                      document.getElementsByClassName('apexcharts-canvas')[0].clientWidth + 42 + "px";
                    // document.getElementsByClassName('apexcharts-toolbar')[0].style.marginRight = "12px";
                    document.getElementsByClassName('apexcharts-svg')[0].style.width = "100%";
                  }
                }
              },
              dataLabels: {
                offsetX: 0,
                textAnchor: 'middle',
                // textAnchor: 'middle',    // array 개수를 기준으로 판단 필요 TODO
                enabled: true,
                formatter: function (val, opts) {
                  if (show_highest_price && opts.seriesIndex == 0 && opts.dataPointIndex === highest_price_index) {
                    return "최고가: " + val.toLocaleString('ko-KR') + "원"
                  }

                  if (opts.seriesIndex == 1 && opts.dataPointIndex === lowest_price_index) {
                    return "최저가: " + val.toLocaleString('ko-KR') + "원"
                  }
                }
              },
              colors: ["rgb(255,115,105)", "rgb(82,156,202)"],
              stroke: {
                width: [1, 1],
                curve: 'smooth'
              },
              xaxis: {
                categories: data['date_list']
              },
              tooltip: {
                y: {
                  formatter: function (value, {series, seriesIndex, dataPointIndex, w}) {
                    return value.toLocaleString('ko-KR') + "원"
                  }
                }
              },
              grid: {
                borderColor: '#f1f1f1',
              }
            };

            var chart = new ApexCharts(document.querySelector("#chart"), options);
            chart.render();

            setTimeout(function () {
              document.title = data['p_nm'];
              document.getElementsByTagName("h1")[0].innerHTML = data['p_nm'];
              product_url = data['url']
              document.getElementsByClassName('page-icon')[0].getElementsByTagName("img")[0].src = data['p_img_url']
              if (data['get_point']) {
                document.getElementById('detail_item_link_alrimi').innerHTML = "구매하러 가기 🚀 (+8 포인트 적립)"
              }

              let notionLinks = document.querySelectorAll('a.notion-link-token');

              for (let i = 0; i < notionLinks.length; i++) {
                let link = notionLinks[i];
                if (link.href === '<https://t.me/coupang_alarm_bot>') {
                  link.style.display = 'none';
                }
              }
            }, 200);
          }
        });
    }

    function get_last_index_by_value(arr, value) {
      for (let index = arr.length - 1; index >= 0; index--) {
        if (arr[index] === value) {
          return index;
        }
      }
    }

    function apply_event() {
      let product_id = getParam('id')
      let a_id = getParam('a_id')
      let u_id = getParam('u_id')
      fetch("<https://fnf4ts3qrj.execute-api.ap-northeast-2.amazonaws.com/default/get_product_detail?type=click&>" +
            "id=" + product_id + "&u_id=" + u_id + "&a_id=" + a_id)
        .catch(error => {
          console.error('Error fetching data:', error);
        });
      window.open(product_url);
    }

    function add_product() {
      window.open('<https://t.me/coupang_alarm_bot?start=a_p_>' + getParam('id'));
    }
  </script>
</head>
<body>
<section style="overflow: hidden;">
  <table class="table table-striped table-dark" style="margin-bottom:0">
    <thead>
    <!--        <tr style="background-color: #2f3437;">-->
    <!--            <th scope="col"></th>-->
    <!--            <th scope="col">가격</th>-->
    <!--            <th scope="col">날짜</th>-->
    <!--        </tr>-->
    </thead>
    <tbody>
    <tr style="background-color: #464b51;">
      <td>현재가</td>
      <td id="now_price"></td>
      <td id="card_benefit"></td>
    </tr>
    <tr style="background-color: #2f3437;color: rgb(82,156,202)">
      <td>최저가</td>
      <td id="lowest_price"></td>
      <td id="lowest_date"></td>
    </tr>
    <tr style="background-color: #464b51;color: rgb(255,115,105)">
      <td>최고가</td>
      <td id="highest_price"></td>
      <td id="highest_date"></td>
    </tr>
    <tr id="etc_description" style="background-color: #2f3437; display: none">
      <td id="etc_price_type"></td>
      <td id="etc_price"></td>
      <td>현재가 대비</td>
    </tr>
    </tbody>
  </table>
  <div id="chart" style="background-color: #2f3437; min-height: 500px"></div>
</section>
<div id="detail_item_link">
  <a href="#" onclick="add_product()" id="detail_item_link_alrimi" class="cta" rel="noreferrer" style="display: none">최저가 알림 받기 🔔</a>
  <a href="#" onclick="apply_event()" id="detail_item_link_shop" class="cta" rel="noreferrer" style="display: none">구매하러 가기 🚀</a>
</div>
</body>
<!-- display_footer -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-6350989486427019"
     data-ad-slot="3060063943"
     data-ad-format="auto"
     data-full-width-responsive="true"></ins>
<script>
     (adsbygoogle = window.adsbygoogle || []).push({});
</script>