...
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -45,20 +45,62 @@ port.onMessage.addListener(response => {
|
||||
else scrollByPercentUpDown(Number(isUpDown),100);
|
||||
}
|
||||
break;
|
||||
case "ViewerTouch": {
|
||||
if (document.querySelector(".show_viewer")) {
|
||||
var area = response["area"]
|
||||
var current = Number(document.querySelector("#mcv_currentPageNum").innerHTML)
|
||||
var total = Number(document.querySelector("#mcv_totalPagesNum").innerHTML)
|
||||
|
||||
if ("left" === area) {
|
||||
if (current > 0) {
|
||||
document.querySelector("#mcv_clickAreaRight").click()
|
||||
} else {
|
||||
document.querySelector("#goPrevBtn").click()
|
||||
}
|
||||
} else if ("right" === area) {
|
||||
if (current < total) {
|
||||
document.querySelector("#mcv_clickAreaLeft").click()
|
||||
}else {
|
||||
document.querySelector("#goNextBtn").click()
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "onLoaded":{
|
||||
|
||||
}
|
||||
break;
|
||||
case "saveContent":{
|
||||
sendMessage(
|
||||
{
|
||||
type: "SHOWVIEWER",
|
||||
contents : document.documentElement.outerHTML
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
default:
|
||||
port.postMessage(`Received: ${JSON.stringify(response)}`);
|
||||
break
|
||||
}
|
||||
});
|
||||
if(document.querySelector(".list-body")) {
|
||||
if (document.location.href.search("reddit") > -1) {
|
||||
if (document.querySelector('#xpromo-bottom-sheet')) {
|
||||
document.querySelector('#xpromo-bottom-sheet').remove()
|
||||
}
|
||||
}
|
||||
if (document.querySelector(".show_viewer") !== null) {
|
||||
document.querySelector(".show_viewer").click();
|
||||
sendMessage({type: "SHOWVIEWER"});
|
||||
}
|
||||
if(document.querySelector(".list-body") !== null) {
|
||||
var listBody = null
|
||||
try {listBody = document.querySelector(".list-body");}catch (e) {}
|
||||
getList(listBody.children)
|
||||
} else if(document.querySelector("#novel_content")){
|
||||
}
|
||||
if(document.querySelector("#novel_content") !== null){
|
||||
var title = null
|
||||
var contents = null
|
||||
try {title = toonTitle(document.querySelector(".page-desc")); }catch (e) {}
|
||||
@@ -74,16 +116,18 @@ if(document.querySelector(".list-body")) {
|
||||
}
|
||||
);
|
||||
}
|
||||
} else if(document.querySelector("#html_encoder_div")) {
|
||||
}
|
||||
if(document.querySelector("#html_encoder_div")) {
|
||||
sendMessage(
|
||||
{
|
||||
type: "WebtoonContents",
|
||||
}
|
||||
);
|
||||
} else {
|
||||
sendMessage({type:"MSG",msg:"connected has Nothings"});
|
||||
loadComplete()
|
||||
}
|
||||
// else {
|
||||
// sendMessage({type:"MSG",msg:"connected has Nothings"});
|
||||
// loadComplete()
|
||||
// }
|
||||
|
||||
|
||||
function getList(children) {
|
||||
@@ -93,9 +137,29 @@ function getList(children) {
|
||||
for (i= 0; i < maxCount; i++) {
|
||||
var chapterNum = children[i].getElementsByClassName('wr-num')[0].textContent;
|
||||
var pageUrl = children[i].getElementsByClassName('wr-subject')[0].getElementsByTagName('a')[0].href;
|
||||
var contentsType = location.hostname.search("book") > -1 ? "book" : location.hostname.search("mana") > -1 ? "comics" : location.hostname.search("new") > -1 ? "webtoon" : "web";
|
||||
if (pageUrl != null && pageUrl.length > 0 && pageUrl.startsWith("http")) {
|
||||
pageUrl = new URL(pageUrl).pathname;
|
||||
var urlObj =URL.parse(pageUrl);
|
||||
pageUrl = urlObj.protocol + '//' + urlObj.host + urlObj.pathname;
|
||||
if (pageUrl) {
|
||||
var paths = pageUrl.split('/')
|
||||
if (paths.length > 0) {
|
||||
var last = paths[paths.length - 1];
|
||||
if (last && Array.from(last).every(ch => ch >= '0' && ch <= '9')) {
|
||||
|
||||
} else {
|
||||
paths.pop();
|
||||
}
|
||||
}
|
||||
|
||||
var newP = paths.join('/');
|
||||
|
||||
pageUrl = URL.parse(newP).pathname
|
||||
}
|
||||
} else {
|
||||
console.log("pageUrl.startsWith('http') == false" + pageUrl);
|
||||
}
|
||||
|
||||
var chapterTitle = children[i].getElementsByClassName('wr-subject')[0].getElementsByTagName('a')[0].innerText;
|
||||
if(chapterTitle.split('\n').length > 1) {
|
||||
chapterTitle = chapterTitle.split('\n')[1];
|
||||
@@ -107,6 +171,7 @@ function getList(children) {
|
||||
'chapterID': Number(chapterNum),
|
||||
'chapterNum': Number(chapterNum),
|
||||
'pathUrl': pageUrl,
|
||||
'contentsType': contentsType,
|
||||
'bookPageUrl': bookPageUrl,
|
||||
'chapterTitle': chapterTitle,
|
||||
'bookTitle': bookTitle,
|
||||
@@ -121,6 +186,7 @@ function getList(children) {
|
||||
{
|
||||
type: "getListResult",
|
||||
bookInfos: {
|
||||
'contentsType': contentsType,
|
||||
bookTitle: bookTitle,
|
||||
bookPageUrl: new URL(location.href).pathname,
|
||||
pages: contentsArray ,
|
||||
@@ -150,7 +216,7 @@ function scrollByPercent(current , max) {
|
||||
const moveAmount = pageHeight / max;
|
||||
window.scrollTo({ top: moveAmount * current, behavior: "smooth" });
|
||||
}
|
||||
|
||||
document.querySelector(".header__inner")
|
||||
function scrollByPercentUpDown(isToDown , max) {
|
||||
const pageHeight = Math.max(
|
||||
document.body.scrollHeight,
|
||||
@@ -161,7 +227,7 @@ function scrollByPercentUpDown(isToDown , max) {
|
||||
document.documentElement.clientHeight
|
||||
);
|
||||
const currentScroll = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0;
|
||||
const moveAmount = Math.max(pageHeight / max,100);
|
||||
const moveAmount = Math.max(pageHeight / max,150);
|
||||
window.scrollTo({ top: currentScroll + (moveAmount * isToDown) , behavior: "smooth" });
|
||||
}
|
||||
|
||||
@@ -172,6 +238,11 @@ function sendMessage(msg) {
|
||||
port.postMessage(JSON.stringify(msg));
|
||||
}
|
||||
|
||||
function toast(msg) {
|
||||
port.postMessage(JSON.stringify({type:"MSG",msg:msg}));
|
||||
}
|
||||
|
||||
|
||||
function dssd() {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user