<style> .pDr, .pDt.p, .brdCmb, .pTtl.aTtl.sml, .pHead { display: none !important; } </style>
<!DOCTYPE html>
<html lang="vi">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

   <style>
.info-container{display:flex;flex-direction:column;align-items:center;margin-bottom:20px;position:relative}.cover{max-width:160px;height:auto;text-align:center;margin-bottom:10px;position:relative;overflow:hidden;border-radius:15px}.cover img{width:100%;height:auto;object-fit:cover;border-radius:15px;aspect-ratio:2 / 3}.ribbon-RenamedCL{position:absolute;top:-19px;right:0;background:linear-gradient(135deg,#FFA726,#FB8C00);color:white;font-size:5px;font-weight:bold;text-transform:uppercase;padding:5.2px 8px 5.2px 8px;border-bottom-left-radius:8px;border-bottom-right-radius:8px;box-shadow:0 4px 6px rgba(0,0,0,0.3);z-index:1}.ribbon-RenamedCL span{font-size:7px;margin-right:14px;display:block;font-weight:bold;transform:translateY(10px)}.circle-RenamedCL{position:absolute;top:-3px;right:-5px;width:25px;height:25px;background-color:white;border-radius:50%;display:flex;align-items:center;justify-content:center;z-index:2}.circle-RenamedCL svg{width:14px;height:14px;margin-top:4px;margin-left:-4px}.details{text-align:center;border-radius:8px}.details h2{margin-bottom:0;margin-top:0}.details p{margin:10px 0}.link{margin-top:20px;text-align:center}.custom-button{border:none;color:#fff;background-color:var(--linkB);font-family:inherit;font-size:15px;padding:0.5em 1.2em;cursor:pointer;border-radius:25px}.chapters-wrapper{max-height:300px;width:100%;max-width:none;overflow-y:auto;overflow-x:auto;border-radius:6px;border:1px solid var(--contentL);background:var(--contentB)}.chapters-wrapper::-webkit-scrollbar{display:none}.chapter{display:flex;align-items:center;margin-bottom:1px;padding:4px;font-size:15px;white-space:nowrap}.chapter svg{flex-shrink:0;width:14px;height:14px}.chapter-status{margin-left:5px}.chapter-name{flex:1;display:block;padding-left:5px;cursor:pointer;text-decoration:none;color:var(--contentBd);overflow-x:auto;text-overflow:ellipsis;white-space:nowrap;-webkit-overflow-scrolling:touch;user-select:none;max-width:auto}.chapter-name:hover{color:var(--linkB)}.chapter-name::-webkit-scrollbar{display:none}.chapter-time{font-size:12px;color:var(--contentBd);margin-left:10px}.genre-container{display:flex;flex-wrap:wrap;gap:8px;justify-content:center;align-items:center;text-align:center}.genre-label{border:1px solid var(--contentL);color:var(--bodyC);background:var(--contentB);padding:0 6px;cursor:pointer;font-size:14px;user-select:none}.genre-label a{color:inherit;text-decoration:none}.genre-label:hover{background-color:var(--linkB);color:white!important}.genre-label:hover a{color:white!important}#total-chapters-title{display:flex;justify-content:space-between;align-items:center;position:sticky;top:0;z-index:1;border-bottom:1px solid var(--contentL);background:var(--contentB);padding:2px 8px;color:var(--linkB)}#order-toggle{font-size:14px;cursor:pointer;color:var(--linkB)}.svg-chapter-icon{margin-left:1px;margin-right:5px;vertical-align:middle;width:18px;height:18px;transform:translateY(-2px)}.loader{display:block;border:4px solid rgba(0,0,0,0.1);border-left-color:var(--linkB);border-radius:50%;width:24px;height:24px;animation:loader 1s linear infinite;margin:0 auto;margin-bottom:10px}@keyframes loader{to{transform:rotate(360deg)}}</style>
</head>
<body>
          <div id="loader" class="loader"></div>
    <div class="info-container">
        <div class="cover" id="cover"></div>
        <div class="details" id="details"></div>
    </div>

      <div class="container">

<div class="chapters-wrapper" style="display:none;"> 
            <div id="total-chapters-title" class="total-chapters-title"></div>
            <div id="chapters"></div>
        </div>
    </div>
  
    <div class="introduction-container" id="introduction" style="display:none;">
        <blockquote class="s2">
            <p id="intro-text" style="text-align: justify;"></p>
            <span id="author-name"></span>
        </blockquote>
    </div>

<script>document.addEventListener('DOMContentLoaded',function(){document.getElementById('loader').style.display='block';const apiUrl=`https://script.google.com/macros/s/AKfycbyGvZthyMDAq4fry2di-VoXh69gHQXDjqSAsHioGAfYDwtxtbPehfNvCvdRdWxV6ch7/exec?title=${encodeURIComponent(tabName)}`;fetch(apiUrl).then(response=>response.json()).then(data=>{document.getElementById('loader').style.display='none';if(data.error){document.getElementById("details").innerHTML=`<p>${data.error}</p>`;return}
if(!data||Object.keys(data).length===0){document.getElementById("details").innerHTML="<p>Không tìm thấy thông tin cho truyện này.</p>";return}
const story=data;const formattedIntroduction=story['Giới thiệu']?.replace(/\n+/g,'<div style="margin-top: 8px;"></div>')||"Chưa có thông tin.";const cmntElement=document.querySelector('.cmnt');const commentCount=cmntElement&&cmntElement.hasAttribute('data-text')?cmntElement.getAttribute('data-text'):'0';const authorLink=`https://www.kunsnovel.pro.vn/p/search.html?tacgia=${encodeURIComponent(story['Tác giả'])}`;const tinhtrangLink=`https://www.kunsnovel.pro.vn/p/search.html?tinhtrang=${encodeURIComponent(story['Tình trạng'])}`;const hasLockedChapter=story.Chương.some(chapter=>chapter.status==='Locked');const LockedorOpen=hasLockedChapter?"Có khóa":"Không khóa";const genreLabels=`
  <div class="genre-container">
    ${story['Thể loại'].split(',').map(genre => {
      return `<span class="genre-label"><a href="https://www.kunsnovel.pro.vn/p/search.html?theloai=${encodeURIComponent(genre.trim())}" target="_self">${genre.trim()}</a></span>`;
    }).join(' ')}
  </div>
`;document.getElementById("cover").innerHTML=`
    <div class="cover">
        <img src="${story['Url bìa']}" alt="${story['Tác phẩm']}">
        <!-- Thêm ribbon và SVG -->
        ${generateRibbonAndSVG(story['Tình trạng'])}
    </div>
`;function generateRibbonAndSVG(status){let background,gradientId,svgPath,label;switch(status){case "Đang viết":gradientId="gradient-writing";svgPath=`
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none">
  <defs>
    <linearGradient id="gradient-writing" x1="0%" y1="0%" x2="100%" y2="100%">
      <stop offset="0%" stop-color="#FFA726" />
      <stop offset="100%" stop-color="#FB8C00" />
    </linearGradient>
  </defs>
  <!-- Đường chữ nhật -->
  <rect x="4" y="16" width="16" height="4" rx="2" fill="none" stroke="url(#gradient-writing)" stroke-width="3"></rect>
  <!-- Hình tam giác -->
  <path d="M4.90949 11.3642L8 16H16L19.0905 11.3642C19.5259 10.7112 19.7436 10.3847 19.7083 10.0289C19.6731 9.67311 19.3956 9.39561 18.8406 8.84062L12 2L5.15938 8.84062C4.60439 9.39561 4.32689 9.67311 4.29166 10.0289C4.25643 10.3847 4.47412 10.7112 4.90949 11.3642Z" fill="none" stroke="url(#gradient-writing)" stroke-width="3"></path>
  <!-- Hình tròn -->
  <circle cx="12" cy="11" r="2" fill="none" stroke="url(#gradient-writing)" stroke-width="3"></circle>
  <!-- Đường thẳng -->
  <path d="M12 2V9" fill="none" stroke="url(#gradient-writing)" stroke-width="3"></path>
</svg>

`;background="linear-gradient(135deg, #FFA726, #FB8C00)";label="Đang viết";break;case "Tạm ngừng":gradientId="gradient-paused";svgPath=`
 <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512.149 512.149" fill="none">
  <defs>
    <linearGradient id="gradient-paused" x1="0%" y1="0%" x2="100%" y2="100%">
      <stop offset="0%" stop-color="#FF5252" />
      <stop offset="100%" stop-color="#D32F2F" />
    </linearGradient>
  </defs>
  <g transform="translate(-1)">
    <g>
      <path d="M504.427,111.44l-1.253-1.254c-11.776-11.776-30.967-11.802-42.814,0.035l-46.089,46.574 c-2.428,2.436-6.312,2.534-8.845,0.203l-64.618-59.657c-6.276-5.8-14.442-8.987-22.996-8.987h-96.124 c-2.269,0-4.44,0.865-6.082,2.419l-81.47,77.356c-11.935,11.944-12.756,31.197-1.818,42.92 c5.844,6.268,13.736,9.719,22.219,9.719h0.15c8.413-0.044,16.499-3.619,22.087-9.728l57.538-60.893h20.595L120.63,300.218H37.81 c-19.633,0-35.778,14.68-36.758,33.421c-0.521,9.79,2.904,19.094,9.64,26.191c6.638,7,15.969,11.008,25.618,11.008h123.586 c2.436,0,4.767-1.006,6.444-2.798l63.32-67.593l53.248,55.684l-16.075,102.735c-4.052,17.02,4.114,34.357,19.412,41.198 c4.714,2.119,9.719,3.178,14.698,3.178c5.358,0,10.69-1.227,15.598-3.655c9.481-4.696,16.296-13.285,18.776-23.967 l27.463-147.306c0.53-2.86-0.38-5.809-2.445-7.865l-73.295-73.198l58.227-58.138l40.589,40.58 c11.335,11.335,31.091,11.335,42.417,0l76.156-76.147c5.623-5.623,8.722-13.109,8.722-21.054 C513.149,124.54,510.05,117.063,504.427,111.44z" fill="url(#gradient-paused)" />
      <path d="M407.065,114.837c29.211,0,52.966-23.755,52.966-52.966c0-29.211-23.755-52.966-52.966-52.966 c-29.21,0-52.966,23.755-52.966,52.966C354.1,91.082,377.855,114.837,407.065,114.837z" fill="url(#gradient-paused)" />
    </g>
  </g>
</svg>

 `;background="linear-gradient(135deg, #FF5252, #D32F2F)";label="Tạm ngừng";break;case "Hoàn thành":gradientId="gradient-completed";svgPath=`
      <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
  <defs>
    <linearGradient id="gradient-complete" x1="0%" y1="0%" x2="100%" y2="100%">
      <stop offset="0%" stop-color="#42A5F5" />
      <stop offset="100%" stop-color="#1E88E5" />
    </linearGradient>
  </defs>
  <path
    d="M16.19 2H7.81C4.17 2 2 4.17 2 7.81V16.18C2 19.83 4.17 22 7.81 22H16.18C19.82 22 21.99 19.83 21.99 16.19V7.81C22 4.17 19.83 2 16.19 2ZM11.5 17.25C11.5 17.61 11.14 17.85 10.81 17.71C9.6 17.19 8.02 16.71 6.92 16.57L6.73 16.55C6.12 16.47 5.62 15.9 5.62 15.28V7.58C5.62 6.81 6.24 6.24 7 6.3C8.25 6.4 10.1 7 11.26 7.66C11.42 7.75 11.5 7.92 11.5 8.09V17.25ZM18.38 15.27C18.38 15.89 17.88 16.46 17.27 16.54L17.06 16.56C15.97 16.71 14.4 17.18 13.19 17.69C12.86 17.83 12.5 17.59 12.5 17.23V8.08C12.5 7.9 12.59 7.73 12.75 7.64C13.91 6.99 15.72 6.41 16.95 6.3H16.99C17.76 6.3 18.38 6.92 18.38 7.69V15.27Z"
    stroke="url(#gradient-complete)"
    fill="none"
    stroke-width="3"
  />
</svg>

`;background="linear-gradient(135deg, #42A5F5, #1E88E5)";label="Hoàn thành";break}
return `
    <div class="ribbon-RenamedCL" style="background: ${background}">
      <span>${label}</span>
    </div>
    <div class="circle-RenamedCL">
      ${svgPath}
    </div>
  `}
document.getElementById("details").innerHTML=`
        <h2>${story['Tác phẩm']}</h2>
        <p>
    <strong>${story['Số chương']}
<svg class="svg-chapter-icon" class='c' viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path class='line' d="M16.1898 2H7.81976C4.17976 2 2.00977 4.17 2.00977 7.81V16.18C2.00977 19.82 4.17976 21.99 7.81976 21.99H16.1898C19.8298 21.99 21.9998 19.82 21.9998 16.18V7.81C21.9998 4.17 19.8298 2 16.1898 2Z" fill="#292D32"></path> <path class='line' d="M11.4991 8.09V17.25C11.4991 17.61 11.1391 17.85 10.8091 17.71C9.59914 17.19 8.01913 16.71 6.91913 16.57L6.72913 16.55C6.11913 16.47 5.61914 15.9 5.61914 15.28V7.57999C5.61914 6.81999 6.23915 6.25 6.99915 6.31C8.24915 6.41 10.0992 7.01001 11.2592 7.67001C11.4092 7.74001 11.4991 7.91 11.4991 8.09Z" fill="#292D32"></path> <path class='line' d="M18.38 7.69983V15.2698C18.38 15.8898 17.88 16.4598 17.27 16.5398L17.06 16.5598C15.97 16.7098 14.4 17.1798 13.19 17.6898C12.86 17.8298 12.5 17.5898 12.5 17.2298V8.0798C12.5 7.8998 12.59 7.72983 12.75 7.63983C13.91 6.98983 15.72 6.4098 16.95 6.2998H16.99C17.76 6.3098 18.38 6.92983 18.38 7.69983Z" fill="#292D32"></path> </g></svg>
    </strong>
    
    <strong>${story['Tổng số lượt xem']}
<svg <svg class="svg-chapter-icon" class='c' viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path class='line' d="M21.25 9.14993C18.94 5.51993 15.56 3.42993 12 3.42993C10.22 3.42993 8.49 3.94993 6.91 4.91993C5.33 5.89993 3.91 7.32993 2.75 9.14993C1.75 10.7199 1.75 13.2699 2.75 14.8399C5.06 18.4799 8.44 20.5599 12 20.5599C13.78 20.5599 15.51 20.0399 17.09 19.0699C18.67 18.0899 20.09 16.6599 21.25 14.8399C22.25 13.2799 22.25 10.7199 21.25 9.14993ZM12 16.0399C9.76 16.0399 7.96 14.2299 7.96 11.9999C7.96 9.76993 9.76 7.95993 12 7.95993C14.24 7.95993 16.04 9.76993 16.04 11.9999C16.04 14.2299 14.24 16.0399 12 16.0399Z" fill="#292D32"></path> <path class='line' d="M12.0004 9.13989C10.4304 9.13989 9.15039 10.4199 9.15039 11.9999C9.15039 13.5699 10.4304 14.8499 12.0004 14.8499C13.5704 14.8499 14.8604 13.5699 14.8604 11.9999C14.8604 10.4299 13.5704 9.13989 12.0004 9.13989Z" fill="#292D32"></path> </g></svg>
      </strong>
          <strong>${story['Tổng lượt mở khóa']}
<svg class="svg-chapter-icon" class='c' viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path class='line' d="M2 16C2 13.1716 2 11.7574 2.87868 10.8787C3.75736 10 5.17157 10 8 10H16C18.8284 10 20.2426 10 21.1213 10.8787C22 11.7574 22 13.1716 22 16C22 18.8284 22 20.2426 21.1213 21.1213C20.2426 22 18.8284 22 16 22H8C5.17157 22 3.75736 22 2.87868 21.1213C2 20.2426 2 18.8284 2 16Z" stroke="#1C274C" stroke-width="1.5"></path> <circle cx="12" cy="16" r="2" stroke="#1C274C" stroke-width="1.5"></circle> <path class='line' d="M6 10V8C6 4.68629 8.68629 2 12 2C14.7958 2 17.1449 3.91216 17.811 6.5" stroke="#1C274C" stroke-width="1.5" stroke-linecap="round"></path> </g></svg>
      </strong>
          <strong>${commentCount}
<svg class="svg-chapter-icon"  class='line' viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <g clip-path="url(#clip0_429_11106)"> <path  class='line' d="M12 21C16.9706 21 21 16.9705 21 12C21 7.02941 16.9706 2.99997 12 2.99997C7.02944 2.99997 3 7.02941 3 12C3 13.4876 3.36093 14.8909 4 16.1272L3 21L7.8728 20C9.10904 20.639 10.5124 21 12 21Z" stroke="#292929" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"></path> <rect  class='line' x="7.5" y="12" width="0.01" height="0.01" stroke="#292929" stroke-width="4.75" stroke-linejoin="round"></rect> <rect  class='line' x="12" y="12" width="0.01" height="0.01" stroke="#292929" stroke-width="4.75" stroke-linejoin="round"></rect> <rect  class='line' x="16.5" y="12" width="0.01" height="0.01" stroke="#292929" stroke-width="4.75" stroke-linejoin="round"></rect> </g> <defs> <clipPath id="clip0_429_11106"> <rect width="24" height="24" fill="white"></rect> </clipPath> </defs> </g></svg>
      </strong> <!-- Số bình luận từ data-text -->
        </p>
<p>
    <strong></strong>
    <a href="${authorLink}" target="_self" style="color: var(--bodyC);">
        ${story['Tác giả']}
    </a>
    |
    <strong></strong>
    <a href="${tinhtrangLink}" target="_self" style="color: var(--bodyC);">
        ${story['Tình trạng']}
    </a>
    |
    <strong></strong>
    <span style="color: var(--bodyC);">${LockedorOpen}</span>
</p>

        <p><strong></strong> ${genreLabels}</p>
        <div class="link">
          <a href="${story['Link tác phẩm']}" target="_self">
            <button class="custom-button">ĐỌC NGAY</button>
          </a>
        </div>
      `;document.getElementById("intro-text").innerHTML=formattedIntroduction;document.getElementById("author-name").innerHTML=story['Tác giả'];displayChapters(story.Chương);document.querySelector('.chapters-wrapper').style.display='block';document.querySelector('.introduction-container').style.display='block'}).catch(error=>{console.error("Error fetching data:",error);document.getElementById("details").innerHTML="<p>Đã xảy ra lỗi khi tải dữ liệu.</p>";document.getElementById('loader').style.display='none'})});let isNewestFirst=!0;function displayChapters(chapters){const chaptersContainer=document.getElementById('chapters');chaptersContainer.innerHTML='';const totalChaptersTitle=document.getElementById('total-chapters-title');totalChaptersTitle.innerHTML=`
    <span><b>Hiện có: ${chapters.length} chương</b></span>
    <span id="order-toggle"><b>${isNewestFirst ? "Mới nhất ⇈" : "Cũ nhất ⇊"}</b></span>
  `;document.getElementById('order-toggle').addEventListener('click',()=>{isNewestFirst=!isNewestFirst;displayChapters([...chapters].reverse())});chapters.forEach(chapter=>{const chapterDiv=document.createElement('div');chapterDiv.className='chapter';const lockIcon=chapter.status==='Locked'?`<svg class='c' viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><g id="SVGRepo_bgCarrier" stroke-width="0"></g><g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"></g><g id="SVGRepo_iconCarrier"> <path class='line' d="M2 16C2 13.1716 2 11.7574 2.87868 10.8787C3.75736 10 5.17157 10 8 10H16C18.8284 10 20.2426 10 21.1213 10.8787C22 11.7574 22 13.1716 22 16C22 18.8284 22 20.2426 21.1213 21.1213C20.2426 22 18.8284 22 16 22H8C5.17157 22 3.75736 22 2.87868 21.1213C2 20.2426 2 18.8284 2 16Z" stroke="#1C274C" stroke-width="1.5"></path> <circle class='line' cx="12" cy="16" r="2" stroke="#1C274C" stroke-width="1.5"></circle> <path class='line' d="M6 10V8C6 4.68629 8.68629 2 12 2C15.3137 2 18 4.68629 18 8V10" stroke="#1C274C" stroke-width="1.5" stroke-linecap="round"></path> </g></svg>`:`<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"></svg>`;chapterDiv.innerHTML=`
      <div class="chapter-status">${lockIcon}</div>
<div class="chapter-name" onclick="window.location.href = 'https://www.kunsnovel.pro.vn/p/read.html?id=${encodeURIComponent(tabName)}&chap=${encodeURIComponent(chapter.Chap)}'">
        <div>${chapter.Chap}</div>
      </div>
      <div class="chapter-time">${chapter.time}</div>
    `;chaptersContainer.appendChild(chapterDiv)})}</script>
</body>
</html>
