Skip to content

Commit

Permalink
10.6.1
Browse files Browse the repository at this point in the history
  • Loading branch information
green1052 committed Feb 16, 2023
1 parent cbe4a73 commit c8bc616
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 14 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "betternovelpia",
"version": "10.6.0",
"version": "10.6.1",
"license": "UNLICENSED",
"scripts": {
"build": "webpack --config webpack.prod.js",
Expand Down
17 changes: 12 additions & 5 deletions src/module/ViewNovelToCookie.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import $ from "jquery";
import {fakeViewer} from "../util/FakeViewer";
import {viewerData} from "../util/ViewerData";
import Cookies from "js-cookie";
Expand Down Expand Up @@ -33,9 +32,9 @@ export default {
}
},
async start() {
const blocked = $(`p:contains("플러스 멤버십이"), p:contains("열람에 회원가입/로그인이")`);
const blocked = document.querySelector<HTMLElement>(".one-event-viewer-plus");

if (!blocked.length)
if (!blocked)
return;

const loginKey = GM_getValue("ViewNovelToCookie_LOGINKEY", "") as string;
Expand All @@ -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;
19 changes: 14 additions & 5 deletions src/util/CommentLoaded.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
const functionList: Array<() => void | Promise<void>> = [];

export function commentLoaded(func: () => void | Promise<void>) {
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);
}
});
}
8 changes: 5 additions & 3 deletions src/util/FakeViewer.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import $ from "jquery";
import {NOVEL_DRAWING} from "./Selectors";

export function fakeViewer(blocked: JQuery<HTMLElement>, 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(`<ol class="no-drag np"id=novel_drawing onclick=navi_view() style=padding:0;margin:0>`);

blocked.remove();
$blocked.remove();

unsafeWindow.novel_data = novelData;

Expand Down

0 comments on commit c8bc616

Please sign in to comment.