Files
lnreader-plugins/.js/src/plugins/chinese/linovelib.js
T
2026-09-25 13:41:04 -03:00

1 line
4.7 KiB
JavaScript

var e=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))(function(o,a){function i(e){try{s(n.next(e))}catch(e){a(e)}}function l(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r(function(e){e(t)})).then(i,l)}s((n=n.apply(e,t||[])).next())})},t=this&&this.__generator||function(e,t){var r,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=l(0),i.throw=l(1),i.return=l(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(s){return function(l){if(r)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(r=1,n&&(o=2&l[0]?n.return:l[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,l[1])).done)return o;switch(n=0,o&&(l=[2&l[0],o.value]),l[0]){case 0:case 1:o=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,n=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]<o[3])){a.label=l[1];break}if(6===l[0]&&a.label<o[1]){a.label=o[1],o=l;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(l);break}o[2]&&a.ops.pop(),a.trys.pop();continue}l=t.call(e,a)}catch(e){l=[6,e],n=0}finally{r=o=0}if(5&l[0])throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}([l,s])}}};Object.defineProperty(exports,"__esModule",{value:!0});var r=require("cheerio"),n=require("@libs/fetch"),o=require("@libs/filterInputs"),a=require("@libs/storage"),i=function(){function i(){this.id="linovelib",this.name="Linovelib",this.icon="src/cn/linovelib/icon.png",this.site="https://www.bilinovel.com",this.version="1.2.1",this.imageRequestInit={method:"GET",headers:{"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36 Edg/144.0.0.0",Referer:"https://www.linovelib.com",Accept:"image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8"}},this.webStorageUtilized=!0,this.pluginSettings={host:{value:"http://example.com",label:"Custom LDS Host",type:"Text"}},this.serverUrl=a.storage.get("host")||"http://localhost:5301",this.filters={rank:{label:"排行榜",value:"monthvisit",options:[{label:"月点击榜",value:"monthvisit"},{label:"周点击榜",value:"weekvisit"},{label:"月推荐榜",value:"monthvote"},{label:"周推荐榜",value:"weekvote"},{label:"月鲜花榜",value:"monthflower"},{label:"周鲜花榜",value:"weekflower"},{label:"月鸡蛋榜",value:"monthegg"},{label:"周鸡蛋榜",value:"weekegg"},{label:"最近更新",value:"lastupdate"},{label:"最新入库",value:"postdate"},{label:"收藏榜",value:"goodnum"},{label:"新书榜",value:"newhot"}],type:o.FilterTypes.Picker}}}return i.prototype.popularNovels=function(o,a){return e(this,arguments,void 0,function(e,o){var a,i,l,s,c,u=o.showLatestNovels,h=o.filters;return t(this,function(t){switch(t.label){case 0:return a=u?"lastupdate":h.rank.value,i="".concat(this.site,"/top/").concat(a,"/").concat(e,".html"),[4,(0,n.fetchText)(i)];case 1:if(""===(l=t.sent()))throw Error("无法获取小说列表,请检查网络");return s=(0,r.load)(l),c=[],s(".module-rank-booklist .book-layout").each(function(e,t){var r,n=s(t).attr("href"),o=s(t).find(".book-title").text(),a=null===(r=s(t).find("div.book-cover > img").attr("data-src"))||void 0===r?void 0:r.replace("/https","https");if(n){var i={name:o,cover:a,path:n};c.push(i)}}),[2,c]}})})},i.prototype.parseNovel=function(r){return e(this,void 0,void 0,function(){var e;return t(this,function(t){switch(t.label){case 0:return[4,(0,n.fetchText)("".concat(this.serverUrl,"/api/novel?path=").concat(r))];case 1:return e=t.sent(),[2,JSON.parse(e)]}})})},i.prototype.parseChapter=function(r){return e(this,void 0,void 0,function(){var e,o,i;return t(this,function(t){switch(t.label){case 0:return e=Number(a.storage.get("lastFetchChapterTime_"+r))||0,Date.now()-e<1e4?[2,a.storage.get("chapterContent_"+r)||""]:[4,(0,n.fetchText)("".concat(this.serverUrl,"/api/chapter?path=").concat(r))];case 1:return o=t.sent(),i=JSON.parse(o),a.storage.set("lastFetchChapterTime_"+r,Date.now()),a.storage.set("chapterContent_"+r,i.content),[2,i.content]}})})},i.prototype.searchNovels=function(r){return e(this,void 0,void 0,function(){var e,o,i;return t(this,function(t){switch(t.label){case 0:return e=Number(a.storage.get("lastSearchTime_"+this.id))||0,Date.now()-e<5e3?[2,[]]:[4,(0,n.fetchText)("".concat(this.serverUrl,"/api/search?keyword=").concat(encodeURIComponent(r)))];case 1:return o=t.sent(),i=JSON.parse(o).results,a.storage.set("lastSearchTime_"+this.id,Date.now()),[2,i]}})})},i}();exports.default=new i;