diff --git a/package.json b/package.json index eb4894b..4cf9c67 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "betternovelpia", - "version": "10.6.0", + "version": "10.6.1", "license": "UNLICENSED", "scripts": { "build": "webpack --config webpack.prod.js", diff --git a/src/module/ViewNovelToCookie.ts b/src/module/ViewNovelToCookie.ts index 99a2d82..2bfaf9b 100644 --- a/src/module/ViewNovelToCookie.ts +++ b/src/module/ViewNovelToCookie.ts @@ -1,4 +1,3 @@ -import $ from "jquery"; import {fakeViewer} from "../util/FakeViewer"; import {viewerData} from "../util/ViewerData"; import Cookies from "js-cookie"; @@ -33,9 +32,9 @@ export default { } }, async start() { - const blocked = $(`p:contains("플러스 멤버십이"), p:contains("열람에 회원가입/로그인이")`); + const blocked = document.querySelector(".one-event-viewer-plus"); - if (!blocked.length) + if (!blocked) return; const loginKey = GM_getValue("ViewNovelToCookie_LOGINKEY", "") as string; @@ -55,7 +54,15 @@ export default { resetCookie("USERKEY", oldUserKey); }); - if (data.length > 0) - fakeViewer(blocked, data); + if (data.length <= 0) + return; + + fakeViewer(blocked, data); + + const oldGetCommentBox = unsafeWindow.get_comment_box + .toString() + .replace("response.status == '200'", `response.status == '200' || response.errmsg.startsWith("PLUS")`); + + unsafeWindow.get_comment_box = () => eval(`${oldGetCommentBox}get_comment_box()`); } } as Module; \ No newline at end of file diff --git a/src/util/CommentLoaded.ts b/src/util/CommentLoaded.ts index f9f6c88..c4a8e03 100644 --- a/src/util/CommentLoaded.ts +++ b/src/util/CommentLoaded.ts @@ -1,10 +1,19 @@ +const functionList: Array<() => void | Promise> = []; + export function commentLoaded(func: () => void | Promise) { if (!location.pathname.startsWith("/viewer/")) throw "is not viewer"; - const oldCommentLoad = unsafeWindow.get_comment_load; + functionList.push(func); + + unsafeWindow.get_comment_load = new Proxy(unsafeWindow.get_comment_load, { + apply(target, thisArg, argArray) { + Reflect.apply(target, thisArg, argArray); - unsafeWindow.get_comment_load = (comment_re_no = 0, comment_ori_no = 0) => { - oldCommentLoad(comment_re_no, comment_ori_no); - setTimeout(func, 500); - }; + setTimeout(() => { + for (const func of functionList) { + func(); + } + }, 500); + } + }); } \ No newline at end of file diff --git a/src/util/FakeViewer.ts b/src/util/FakeViewer.ts index e10c069..a3cf88f 100644 --- a/src/util/FakeViewer.ts +++ b/src/util/FakeViewer.ts @@ -1,12 +1,14 @@ import $ from "jquery"; import {NOVEL_DRAWING} from "./Selectors"; -export function fakeViewer(blocked: JQuery, novelData: { text: string, size: number, align: string }[]) { - blocked +export function fakeViewer(blocked: HTMLElement, novelData: { text: string, size: number, align: string }[]) { + const $blocked = $(blocked); + + $blocked .closest("#novel_text") .append(`
    `); - blocked.remove(); + $blocked.remove(); unsafeWindow.novel_data = novelData;