Files
2025-04-29 00:37:24 +08:00

560 lines
17 KiB
JavaScript

function cleanMaliciousCode(decodedStr) {
// 定义一系列的恶意代码和关键字
const maliciousPatterns = [
/eval\s*\(/gi, // 检测 eval
/document\.location/gi, // 页面跳转
/window\.location/gi, // 页面跳转
/window\.location\.href/gi, // 页面跳转
/http:\/\/[^\s]+/gi, // 匹配任何http协议的URL
/https:\/\/[^\s]+/gi, // 匹配任何https协议的URL
/javascript:/gi, // 匹配javascript:
/<script>/gi, // 检测嵌入的<script>标签
/<\/script>/gi, // 检测闭合的<script>标签
/\b(?:[a-zA-Z0-9-]+\.){1,}[a-zA-Z]{2,}\b/gi ,// 匹配任何域名,如 example.com
/m.23wx.com/gi, // 检测闭合的<script>标签
/23wx.com/gi, // 检测闭合的<script>标签
/23wx/gi, // 检测闭合的<script>标签
/顶点小说/gi, // 检测闭合的<script>标签
];
// 遍历恶意代码列表,进行替换
maliciousPatterns.forEach(pattern => {
decodedStr = decodedStr.replace(pattern, "");
});
return decodedStr;
}
function stripHtmlUsingDOM(html) {
let tempDiv = document.createElement("div");
tempDiv.innerHTML = html;
return tempDiv.innerText || tempDiv.textContent;
}
var qsbs = {
_keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
aa: function (input) {
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
input = qsbs._utf8_encode(input);
while (i < input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output + this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
}
return output;
},
bb: function (input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
output = qsbs._utf8_decode(output);
return output;
},
bbb: function (input) {
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
output = qsbs._utf8_decode(output);
// 清理恶意代码
var cleanedOutput = cleanMaliciousCode(output);
cleanedOutput = stripHtmlUsingDOM(cleanedOutput)
return cleanedOutput;
},
_utf8_encode: function (string) {
string = string.replace(/\r\n/g, "\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
} else if ((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
} else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
_utf8_decode: function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while (i < utftext.length) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
} else if ((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i + 1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
} else {
c2 = utftext.charCodeAt(i + 1);
c3 = utftext.charCodeAt(i + 2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
};
var _num = 100;
function LastRead() {
this.bookList = "bookList"
}
LastRead.prototype = {
set: function (bid, tid, title, texttitle, read_page, author, tmpbook) {
if (!(bid && tid && title && texttitle, read_page)) return;
var v = bid + '#' + tid + '#' + title + '#' + texttitle + '#' + read_page + '#' + author + '#' + tmpbook;
this.setItem(bid, v);
this.setBook(bid)
},
get: function (k) {
return this.getItem(k) ? this.getItem(k).split("#") : "";
},
remove: function (k) {
this.removeItem(k);
this.removeBook(k)
},
setBook: function (v) {
var reg = new RegExp("(^|#)" + v);
var books = this.getItem(this.bookList);
if (books == "") {
books = v
}
else {
if (books.search(reg) == -1) {
books += "#" + v
}
else {
books.replace(reg, "#" + v)
}
}
this.setItem(this.bookList, books)
},
getBook: function () {
var v = this.getItem(this.bookList) ? this.getItem(this.bookList).split("#") : Array();
var books = Array();
if (v.length) {
for (var i = 0; i < v.length; i++) {
var tem = this.getItem(v[i]).split('#');
if (i > v.length - (_num + 1)) {
if (tem.length > 3) books.push(tem);
}
else {
lastread.remove(tem[0]);
}
}
}
return books
},
removeBook: function (v) {
var reg = new RegExp("(^|#)" + v);
var books = this.getItem(this.bookList);
if (!books) {
books = ""
}
else {
if (books.search(reg) != -1) {
books = books.replace(reg, "")
}
}
this.setItem(this.bookList, books)
},
setItem: function (k, v) {
if (!!window.localStorage) {
localStorage.setItem(k, v);
}
else {
var expireDate = new Date();
var EXPIR_MONTH = 30 * 24 * 3600 * 1000;
expireDate.setTime(expireDate.getTime() + 12 * EXPIR_MONTH)
document.cookie = k + "=" + encodeURIComponent(v) + ";expires=" + expireDate.toGMTString() + "; path=/";
}
},
getItem: function (k) {
var value = ""
var result = ""
if (!!window.localStorage) {
result = window.localStorage.getItem(k);
value = result || "";
}
else {
var reg = new RegExp("(^| )" + k + "=([^;]*)(;|\x24)");
var result = reg.exec(document.cookie);
if (result) {
value = decodeURIComponent(result[2]) || ""
}
}
return value
},
removeItem: function (k) {
if (!!window.localStorage) {
window.localStorage.removeItem(k);
}
else {
var expireDate = new Date();
expireDate.setTime(expireDate.getTime() - 1000)
document.cookie = k + "= " + ";expires=" + expireDate.toGMTString()
}
},
removeAll: function () {
if (!!window.localStorage) {
window.localStorage.clear();
}
else {
var v = this.getItem(this.bookList) ? this.getItem(this.bookList).split("#") : Array();
var books = Array();
if (v.length) {
for (i in v) {
var tem = this.removeItem(v[k])
}
}
this.removeItem(this.bookList)
}
}
}
function showbook() {
var showbook = document.getElementById('newcase');
var books = lastread.getBook();
var bookhtml = '';
if (books.length) {
var k = 1;
for (var i = books.length - 1; i > -1; i--) {
var articlename = books[i][2];
var lastchapter = books[i][3];
var lastchapterid = books[i][1];
var read_page = parseInt(books[i][4]);
var tmpbook_del = books[i][0];
var author = books[i][5];
var read_ym = parseInt(read_page + 1);
if (books[i][6] > 0) {
var articleid = parseInt(books[i][0].replace('t', ''));
var shortid = parseInt(articleid / 1000);
var mybook_aid = parseInt(books[i][6]);
var mybook_cid = parseInt(books[i][1] - articleid);
info_url = tag_info_rewrite.replace(/{aid}/, articleid);
info_url = info_url.replace(/{bid}/, shortid);
read_url = tag_read_rewrite.replace(/{aid}/, articleid);
read_url = read_url.replace(/{bid}/, shortid);
read_url = read_url.replace(/{cid}/, lastchapterid);
read_page_url = tag_read_page_rewrite.replace(/{aid}/, articleid);
read_page_url = read_page_url.replace(/{bid}/, shortid);
read_page_url = read_page_url.replace(/{cid}/, lastchapterid);
read_page_url = read_page_url.replace(/{pid}/, read_page);
} else {
var articleid = parseInt(books[i][0]);
var shortid = parseInt(articleid / 1000);
var mybook_aid = articleid;
var mybook_cid = books[i][1];
info_url = info_rewrite.replace(/{aid}/, articleid);
info_url = info_url.replace(/{bid}/, shortid);
read_url = read_rewrite.replace(/{aid}/, articleid);
read_url = read_url.replace(/{bid}/, shortid);
read_url = read_url.replace(/{cid}/, lastchapterid);
read_page_url = read_page_rewrite.replace(/{aid}/, articleid);
read_page_url = read_page_url.replace(/{bid}/, shortid);
read_page_url = read_page_url.replace(/{cid}/, lastchapterid);
read_page_url = read_page_url.replace(/{pid}/, read_page);
}
var info_url, read_url;
var c = '';
if ((k % 2) == 0) {
c = 'hot_saleEm';
}
if (read_page == 0) {
page_word = '';
} else {
page_word = '第' + read_ym + '页';
}
if (read_page == 0) {
jxyd = '<a href="' + read_url + '" class="a3"><span class="iconfont icon-yuedu1"></span>继续阅读</a></div></div>';
} else {
jxyd = '<a href="' + read_page_url + '" class="a3"><span class="iconfont icon-yuedu1"></span>继续阅读</a></div></div>';
}
var jxyd;
bookhtml += '<div class="hot_sale' + ' ' + c + '"><div class="tl"><a href="' + info_url + '" class="title">' + articlename + '</a></div><p>小说作者:<span>' + author + '</span></p><p class="p2">上次阅读:' + lastchapter + page_word + '</p><div class="anbtn"><a href="javascript:removebook(' + tmpbook_del + ')" class="xsdel"><span class="iconfont icon-105"></span></a><a href="' + info_url + '" class="a4"><span class="iconfont icon-shujia1"></span>目录</a><a onclick=\'shuqian(' + mybook_aid + ',' + mybook_cid + ',"' + tmpbook_rewrite + '")\' class="a2"><span class="iconfont icon-gengxin"></span>云书签</a>' + jxyd;
// '<li id="'+tmpbook_del+'"><span class="s1"><a href="'+info_url+'">《'+articlename+'》</a></span><span class="s2">作 者:'+author+'</span><span class="s3">阅读至:'+lastchapter+page_word+'</span><span class="s5"><a href="javascript:removebook('+tmpbook_del+')" class="xsdel">删除</a><a onclick=\'shuqian('+mybook_aid+','+mybook_cid+',"'+tmpbook_rewrite+'")\' class="a2"><span class="iconfont icon-gengxin"></span>保存至书架</a>'+jxyd+'</span></li>';
k++;
}
showbook.innerHTML = '<div class="xs_phb"><span class="iconfont icon-liulanliang fs22 btn_cl_1"></span><h2 class="btn_cl_1">阅读历史(浏览器储存记录)</h2>' + bookhtml;
}
else {
showbook.innerHTML = '<li>您还木有阅读本站小说,未产生阅读记录。</li>';
}
}
function removebook(k) {
lastread.remove(k);
showbook()
}
function yuedu() {
//document.write("<a href='javascript:showbook();' target='_self'>点击查看阅读记录</a>");
showbook();
}
window.lastread = new LastRead();
function removebook(k) {
lastread.remove(k);
showbook()
}
var checkbg = "#f7ecef";
//内容页用户设置
function nr_setbg(intype) {
var huyandiv = document.getElementById("huyandiv");
var light = document.getElementById("lightdiv");
if (intype == "huyan") {
if (huyandiv.style.backgroundColor == "") {
set("light", "huyan");
document.cookie = "light=huyan;path=/";
}
else {
set("light", "no");
document.cookie = "light=no;path=/";
}
}
if (intype == "light") {
if (light.innerHTML == "关灯") {
set("light", "yes");
document.cookie = "light=yes;path=/";
}
else {
set("light", "no");
document.cookie = "light=no;path=/";
}
}
if (intype == "big") {
set("font", "big");
document.cookie = "font=big;path=/";
}
if (intype == "middle") {
set("font", "middle");
document.cookie = "font=middle;path=/";
}
if (intype == "small") {
set("font", "small");
document.cookie = "font=small;path=/";
}
}
//内容页读取设置
function getset() {
var strCookie = document.cookie;
var arrCookie = strCookie.split("; ");
var light;
var font;
for (var i = 0; i < arrCookie.length; i++) {
var arr = arrCookie[i].split("=");
if ("light" == arr[0]) {
light = arr[1];
break;
}
}
for (var i = 0; i < arrCookie.length; i++) {
var arr = arrCookie[i].split("=");
if ("font" == arr[0]) {
font = arr[1];
break;
}
}
//light
if (light == "yes") {
set("light", "yes");
}
else if (light == "no") {
set("light", "no");
}
else if (light == "huyan") {
set("light", "huyan");
}
//font
if (font == "big") {
set("font", "big");
}
else if (font == "middle") {
set("font", "middle");
}
else if (font == "small") {
set("font", "small");
}
else {
set("", "");
}
}
//内容页应用设置
function set(intype, p) {
var nr_body = document.getElementById("chapterbody");//页面body
var huyandiv = document.getElementById("huyandiv");//护眼div
var lightdiv = document.getElementById("lightdiv");//灯光div
var fontfont = document.getElementById("fontfont");//字体div
var fontbig = document.getElementById("fontbig");//大字体div
var fontmiddle = document.getElementById("fontmiddle");//中字体div
var fontsmall = document.getElementById("fontsmall");//小字体div
var txt = document.getElementById("txt");//内容div
var nr_title = document.getElementById("chaptername");//文章标题
//var shuqian_2 = document.getElementById("shuqian_2");//书签链接
var pt_mulu = document.getElementById("pt_mulu");
var pt_next = document.getElementById("pt_next");
var pb_prev = document.getElementById("pb_prev");
var pb_mulu = document.getElementById("pb_mulu");
var pb_next = document.getElementById("pb_next");
//初始化
//document.getElementsByName("page_nr")[1].style.color = "#000";
//灯光
if (intype == "light") {
if (p == "yes") {
//关灯
lightdiv.innerHTML = "开灯";
lightdiv.style.backgroundColor = "#ccc9c0";
nr_body.style.backgroundColor = "#32373B";
huyandiv.style.backgroundColor = "";
nr_title.style.color = "#ccc";
txt.style.color = "#999";
//shuqian_2.style.color = "#999";
}
else if (p == "no") {
//开灯
lightdiv.innerHTML = "关灯";
lightdiv.style.backgroundColor = checkbg;
nr_body.style.backgroundColor = "#f7ecef";
txt.style.color = "#423838";
nr_title.style.color = "#333";
huyandiv.style.backgroundColor = "";
//shuqian_2.style.color = "#000";
}
else if (p == "huyan") {
//护眼
lightdiv.innerHTML = "关灯";
huyandiv.style.backgroundColor = "#ded4b2";
nr_body.style.backgroundColor = "#dfdbcd";
txt.style.color = "#333";
//shuqian_2.style.color = "#000";
}
}
//字体
if (intype == "font") {
//alert(p);
fontbig.style.backgroundColor = "";
fontmiddle.style.backgroundColor = "";
fontsmall.style.backgroundColor = "";
if (p == "big") {
fontbig.style.backgroundColor = "#ded4b2";
txt.style.fontSize = "30px";
txt.style.lineHeight = "45px"
}
if (p == "middle") {
fontmiddle.style.backgroundColor = "#ded4b2";
txt.style.fontSize = "24px";
txt.style.lineHeight = "36px"
}
if (p == "small") {
fontsmall.style.backgroundColor = "#ded4b2";
txt.style.fontSize = "18px";
txt.style.lineHeight = "30px"
}
}
}