...
This commit is contained in:
@@ -469,8 +469,13 @@ if(document.querySelector(".list-body") !== null) {
|
||||
var listBody = null
|
||||
try {listBody = document.querySelector(".list-body");}catch (e) {}
|
||||
getList(listBody.children)
|
||||
}
|
||||
if(document.querySelector("#novel_content") !== null){
|
||||
} else if(document.querySelector(".novel-eps") !== null) {
|
||||
//document.querySelector(".novel-eps").children
|
||||
removeSpecificGifs()
|
||||
var listBody = null
|
||||
try {listBody = document.querySelector(".novel-eps");}catch (e) {}
|
||||
getList2(listBody.children)
|
||||
} else if(document.querySelector("#novel_content") !== null){
|
||||
removeSpecificGifs()
|
||||
var title = null
|
||||
var contents = null
|
||||
@@ -487,6 +492,23 @@ if(document.querySelector("#novel_content") !== null){
|
||||
}
|
||||
);
|
||||
}
|
||||
} else if(document.querySelector('[style^="--novel"]') !== null){
|
||||
removeSpecificGifs()
|
||||
var title = null
|
||||
var contents = null
|
||||
try {title = toonTitle(document.querySelector(".page-desc")); }catch (e) {}
|
||||
try {contents = toonContents(document.querySelector('[style^="--novel"]'))}catch (e) {}
|
||||
if (toonTitle !== undefined && toonContents !== undefined && toonTitle !== "" && toonContents !=="") {
|
||||
sendMessage(
|
||||
{
|
||||
type: "BookContents",
|
||||
book : {
|
||||
chapterTitle : title,
|
||||
bookContents : contents
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
if(document.querySelector("#html_encoder_div")) {
|
||||
sendMessage(
|
||||
@@ -572,6 +594,83 @@ function getList(children) {
|
||||
}
|
||||
}
|
||||
|
||||
function getList2(children) {
|
||||
const contentsArray = [];
|
||||
const maxCount = children.length;
|
||||
|
||||
// 반복문 내부에서 공통으로 사용될 변수 미리 선언
|
||||
let bookTitle = "";
|
||||
const viewTitleEl = document.getElementsByClassName('view-title')[0];
|
||||
if (viewTitleEl) {
|
||||
bookTitle = viewTitleEl.getElementsByTagName('span')[0].innerText;
|
||||
}
|
||||
|
||||
for (let i = 0; i < maxCount; i++) {
|
||||
const item = children[i];
|
||||
|
||||
// 1. 에피소드 번호 추출 (data-ep 속성 활용)
|
||||
const chapterNum = item.getAttribute('data-ep');
|
||||
|
||||
// 2. URL 및 제목 요소 찾기
|
||||
const linkAnchor = item.getElementsByTagName('a')[0];
|
||||
if (!linkAnchor) continue;
|
||||
|
||||
let pageUrl = linkAnchor.href;
|
||||
const chapterTitle = item.getElementsByClassName('ne-title')[0]?.innerText || "";
|
||||
|
||||
// 3 콘텐츠 타입 판별
|
||||
const contentsType = location.hostname.includes("book") ? "book" :
|
||||
location.hostname.includes("mana") ? "comics" :
|
||||
location.hostname.includes("new") ? "webtoon" : "web";
|
||||
|
||||
// 4. URL 정제 (기존 로직 유지)
|
||||
if (pageUrl && pageUrl.startsWith("http")) {
|
||||
try {
|
||||
const urlObj = new URL(pageUrl);
|
||||
let paths = urlObj.pathname.split('/').filter(p => p !== "");
|
||||
|
||||
if (paths.length > 0) {
|
||||
const last = paths[paths.length - 1];
|
||||
// 마지막 요소가 숫자가 아니면 제거 (예: 파라미터나 기타 경로)
|
||||
if (!/^\d+$/.test(last)) {
|
||||
paths.pop();
|
||||
}
|
||||
}
|
||||
pageUrl = "/" + paths.join('/');
|
||||
} catch (e) {
|
||||
console.error("URL parsing error:", e);
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 데이터 객체 생성
|
||||
const data = {
|
||||
'chapterID': Number(chapterNum),
|
||||
'chapterNum': Number(chapterNum),
|
||||
'pathUrl': pageUrl,
|
||||
'contentsType': contentsType,
|
||||
'bookPageUrl': location.pathname,
|
||||
'chapterTitle': chapterTitle.trim(),
|
||||
'bookTitle': bookTitle,
|
||||
};
|
||||
|
||||
contentsArray.push(data);
|
||||
}
|
||||
|
||||
// 6. 결과 전송
|
||||
if (contentsArray.length > 0) {
|
||||
sendMessage({
|
||||
type: "getListResult",
|
||||
bookInfos: {
|
||||
'contentsType': contentsArray[0].contentsType,
|
||||
'bookTitle': bookTitle,
|
||||
'bookPageUrl': location.pathname,
|
||||
'pages': contentsArray,
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function toonTitle(toon_title) {
|
||||
return toon_title != null ? toon_title.innerText : null
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user