...
This commit is contained in:
@@ -1,6 +1,26 @@
|
||||
let isRunning = false;
|
||||
let currentUrl = location.href;
|
||||
|
||||
function hideSpecificImages() {
|
||||
const style = document.createElement('style');
|
||||
style.innerHTML = `
|
||||
img[src*=".webp"],
|
||||
img[src*=".png"],
|
||||
img[src*=".gif"],
|
||||
img[src*=".jpg"],
|
||||
source[type="image/webp"],
|
||||
source[type="image/png"],
|
||||
source[type="image/jpg"],
|
||||
source[type="image/gif"] {
|
||||
display: none !important;
|
||||
}
|
||||
`;
|
||||
document.head.appendChild(style);
|
||||
}
|
||||
|
||||
// 스크립트 로드 시 즉시 실행
|
||||
hideSpecificImages();
|
||||
|
||||
// 메인 스크래핑 로직을 별도의 함수로 분리
|
||||
async function runScraper() {
|
||||
if (isRunning) return; // 중복 실행 방지
|
||||
|
||||
@@ -63,13 +63,20 @@
|
||||
//// browser.runtime.sendMessage({ type: 'RELOAD_REQUEST' });
|
||||
//// }
|
||||
////});
|
||||
|
||||
browser.webRequest.onBeforeRequest.addListener(
|
||||
function(details) {
|
||||
console.log("Request intercepted for URL:", details.url);
|
||||
// 이 예시는 단순히 로그를 남기므로 요청을 변경하거나 차단하지 않음
|
||||
// 페이지 자체를 이동(main_frame)하는 요청인지 확인
|
||||
if (details.type === "main_frame") {
|
||||
const currentUrl = details.originUrl || details.documentUrl || "";
|
||||
|
||||
// 현재 URL에 'darama'가 포함되어 있는데, 이동할 URL에는 'darama'가 없다면 차단
|
||||
if (currentUrl.includes("darama") && !details.url.includes("darama")) {
|
||||
console.log("Redirect blocked for URL:", details.url);
|
||||
return { cancel: true };
|
||||
}
|
||||
}
|
||||
return {};
|
||||
},
|
||||
{urls: ["<all_urls>"]}, // 모든 URL에 대해 요청 듣기
|
||||
[]
|
||||
{urls: ["<all_urls>"]},
|
||||
["blocking"] // 요청을 차단할 수 있는 권한 부여
|
||||
);
|
||||
File diff suppressed because one or more lines are too long
@@ -1,4 +1,29 @@
|
||||
if (location.href.includes("darama")) {
|
||||
const observer = new MutationObserver((mutations) => {
|
||||
mutations.forEach((mutation) => {
|
||||
mutation.addedNodes.forEach((node) => {
|
||||
// 추가된 노드 자체가 iframe인 경우
|
||||
if (node.tagName === 'IFRAME') {
|
||||
node.remove();
|
||||
console.log("Blocked dynamic iframe");
|
||||
}
|
||||
// 노드 내부에 자식 요소로 iframe이 포함되어 추가된 경우
|
||||
else if (node.nodeType === Node.ELEMENT_NODE && node.querySelectorAll) {
|
||||
node.querySelectorAll('iframe').forEach(iframe => {
|
||||
iframe.remove();
|
||||
console.log("Blocked nested dynamic iframe");
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// 문서 전체의 자식 노드 추가를 실시간으로 감시
|
||||
observer.observe(document.documentElement, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function pubDateNumber(tdateTime) {
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,16 @@
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function(details) {
|
||||
if (details.type === "main_frame") {
|
||||
const currentUrl = details.originUrl || details.documentUrl || "";
|
||||
|
||||
// 현재 URL에 'darama'가 포함되어 있는데, 이동할 URL에는 'darama'가 없다면 차단
|
||||
if (currentUrl.includes("darama") && !details.url.includes("darama")) {
|
||||
console.log("Redirect blocked for URL:", details.url);
|
||||
return { cancel: true };
|
||||
}
|
||||
}
|
||||
return {};
|
||||
},
|
||||
{ urls: ["<all_urls>"] },
|
||||
["blocking"] // 요청을 가로채고 취소할 수 있는 권한
|
||||
);
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"version": "1.0",
|
||||
"name": "Darama AdBlocker",
|
||||
"background": {
|
||||
"scripts": ["background.js"]
|
||||
},
|
||||
"content_scripts": [
|
||||
{
|
||||
"run_at": "document_start",
|
||||
"matches": ["<all_urls>"],
|
||||
"js": ["messaging.js"]
|
||||
}
|
||||
],
|
||||
"permissions": [
|
||||
"cookies",
|
||||
"<all_urls>",
|
||||
"webRequest",
|
||||
"webRequestBlocking"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
// 1. 페이지 로드 시 정적 광고 및 불필요한 요소 즉시 제거
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
handleCommon(document);
|
||||
// applyDomainRules();
|
||||
});
|
||||
|
||||
// 2. DOM 변화를 실시간 감시하여 동적 아이프레임 및 광고 추가 완벽 차단
|
||||
const observer = new MutationObserver((mutations) => {
|
||||
mutations.forEach((mutation) => {
|
||||
mutation.addedNodes.forEach((node) => {
|
||||
if (node.nodeType !== Node.ELEMENT_NODE) return;
|
||||
|
||||
// [darama 도메인] 동적으로 삽입되는 iframe 즉시 삭제
|
||||
if (location.href.includes("darama")) {
|
||||
if (node.tagName === 'IFRAME') {
|
||||
node.remove();
|
||||
} else if (node.querySelectorAll) {
|
||||
node.querySelectorAll('iframe').forEach(iframe => iframe.remove());
|
||||
}
|
||||
}
|
||||
|
||||
// 동적으로 삽입되는 공통 광고 노드 지속 삭제
|
||||
handleCommon(node);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
observer.observe(document.documentElement, {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
|
||||
// 3. 공통 광고 요소 제거 함수 (정적/동적 DOM 모두 대응)
|
||||
function handleCommon(parentElement) {
|
||||
if (!parentElement.querySelectorAll) return;
|
||||
|
||||
// const adSelectors = [
|
||||
// ".top_google_ad_space", ".adv-group", "[id^='div-gpt-ad']",
|
||||
// "[id^='div_adnmore_area']", "[class^='adv-groupno']", ".code-block",
|
||||
// ".ad-template", "#xpromo-bottom-sheet", "[data-banner^='coupang-']",
|
||||
// "[id^='mobonDivBanner']", "[id^='pnlTopAd']", "[class^='ad-tag']",
|
||||
// "[class^='science-banner-area']"
|
||||
// ];
|
||||
//
|
||||
// adSelectors.forEach(selector => {
|
||||
// parentElement.querySelectorAll(selector).forEach(e => e.remove());
|
||||
// });
|
||||
|
||||
// parentElement.querySelectorAll('iframe').forEach(e => {
|
||||
// const src = e.getAttribute("src");
|
||||
// if (src && (src.includes("ads") || src.includes("coupang"))) {
|
||||
// e.remove();
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
// 4. 도메인별 맞춤형 요소 제거 (기존 룰 단순화)
|
||||
function applyDomainRules() {
|
||||
const url = location.href;
|
||||
|
||||
if (url.includes("nate.com")) {
|
||||
document.querySelectorAll('[class^="float-adv-wrap"], [id^="ad_"], #ad_sponsorBar, #newsSidebar, iframe[id^="ad"]').forEach(e => e.remove());
|
||||
} else if (url.includes("zdnet.co.kr")) {
|
||||
document.querySelectorAll('div[id*="FloatCon"]').forEach(e => e.remove());
|
||||
} else if (url.includes("inews24")) {
|
||||
document.querySelectorAll('ad[alt^="a"], div[class^="topnews"], form[class^="talkplus"], ins, footer').forEach(e => e.remove());
|
||||
} else if (url.includes("starnewskorea")) {
|
||||
document.querySelectorAll('div[class^="floating-top-ad"], div[id^="dablewidget_"], footer').forEach(e => e.remove());
|
||||
} else if (url.includes("khan.co.kr")) {
|
||||
document.querySelectorAll('[class^="banner-"], [class^="google-auto-placed"], footer, iframe').forEach(e => e.remove());
|
||||
} else if (url.includes("dcinside.com")) {
|
||||
document.querySelectorAll('[id^="view_btn_area"], [class^="trend-rank"], [class^="adv-group"], [id^="div_adnmore_area"]').forEach(e => e.remove());
|
||||
} else if (url.includes("fmkorea.com")) {
|
||||
document.querySelectorAll('[class^="fmad_wrapper"], [class^="ad ad_wrapper"], [class^="m_top_hotdeal"]').forEach(e => e.remove());
|
||||
} else if (url.includes("theqoo.net")) {
|
||||
document.querySelectorAll('[class^="board_content_google_ad"], ins[class^="adsbygoogle"]').forEach(e => e.remove());
|
||||
}
|
||||
}
|
||||
@@ -185,7 +185,7 @@
|
||||
text-align: left;
|
||||
border-top: 1px solid var(--border-color);
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
/* 💡 Grid 대신 Flex Column으로 변경하여 세로 스크롤에 최적화 */
|
||||
/* Grid 대신 Flex Column으로 변경하여 세로 스크롤에 최적화 */
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
@@ -203,7 +203,7 @@
|
||||
justify-content: space-between;
|
||||
box-sizing: border-box;
|
||||
width: 100%;
|
||||
flex-shrink: 0; /* 💡 핵심: 화면이 좁아도 세로로 절대 찌그러지지 않게 강제 방어 */
|
||||
flex-shrink: 0; /* 핵심: 화면이 좁아도 세로로 절대 찌그러지지 않게 강제 방어 */
|
||||
overflow: hidden;
|
||||
transition: transform 0.15s, background 0.15s;
|
||||
}
|
||||
@@ -253,10 +253,10 @@
|
||||
<div id="library-overlay" class="overlay" style="display: none;">
|
||||
<div class="box library-box">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; flex-wrap: wrap; gap: 8px;">
|
||||
<h2 style="margin: 0;">📚 내 서재</h2>
|
||||
<h2 style="margin: 0;"> 내 서재</h2>
|
||||
<div style="display: flex; gap: 8px;">
|
||||
<select id="library-tag-filter" style="padding: 6px; border-radius: 6px; background: var(--modal-content-bg); color: var(--text-color); border: 1px solid var(--border-color); font-size: 13px; cursor: pointer;">
|
||||
<option value="all">🏷️ 전체 태그</option>
|
||||
<option value="all">️ 전체 태그</option>
|
||||
</select>
|
||||
<select id="library-sort-select" style="padding: 6px; border-radius: 6px; background: var(--modal-content-bg); color: var(--text-color); border: 1px solid var(--border-color); font-size: 13px; cursor: pointer;">
|
||||
<option value="lastRead">최근 열람순</option>
|
||||
@@ -272,10 +272,10 @@
|
||||
<button id="btn-go-new" class="btn-go-new">+ 새 책 추가하기</button>
|
||||
|
||||
<div style="display: flex; gap: 10px; margin-top: 10px;">
|
||||
<button id="btn-backup-all" style="flex: 1; padding: 10px; background: #27ae60; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: bold;">📥 전체 백업</button>
|
||||
<button id="btn-restore-main" style="flex: 1; padding: 10px; background: #8e44ad; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: bold;">📤 복원하기</button>
|
||||
<button id="btn-backup-all" style="flex: 1; padding: 10px; background: #27ae60; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: bold;"> 전체 백업</button>
|
||||
<button id="btn-restore-main" style="flex: 1; padding: 10px; background: #8e44ad; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: bold;"> 복원하기</button>
|
||||
</div>
|
||||
<button id="btn-manage-keywords" style="margin-top: 10px; width: 100%; padding: 10px; background: #e67e22; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: bold;">🏷️ 태그 및 키워드 관리</button>
|
||||
<button id="btn-manage-keywords" style="margin-top: 10px; width: 100%; padding: 10px; background: #e67e22; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: bold;">️ 태그 및 키워드 관리</button>
|
||||
|
||||
<input type="file" id="restore-input" accept=".json" style="display: none;">
|
||||
</div>
|
||||
@@ -322,13 +322,13 @@
|
||||
<div id="keyword-modal" style="display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.85); z-index: 200; align-items: center; justify-content: center;">
|
||||
<div class="box" style="width: 90%; max-width: 500px; max-height: 80vh; display: flex; flex-direction: column; padding: 20px;">
|
||||
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; border-bottom: 1px solid var(--border-color); padding-bottom: 10px;">
|
||||
<h2 style="margin: 0; font-size: 17px;">🏷️ 태그 및 키워드 관리</h2>
|
||||
<h2 style="margin: 0; font-size: 17px;">️ 태그 및 키워드 관리</h2>
|
||||
<span id="keyword-close-btn" style="cursor: pointer; font-size: 22px; color: #888;">×</span>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 8px; margin-bottom: 15px;">
|
||||
<button id="btn-backup-tags" style="flex: 1; padding: 8px; background: #27ae60; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: bold;">📥 룰만 백업</button>
|
||||
<button id="btn-restore-tags" style="flex: 1; padding: 8px; background: #8e44ad; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: bold;">📤 룰만 복원</button>
|
||||
<button id="btn-backup-tags" style="flex: 1; padding: 8px; background: #27ae60; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: bold;"> 룰만 백업</button>
|
||||
<button id="btn-restore-tags" style="flex: 1; padding: 8px; background: #8e44ad; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: bold;"> 룰만 복원</button>
|
||||
<input type="file" id="tag-restore-input" accept=".json" style="display: none;">
|
||||
</div>
|
||||
|
||||
@@ -345,7 +345,7 @@
|
||||
<button id="btn-save-keyword-rules" style="flex: 1; padding: 10px; background: #27ae60; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 13px;">저장하기</button>
|
||||
</div>
|
||||
|
||||
<button id="btn-reapply-tags" style="margin-top: 8px; width: 100%; padding: 10px; background: #8e44ad; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 13px;">🔄 전체 서재 태그 싹 다시 스캔하기</button>
|
||||
<button id="btn-reapply-tags" style="margin-top: 8px; width: 100%; padding: 10px; background: #8e44ad; color: #fff; border: none; border-radius: 6px; cursor: pointer; font-weight: bold; font-size: 13px;"> 전체 서재 태그 싹 다시 스캔하기</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -562,10 +562,10 @@
|
||||
|
||||
if (!readerId) {
|
||||
const sortSelect = document.getElementById('library-sort-select');
|
||||
const tagFilterSelect = document.getElementById('library-tag-filter'); // 🆕 태그 필터
|
||||
const tagFilterSelect = document.getElementById('library-tag-filter'); // 태그 필터
|
||||
|
||||
let currentSort = localStorage.getItem('webReader_sortOption') || 'lastRead';
|
||||
let currentTagFilter = 'all'; // 🆕 현재 선택된 태그 상태
|
||||
let currentTagFilter = 'all'; // 현재 선택된 태그 상태
|
||||
|
||||
sortSelect.value = currentSort;
|
||||
|
||||
@@ -575,7 +575,7 @@
|
||||
renderLibraryList();
|
||||
});
|
||||
|
||||
// 🆕 태그 변경 이벤트
|
||||
// 태그 변경 이벤트
|
||||
tagFilterSelect.addEventListener('change', (e) => {
|
||||
currentTagFilter = e.target.value;
|
||||
renderLibraryList();
|
||||
@@ -592,7 +592,7 @@
|
||||
return { ...book, savedData, pKey };
|
||||
});
|
||||
|
||||
// 2. 🆕 존재하는 모든 태그 수집 (중복 제거)
|
||||
// 2. 존재하는 모든 태그 수집 (중복 제거)
|
||||
const uniqueTags = new Set();
|
||||
booksWithMeta.forEach(book => {
|
||||
if (book.savedData.tags && Array.isArray(book.savedData.tags)) {
|
||||
@@ -603,8 +603,8 @@
|
||||
}
|
||||
});
|
||||
|
||||
// 3. 🆕 태그 필터 UI 업데이트 (현재 선택된 값 유지)
|
||||
tagFilterSelect.innerHTML = '<option value="all">🏷️ 전체 태그</option>';
|
||||
// 3. 태그 필터 UI 업데이트 (현재 선택된 값 유지)
|
||||
tagFilterSelect.innerHTML = '<option value="all">️ 전체 태그</option>';
|
||||
Array.from(uniqueTags).sort().forEach(tag => {
|
||||
const option = document.createElement('option');
|
||||
option.value = tag;
|
||||
@@ -613,7 +613,7 @@
|
||||
tagFilterSelect.appendChild(option);
|
||||
});
|
||||
|
||||
// 4. 🆕 태그 필터링 적용
|
||||
// 4. 태그 필터링 적용
|
||||
let filteredBooks = booksWithMeta;
|
||||
if (currentTagFilter !== 'all') {
|
||||
filteredBooks = booksWithMeta.filter(book => {
|
||||
@@ -685,7 +685,7 @@
|
||||
const totalChars = book.chapters ? book.chapters.reduce((sum, chap) => sum + (chap.content ? chap.content.length : 0), 0) : 0;
|
||||
|
||||
let progressText = savedData.chapter !== undefined ? `<span style="font-size:12px; color:#888; margin-left: 6px;">(Ch.${savedData.chapter + 1})</span>` : '';
|
||||
let bookStatsText = `<div style="font-size:11px; color:#aaa; margin-top: 4px;">📚 총 ${totalChapters}화 · ${totalChars.toLocaleString()}자</div>`;
|
||||
let bookStatsText = `<div style="font-size:11px; color:#aaa; margin-top: 4px;"> 총 ${totalChapters}화 · ${totalChars.toLocaleString()}자</div>`;
|
||||
|
||||
let tagsText = '';
|
||||
if (savedData.tags && savedData.tags.length > 0) {
|
||||
@@ -699,8 +699,8 @@
|
||||
tagsText = `<div style="margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px;">${badges}</div>`;
|
||||
}
|
||||
|
||||
let lastReadText = savedData.lastRead ? `<div style="font-size:11px; color:#aaa; margin-top: 6px;">🕒 마지막 열람: ${savedData.lastRead}</div>` : '';
|
||||
let memoText = savedData.memo ? `<div style="font-size:12px; color:#f39c12; margin-top: 6px; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;">📝 ${savedData.memo}</div>` : '';
|
||||
let lastReadText = savedData.lastRead ? `<div style="font-size:11px; color:#aaa; margin-top: 6px;"> 마지막 열람: ${savedData.lastRead}</div>` : '';
|
||||
let memoText = savedData.memo ? `<div style="font-size:12px; color:#f39c12; margin-top: 6px; display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;"> ${savedData.memo}</div>` : '';
|
||||
|
||||
const titleArea = document.createElement('div');
|
||||
titleArea.style.cssText = "flex: 1; display: flex; flex-direction: column; margin-bottom: 10px;";
|
||||
@@ -732,7 +732,7 @@
|
||||
|
||||
const isCompleted = savedData.isCompleted || false;
|
||||
const compBtn = document.createElement('button');
|
||||
compBtn.innerText = isCompleted ? "✔️ 완독" : "📖 읽는 중";
|
||||
compBtn.innerText = isCompleted ? "✔️ 완독" : " 읽는 중";
|
||||
compBtn.style.cssText = `grid-column: span 2; padding: 8px 0; background-color: ${isCompleted ? '#27ae60' : '#95a5a6'}; ${commonBtnStyle}`;
|
||||
compBtn.onclick = (e) => {
|
||||
e.stopPropagation();
|
||||
@@ -1402,11 +1402,11 @@
|
||||
// [8] 태그 및 키워드 자동 추출 로직 (+ 태그 룰 백업/복원)
|
||||
// ============================================================================
|
||||
const DEFAULT_KEYWORD_RULES = {
|
||||
"🐉 판타지": ["마법", "오크", "엘프", "드래곤", "제국", "마왕"],
|
||||
" 판타지": ["마법", "오크", "엘프", "드래곤", "제국", "마왕"],
|
||||
"⚔️ 무협": ["무림", "천마", "검기", "내공", "혈교", "무당파"],
|
||||
"🏢 현판": ["헌터", "게이트", "각성", "시스템", "상태창", "던전"],
|
||||
"💕 로맨스": ["황제", "공작", "백작", "영애", "황태자", "정략결혼"],
|
||||
"🚀 SF": ["우주선", "안드로이드", "인공지능", "사이보그", "은하제국"]
|
||||
" 현판": ["헌터", "게이트", "각성", "시스템", "상태창", "던전"],
|
||||
" 로맨스": ["황제", "공작", "백작", "영애", "황태자", "정략결혼"],
|
||||
" SF": ["우주선", "안드로이드", "인공지능", "사이보그", "은하제국"]
|
||||
};
|
||||
|
||||
function getKeywordRules() {
|
||||
@@ -1466,7 +1466,7 @@
|
||||
const btnSaveKeywordRules = document.getElementById('btn-save-keyword-rules');
|
||||
const btnReapplyTags = document.getElementById('btn-reapply-tags');
|
||||
|
||||
// 💡 태그 룰 전용 백업 및 복원 로직
|
||||
// 태그 룰 전용 백업 및 복원 로직
|
||||
document.getElementById('btn-backup-tags').addEventListener('click', () => {
|
||||
const currentRules = getKeywordRules();
|
||||
downloadJSON(currentRules, `tag_rules_backup_${Date.now()}.json`);
|
||||
@@ -1520,7 +1520,7 @@
|
||||
row.className = 'keyword-rule-row';
|
||||
row.style.cssText = "display: flex; gap: 6px; margin-bottom: 8px; align-items: center;";
|
||||
row.innerHTML = `
|
||||
<input type="text" class="rule-tag-input" placeholder="태그명 (예: 🐉 판타지)" value="${tag}" style="width: 30%; padding: 6px; border: 1px solid var(--border-color); background: var(--modal-content-bg); color: var(--text-color); border-radius: 4px; font-size: 12px;">
|
||||
<input type="text" class="rule-tag-input" placeholder="태그명 (예: 판타지)" value="${tag}" style="width: 30%; padding: 6px; border: 1px solid var(--border-color); background: var(--modal-content-bg); color: var(--text-color); border-radius: 4px; font-size: 12px;">
|
||||
<input type="text" class="rule-keywords-input" placeholder="키워드 (쉼표로 구분)" value="${keywordsStr}" style="flex: 1; padding: 6px; border: 1px solid var(--border-color); background: var(--modal-content-bg); color: var(--text-color); border-radius: 4px; font-size: 12px;">
|
||||
<button class="btn-del-rule" style="padding: 6px 9px; background: #e74c3c; color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 12px;">✕</button>
|
||||
`;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
const CACHE_NAME = 'web-reader-cache-v1';
|
||||
const ASSETS_TO_CACHE = [
|
||||
'./reader.html',
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js'
|
||||
];
|
||||
|
||||
// 1. 설치 시 핵심 파일 및 외부 CDN 라이브러리 캐싱
|
||||
self.addEventListener('install', (event) => {
|
||||
event.waitUntil(
|
||||
caches.open(CACHE_NAME).then((cache) => {
|
||||
return cache.addAll(ASSETS_TO_CACHE);
|
||||
}).then(() => self.skipWaiting())
|
||||
);
|
||||
});
|
||||
|
||||
// 2. 구버전 캐시 정리
|
||||
self.addEventListener('activate', (event) => {
|
||||
event.waitUntil(
|
||||
caches.keys().then((keys) => {
|
||||
return Promise.all(
|
||||
keys.filter((key) => key !== CACHE_NAME).map((key) => caches.delete(key))
|
||||
);
|
||||
}).then(() => self.clients.claim())
|
||||
);
|
||||
});
|
||||
|
||||
// 3. 네트워크 요청 가로채기: 오프라인일 때 캐시된 파일 반환
|
||||
self.addEventListener('fetch', (event) => {
|
||||
const url = new URL(event.request.url);
|
||||
|
||||
// reader.html에 쿼리스트링(?id=book_xxx)이 붙은 경우에도 캐시된 reader.html을 반환하도록 처리
|
||||
if (url.pathname.endsWith('reader.html') || url.pathname.endsWith('/')) {
|
||||
event.respondWith(
|
||||
fetch(event.request).catch(() => {
|
||||
return caches.match('./reader.html');
|
||||
})
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// 그 외 정적 리소스(JSZip 등) 캐시 우선 반환
|
||||
event.respondWith(
|
||||
caches.match(event.request).then((cachedResponse) => {
|
||||
if (cachedResponse) {
|
||||
return cachedResponse;
|
||||
}
|
||||
return fetch(event.request).then((networkResponse) => {
|
||||
// 성공적으로 받아온 CDN 파일 등은 캐시에 복사해둠
|
||||
if (networkResponse && networkResponse.status === 200 && networkResponse.type === 'cors') {
|
||||
const responseToCache = networkResponse.clone();
|
||||
caches.open(CACHE_NAME).then((cache) => {
|
||||
cache.put(event.request, responseToCache);
|
||||
});
|
||||
}
|
||||
return networkResponse;
|
||||
});
|
||||
})
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user