搜书大师 v23.2版本的 MD5 值为:5ee433f6456b6278bd6e80a5d44df55e
以下内容为反编译后的 S.java 源代码,内容仅作参考
package com.flyersoft.WB;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.AssetManager;
import android.net.Uri;
import android.os.Build;
import android.os.Handler;
import android.os.SystemClock;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.CookieManager;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
import android.webkit.URLUtil;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import com.caverock.androidsvg.k;
import com.flyersoft.WB.collect.AutoCollect;
import com.flyersoft.baseapplication.z2;
import com.flyersoft.components.m;
import com.flyersoft.components.q;
import com.flyersoft.discuss.AD;
import com.flyersoft.discuss.TS;
import com.flyersoft.discuss.z;
import com.flyersoft.seekbooks.ActivityMain;
import com.flyersoft.seekbooks.HotBookAct;
import com.flyersoft.seekbooks.R;
import com.flyersoft.wwtools.tools.L;
import com.ksdk.ssds.manager.b;
import com.ksdk.ssds.s.ce;
import com.lygame.aaa.e50;
import com.lygame.aaa.h1;
import com.lygame.aaa.jy1;
import com.lygame.aaa.o50;
import com.lygame.aaa.pl2;
import io.reactivex.annotations.SchedulerSupport;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
import java.util.List;
public class S {
public static final String BLANK_PAGE = "about:blank";
public static final String CHAPTER_URL_TAG = "*url*";
public static final String HOT_BOOKS_URL = "http://www.moonreader.cn/downloader/freebooks.zip";
public static final String POST_NOAD_URL = "http://www.moonreader.cn/downloader/post_noad.html";
public static final String SELECTED_URL = "http://www.moonreader.cn/downloader/";
public static final String SITES_URL = "http://www.moonreader.cn/downloader/sites.zip";
public static final String SITES_VER_URL = "http://www.moonreader.cn/downloader/ver.txt";
public static final String SITES_VER_URL2 = "http://soushu.site/ver.txt";
public static final String STORE_URL = "https://mcp.yuewen.com/moon/index.html";
public static final String UNKNOWN_CHAPTER = "()";
public static final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36";
public static final String VIP_CHAPTER = "(VIP)";
public static ArrayList<BookSite> allSites = null;
private static boolean allSitesSorted = false;
static ArrayList<String> blockFullList = null;
static ArrayList<String> blockList = null;
public static WebBook curBook = null;
private static ArrayList<String> deletedSites = null;
public static boolean disableFreeSource = false;
public static boolean disableStatistics = false;
public static ArrayList<FavLink> favLinks = null;
public static boolean forceDeleteFreeSource = false;
public static boolean forceInitedAllSite = false;
public static int forceUpdateApp = 0;
private static ArrayList<String> forceWebSites = null;
public static boolean foreReImportFreeSource = false;
private static ArrayList<String> ignoreAdTipSites = null;
public static long initAllSitesTime = 0;
public static boolean inited = false;
private static boolean linkSiteParamsInited = false;
public static ArrayList<LinkSite> linkSites = null;
private static boolean linkSitesSorted = false;
public static boolean newUserDisableNormalSites = false;
public static boolean pauseImportThirdSources = false;
public static int promoPicRate = 50;
public static ArrayList<BookSite> sites;
public static StoreSite store;
public static ArrayList<BookSite> subSites;
public static List<JsonBook> suggestFreeBooks;
public static ArrayList<BookSite> topSites;
public static long uriApplyTime;
public static m.c uriDlg;
public static ArrayList<BookSite> tempTsSites = new ArrayList<>();
public static String FREEBOOK_URL = "http://soushu.starsjoy.com";
public static class FavLink {
public String name;
public String url;
}
public static class LinkSite extends BookSite {
public String domain;
public String icon;
public int tipShowedTimes;
public LinkSite(String filename, String site_define, boolean initeNow) {
super(filename, site_define, initeNow);
}
public void getDefines2() {
this.domain = S.getDomain(this.url);
String replace = this.site_define.replace(pl2.e, "");
int indexOf = replace.indexOf("icon*");
if (indexOf != -1) {
this.icon = replace.substring(indexOf + 5, replace.indexOf("\n", indexOf)).trim();
}
int indexOf2 = replace.indexOf("bookPageFormat*");
if (indexOf2 != -1) {
this.bookPageFormat = replace.substring(indexOf2 + 15, replace.indexOf("\n", indexOf2)).trim();
}
int indexOf3 = replace.indexOf("chapterPageForamt*");
if (indexOf3 != -1) {
this.chapterPageForamt = replace.substring(indexOf3 + 18, replace.indexOf("\n", indexOf3)).trim();
}
int indexOf4 = replace.indexOf("contentPageFormat*");
if (indexOf4 != -1) {
this.contentPageFormat = replace.substring(indexOf4 + 18, replace.indexOf("\n", indexOf4)).trim();
}
int indexOf5 = replace.indexOf("bookPageUrl*");
if (indexOf5 != -1) {
this.bookPageUrl = replace.substring(indexOf5 + 12, replace.indexOf("\n", indexOf5)).trim();
}
int indexOf6 = replace.indexOf("chapterPageUrl*");
if (indexOf6 != -1) {
this.chapterPageUrl = replace.substring(indexOf6 + 15, replace.indexOf("\n", indexOf6)).trim();
}
int indexOf7 = replace.indexOf("contentPageUrl*");
if (indexOf7 != -1) {
this.contentPageUrl = replace.substring(indexOf7 + 15, replace.indexOf("\n", indexOf7)).trim();
}
int indexOf8 = replace.indexOf("category*");
if (indexOf8 != -1) {
this.categoryUrl = replace.substring(indexOf8 + 9, replace.indexOf("\n", indexOf8)).trim();
}
int indexOf9 = replace.indexOf("rank*");
if (indexOf9 != -1) {
this.rankUrl = replace.substring(indexOf9 + 5, replace.indexOf("\n", indexOf9)).trim();
}
}
}
public static class NoPopupChromeClient extends WebChromeClient {
@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
e50.N5("#onJsAlert : " + url);
result.cancel();
return true;
}
@Override
public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
e50.N5("#onJsConfirm : " + url);
result.cancel();
return true;
}
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
e50.N5("#onJsPrompt : " + url);
result.cancel();
return true;
}
}
public static class NormalChromeClient extends WebChromeClient {
@Override
public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
e50.N5("#onJsAlert : " + url);
return super.onJsAlert(view, url, message, result);
}
@Override
public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
e50.N5("#onJsConfirm : " + url);
return super.onJsConfirm(view, url, message, result);
}
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
e50.N5("#onJsPrompt : " + url);
return super.onJsPrompt(view, url, message, defaultValue, result);
}
}
public static class StoreSite extends LinkSite {
public StoreSite(String filename) {
super(filename, null, false);
String siteDefine = S.getSiteDefine(filename);
this.site_define = siteDefine;
initStore(siteDefine);
getDefines();
S.initLinkSiteParams2(this);
}
public void initStore(String s) {
}
}
public static class WebBook {
public String bookId;
public String charCount;
public String coverUrl;
public BookSite site;
public String tag;
public TS.Book tsBook;
public String updateTime;
public String url;
public ArrayList<WebBook> sources = new ArrayList<>();
public ArrayList<WebChapter> chapters = new ArrayList<>();
public ArrayList<String> loadedUrls = new ArrayList<>();
public String category = "";
public String description = "";
public String author = "";
public String name = "";
}
public static class WebChapter {
public BookSite bookSite;
public String formatUrl;
public String html;
public String name;
public String tag;
public TS.Chapter tsChapter;
public String url;
public boolean vip;
}
public static void addFavLink(String name, String url) {
deleteFavLink(url);
FavLink favLink = new FavLink();
favLink.name = name;
favLink.url = url;
favLinks.add(favLink);
saveFavLinks();
}
public static void addForceWebSite(String siteTag) {
if (getForceWebSites().contains(siteTag)) {
return;
}
getForceWebSites().add(siteTag);
o50.i2(e50.R1 + "/forceWebSites", o50.B2(getForceWebSites()));
}
public static void addToIgnoreAdTipSites(String siteTag) {
if (getIgnoreAdTipSites().contains(siteTag)) {
return;
}
getIgnoreAdTipSites().add(siteTag);
o50.i2(e50.R1 + "/ignoreAdTip", o50.B2(getIgnoreAdTipSites()));
}
public static void addTsChaptersToWebChapters(ArrayList<WebChapter> wcs, ArrayList<TS.Chapter> tcs) {
Iterator<TS.Chapter> it = tcs.iterator();
while (it.hasNext()) {
wcs.add(tsChapter2WebChapter(it.next()));
}
deleteDuplicatedChapters(wcs);
}
private static void appendSitesInSdCard() {
ArrayList<String> w0 = o50.w0(e50.R1, false, true, true, false);
w0.addAll(o50.w0("/sdcard/download", false, true, true, true));
Iterator<String> it = w0.iterator();
while (it.hasNext()) {
String next = it.next();
if (next.endsWith(".wj") || next.endsWith(".wj2") || next.endsWith(".sub") || next.endsWith(".wlink") || next.endsWith(".store")) {
String p0 = o50.p0(next);
BookSite bookSite = new BookSite(next, p0, true);
e50.N5("outer site: " + next + ":" + bookSite.ok() + ", ver: " + bookSite.version());
if (bookSite.ok()) {
if (next.endsWith(".sub")) {
BookSite subSite = getSubSite(bookSite.siteTag);
if (subSite == null || bookSite.version() > subSite.version()) {
e50.N5("*outer sub newer: " + bookSite.name());
subSites.add(0, bookSite);
subSites.remove(subSite);
}
} else if (next.endsWith(".wlink")) {
LinkSite linkSite = getLinkSite(bookSite.siteTag);
if (linkSite == null || bookSite.version() > linkSite.version()) {
e50.N5("*outer wlink newer: " + bookSite.name());
linkSites.add(0, new LinkSite(next, p0, true));
linkSites.remove(linkSite);
}
} else {
BookSite site = getSite(bookSite.siteTag, true);
if (site == null || bookSite.version() > site.version()) {
e50.N5("*outer site newer: " + bookSite.name());
if (!isStoreSite(next)) {
allSites.add(0, bookSite);
allSites.remove(site);
}
}
}
}
}
}
}
public static boolean bookInBlockList(String name) {
return z2.bookInBlockList(name);
}
public static void checkOnlineSitesUpdate() {
int updateTagValue;
boolean z;
WebSitesAct webSitesAct;
z2.SELECTED_URL = SELECTED_URL;
if (!o50.C1(e50.S1())) {
if (e50.w2) {
setDisableNormalSites(true);
}
} else {
try {
String i1 = o50.i1(SITES_VER_URL);
if (i1 == null) {
i1 = o50.i1(SITES_VER_URL2);
}
String clearTxt = clearTxt(i1);
e50.N5("*ver tag: " + clearTxt);
e50.g = updateTagValue(clearTxt, "adLevel*", e50.g);
AD.ShuDanAd = updateTagValue(clearTxt, "ShuDanAd*", AD.ShuDanAd);
AD.ZhongHeAd = updateTagValue(clearTxt, "ZhongHeAd*", AD.ZhongHeAd);
AD.ShuPingAd = updateTagValue(clearTxt, "ShuPingAd*", AD.ShuPingAd);
e50.i = updateTagValue(clearTxt, "disableLevel*", e50.i);
z2.qqNumber = updateTagValue(clearTxt, "#QQ#", (int) z2.qqNumber);
e50.Z1 = updateTagValue(clearTxt, "download*", e50.Z1);
e50.b2 = updateTagValue(clearTxt, "shuPingTip*", e50.b2);
e50.a2 = updateTagValue(clearTxt, "storeUrl*", e50.a2);
e50.m = updateTagValue(clearTxt, "shareToHide2*", e50.m);
e50.p2 = updateTagValue(clearTxt, "monthFee*", e50.p2);
L.minPay = updateTagValue(clearTxt, "minPay*", L.minPay);
L.maxPay = updateTagValue(clearTxt, "maxPay*", L.maxPay);
z2.onlineAppVersion = updateTagValue(clearTxt, "latest*", z2.onlineAppVersion);
e50.Ka = updateTagValue(clearTxt, "storeVer*", e50.Ka);
z2.storeLevel = updateTagValue(clearTxt, "storeLevel*", z2.storeLevel);
promoPicRate = updateTagValue(clearTxt, "promoPicRate*", promoPicRate);
forceUpdateApp = updateTagValue(clearTxt, "forceUpdate*", 0);
e50.o = clearTxt.contains("bothAd2*true");
e50.e = clearTxt.contains("showAds*true");
disableStatistics = clearTxt.contains("disableStatitics*true");
newUserDisableNormalSites = clearTxt.contains("newUserDisableNormalSites*true");
disableFreeSource = clearTxt.contains("disableFreeSource*true");
forceDeleteFreeSource = clearTxt.contains("forceDeleteFreeSource*true");
foreReImportFreeSource = clearTxt.contains("foreReImportFreeSource*true");
pauseImportThirdSources = clearTxt.contains("pauseImportThirdSources*true");
z.showCommSource = clearTxt.contains("showCommSource*true");
z2.useOtherAd = updateTagValue(clearTxt, "otherAd*", z2.useOtherAd);
z2.replaceGdtWithTT = updateTagValue(clearTxt, "replaceGdtWithTT*", z2.replaceGdtWithTT);
z2.enableZk = clearTxt.contains("enableZk*true");
z2.splashDownloadAsk = clearTxt.contains("splashDownloadAsk*true");
z2.splashTapBar = clearTxt.contains("splashTapBar*true");
int updateTagValue2 = updateTagValue(clearTxt, "forceToForum*", e50.n);
if (updateTagValue2 != e50.n) {
e50.n = updateTagValue2;
if (updateTagValue2 > 0 && e50.l2 != 2) {
ActivityMain activityMain = ActivityMain.e;
if (activityMain != null && activityMain.K0 != null) {
activityMain.M0();
} else {
e50.l2 = 2;
}
}
}
if (updateTagValue(clearTxt, "rateDialogReset*", e50.u2) != e50.u2) {
e50.t2 = 0;
}
if (storeToDiscovery() && !linkSites.contains(store)) {
linkSites.add(0, store);
}
if (!e50.j) {
if (clearTxt.contains("disableNormalSites*true")) {
setDisableNormalSites(true);
} else if (!newUserDisableNormalSites) {
setDisableNormalSites(false);
} else if (e50.w2) {
setDisableNormalSites(true);
}
}
int z2 = o50.z2(clearTxt);
if (e50.v2 && z2 > 0 && e50.d >= z2) {
clearOldCachedSiteFiles();
}
if (z2 > e50.d) {
e50.N5("===================sites update, new ver: " + z2 + ", current: " + e50.d);
ArrayList arrayList = new ArrayList();
try {
InputStream d1 = o50.d1(SITES_URL);
String str = e50.R1 + "/.sites.zip";
o50.t1(d1, str);
q b = q.b(str);
Iterator<q.a> it = b.d().iterator();
z = false;
while (it.hasNext()) {
try {
q.a next = it.next();
if (!next.a.endsWith(".wj") && !next.a.endsWith(".wj2") && !next.a.endsWith(".sub") && !next.a.endsWith(".wlink") && !next.a.endsWith(".store")) {
if (next.a.equals("deleted.txt")) {
ArrayList<String> C2 = o50.C2(clearTxt(o50.u1(b.g(next.h))));
o50.C(getDeletedSitesFile());
deletedSites = null;
Iterator<String> it2 = C2.iterator();
while (it2.hasNext()) {
if (deleteSite(it2.next().replace(pl2.e, ""))) {
z = true;
}
}
} else if (next.a.equals("block")) {
o50.t1(b.g(next.h), e50.R1 + "/block");
blockList = null;
} else if (next.a.equals("block_full")) {
o50.t1(b.g(next.h), e50.R1 + "/block_full");
blockFullList = null;
}
}
String u1 = o50.u1(b.g(next.h));
BookSite bookSite = new BookSite(next.a, u1, true);
if (bookSite.ok()) {
boolean z3 = next.a.endsWith(".sub") ? true : true;
if (z3) {
e50.N5("online site update: " + bookSite.name());
o50.i2(e50.R1 + "/." + o50.v0(next.a), u1);
arrayList.add(bookSite.name());
}
}
} catch (Exception e) {
e = e;
e50.S0(e);
if (!z) {
}
e50.N5("update sites count: " + arrayList.size());
initAllSites(true);
initSites(true);
webSitesAct = WebSitesAct.selfPref;
if (webSitesAct != null) {
}
e50.d = z2;
if (!e50.w2) {
}
updateDefaultSelectedSites(false);
e50.q = clearTxt.contains("disableAutoCollect*true");
updateTagValue = updateTagValue(clearTxt, "autoCollectVer*", e50.p);
if (updateTagValue > e50.p) {
}
if (!o50.D1(ActivityMain.e)) {
}
if (forceDeleteFreeSource) {
TS.deleteSource(FREEBOOK_URL);
}
if (foreReImportFreeSource) {
validateFreeBookSource();
}
e50.L();
}
}
} catch (Exception e2) {
e = e2;
z = false;
}
if (!z || arrayList.size() > 0) {
e50.N5("update sites count: " + arrayList.size());
initAllSites(true);
initSites(true);
webSitesAct = WebSitesAct.selfPref;
if (webSitesAct != null) {
Handler handler = webSitesAct.handler;
handler.sendMessage(handler.obtainMessage(0, arrayList));
}
}
e50.d = z2;
}
if (!e50.w2) {
}
updateDefaultSelectedSites(false);
e50.q = clearTxt.contains("disableAutoCollect*true");
updateTagValue = updateTagValue(clearTxt, "autoCollectVer*", e50.p);
if (updateTagValue > e50.p) {
String i12 = o50.i1("http://www.moonreader.cn/downloader/auto_collect.json");
if (!o50.F1(i12)) {
String str2 = e50.R1 + b.b + AutoCollect.AUTO_COLLECT_FILE;
o50.v(str2, str2 + ".backup", true);
o50.i2(str2, i12);
AutoCollect.initCollectEngine();
if (!AutoCollect.initOk.booleanValue()) {
o50.v(str2 + ".backup", str2, true);
AutoCollect.initCollectEngine();
} else {
e50.p = updateTagValue;
}
}
}
if (!o50.D1(ActivityMain.e)) {
ActivityMain.e.i0();
}
} catch (Exception e3) {
e50.T0(e3, false);
}
}
if (forceDeleteFreeSource && TS.getSource(FREEBOOK_URL) != null) {
TS.deleteSource(FREEBOOK_URL);
}
if (foreReImportFreeSource && TS.getSource(FREEBOOK_URL) == null) {
validateFreeBookSource();
}
e50.L();
}
public static void clearOldCachedSiteFiles() {
ArrayList<String> w0 = o50.w0(e50.n4(), false, true, true, false);
w0.addAll(o50.w0(e50.R1, false, true, true, false));
ArrayList arrayList = new ArrayList();
Iterator<String> it = w0.iterator();
while (it.hasNext()) {
String next = it.next();
if (next.endsWith(".wj") || next.endsWith(".wj2") || next.endsWith(".sub") || next.endsWith(".wlink") || next.endsWith(".store")) {
arrayList.add(next);
}
}
Iterator it2 = arrayList.iterator();
while (it2.hasNext()) {
o50.C((String) it2.next());
}
}
public static String clearTxt(String s) {
return s.replace(pl2.e, "").replace("\ufeff", "");
}
public static void clearWebView(WebView web) {
if (web == null) {
return;
}
web.loadUrl(BLANK_PAGE);
web.clearHistory();
}
public static void clearWebViews(ViewGroup webLay) {
if (webLay != null) {
for (int childCount = webLay.getChildCount() - 1; childCount >= 0; childCount--) {
View childAt = webLay.getChildAt(childCount);
if (childAt instanceof WebView) {
e50.N5("remove web: " + childAt);
WebView webView = (WebView) childAt;
clearWebView(webView);
webLay.removeView(webView);
webView.destroy();
}
}
}
}
public static boolean copyDefaultSelectedSites() {
try {
String clearTxt = clearTxt(o50.u1(e50.S1().getAssets().open(getSelectedFile())));
if (z2.storeLevel < 3 && !clearTxt.contains(ce.e)) {
String[] list = e50.S1().getAssets().list("cnweb");
int length = list.length;
int i = 0;
while (true) {
if (i >= length) {
break;
}
if (list[i].equals("main.wj2")) {
clearTxt = "main\n" + clearTxt;
break;
}
i++;
}
}
String str = e50.R1 + "/.selected";
o50.i2(str, randomList(clearTxt));
e50.N5("=========get assets selected sites: \n" + o50.p0(str));
return true;
} catch (Exception e) {
e50.S0(e);
return false;
}
}
public static void deleteDuplicatedChapters(ArrayList<WebChapter> chapters) {
ArrayList arrayList = new ArrayList();
int i = 0;
while (i < chapters.size() - 1) {
int i2 = i + 1;
for (int i3 = i2; i3 < chapters.size(); i3++) {
if (chapters.get(i).url.equals(chapters.get(i3).url)) {
arrayList.add(chapters.get(i));
}
}
i = i2;
}
Iterator it = arrayList.iterator();
while (it.hasNext()) {
chapters.remove((WebChapter) it.next());
}
}
public static boolean deleteFavLink(String url) {
Iterator<FavLink> it = getFavLinks().iterator();
while (it.hasNext()) {
FavLink next = it.next();
if (next.url.equals(url)) {
getFavLinks().remove(next);
saveFavLinks();
return true;
}
}
return false;
}
public static boolean deleteSite(String name) {
if (o50.F1(name) || getDeletedSites().contains(name)) {
return false;
}
e50.N5("*********************delete site:" + name + "*****************");
getDeletedSites().add(name);
o50.i2(getDeletedSitesFile(), o50.B2(getDeletedSites()));
return true;
}
public static void enableWebViewCookie(WebView webView) {
CookieManager.getInstance().setAcceptCookie(true);
if (Build.VERSION.SDK_INT >= 21) {
CookieManager.getInstance().setAcceptThirdPartyCookies(webView, true);
}
}
public static String encode(String key, String encode) {
if (encode == null || encode.length() < 2) {
encode = "gbk";
}
try {
if (encode.equals(SchedulerSupport.NONE)) {
return key;
}
if (encode.equals("unicode2")) {
return getUnicode(key);
}
return URLEncoder.encode(key, encode);
} catch (Exception e) {
e50.S0(e);
if (encode.equals("gbk")) {
return key;
}
try {
return URLEncoder.encode(key, "gbk");
} catch (Exception unused) {
return key;
}
}
}
private static String extractContent(String source, String contentTags) {
Exception e;
int i;
int i2;
try {
String lowerCase = source.toLowerCase();
int i3 = 0;
int i4 = 0;
i = 0;
i2 = 0;
while (true) {
try {
int indexOf = contentTags.indexOf("\n", i3);
if (indexOf == -1 || indexOf - i3 <= 1) {
break;
}
String substring = contentTags.substring(i3, indexOf);
int indexOf2 = substring.indexOf("*");
if (indexOf2 != -1) {
int intValue = Integer.valueOf("" + substring.charAt(indexOf2 + 1)).intValue();
String substring2 = substring.substring(0, indexOf2);
if (intValue == 1) {
int indexOf3 = lowerCase.indexOf(substring2, i4);
if (indexOf3 == -1) {
break;
}
i4 = indexOf3 + substring2.length();
i = i4;
i3 = indexOf + 1;
} else {
if (intValue == 2 && (i2 = lowerCase.indexOf(substring2, i4)) != -1) {
break;
}
i3 = indexOf + 1;
}
} else {
int indexOf4 = lowerCase.indexOf(substring, i4);
if (indexOf4 == -1) {
break;
}
i4 = indexOf4 + substring.length();
i3 = indexOf + 1;
}
} catch (Exception e2) {
e = e2;
e50.S0(e);
if (!o50.F1(contentTags)) {
}
return source.trim();
}
}
} catch (Exception e3) {
e = e3;
i = 0;
i2 = 0;
}
if (!o50.F1(contentTags)) {
source = (i == 0 || i2 <= i) ? "" : source.substring(i, i2);
}
return source.trim();
}
private static WebChapter extractWebChapter(String html2, String lHtml2, BookSite site, String chapterTags, String bookId) {
boolean z;
WebChapter webChapter = new WebChapter();
webChapter.bookSite = site;
String str = site.chapterUrlFormat;
webChapter.formatUrl = str;
if (bookId != null && !o50.F1(str)) {
webChapter.formatUrl = webChapter.formatUrl.replace("%id", bookId);
}
int i = 0;
int i2 = 0;
int i3 = 0;
char c = jy1.a;
boolean z2 = false;
while (true) {
int indexOf = chapterTags.indexOf("\n", i);
int i4 = -1;
if (indexOf != -1 && indexOf - i > 1) {
String substring = chapterTags.substring(i, indexOf);
int indexOf2 = substring.indexOf("*");
if (indexOf2 == -1) {
int indexOf3 = lHtml2.indexOf(substring, i2);
if (indexOf3 != -1) {
i2 = indexOf3;
}
i2 += substring.length();
} else if (i3 == 0) {
i3 = Integer.valueOf("" + substring.charAt(indexOf2 + 1)).intValue();
String substring2 = substring.substring(0, indexOf2);
int indexOf4 = lHtml2.indexOf(substring2, i2);
if (indexOf4 == -1 && i3 == 2) {
StringBuilder sb = new StringBuilder();
sb.append(substring2.substring(0, substring2.length() - 1));
sb.append(substring2.charAt(substring2.length() - 1) == '\"' ? "'" : "\"");
substring2 = sb.toString();
indexOf4 = lHtml2.indexOf(substring2, i2);
if (indexOf4 == -1 && substring2.startsWith(k.h) && (indexOf4 = lHtml2.indexOf(substring2.substring(0, substring2.length() - 1), i2)) != -1) {
z = true;
if (indexOf4 == -1) {
if (i3 == 2) {
c = substring2.charAt(substring2.length() - 1);
}
int length = indexOf4 + substring2.length();
if (z) {
length--;
}
int i5 = length;
z2 = z;
i2 = i5;
}
}
}
z = false;
if (indexOf4 == -1) {
}
} else {
String valueOf = i3 == 2 ? String.valueOf(c) : substring.substring(0, indexOf2);
if (z2) {
int indexOf5 = lHtml2.indexOf(" ", i2);
int indexOf6 = lHtml2.indexOf(">", i2);
if (indexOf5 != -1 || indexOf6 != -1) {
i4 = (indexOf5 == -1 || (indexOf6 != -1 && indexOf5 >= indexOf6)) ? indexOf6 : indexOf5;
}
} else {
i4 = lHtml2.indexOf(valueOf, i2);
}
if (i4 > i2) {
String substring3 = html2.substring(i2, i4);
if (i3 < 3 || !substring3.equals("-1")) {
switch (i3) {
case 1:
webChapter.name = trim(Html.fromHtml(substring3).toString());
break;
case 2:
if (!substring3.startsWith("#")) {
webChapter.url = o50.M1(site.last_url, substring3);
break;
}
break;
case 3:
String str2 = webChapter.formatUrl;
if (str2 != null) {
webChapter.formatUrl = str2.replace("%s3", substring3);
break;
}
break;
case 4:
String str3 = webChapter.formatUrl;
if (str3 != null) {
webChapter.formatUrl = str3.replace("%s4", substring3);
break;
}
break;
case 5:
String str4 = webChapter.formatUrl;
if (str4 != null) {
webChapter.formatUrl = str4.replace("%s5", substring3);
break;
}
break;
case 6:
String str5 = webChapter.formatUrl;
if (str5 != null) {
webChapter.formatUrl = str5.replace("%s6", substring3);
break;
}
break;
}
}
} else {
i4 = i2 + valueOf.length();
}
i2 = i4;
i3 = 0;
}
i = indexOf + 1;
}
}
if (webChapter.url == null && !o50.F1(webChapter.formatUrl)) {
webChapter.url = o50.M1(site.last_url, webChapter.formatUrl);
}
return webChapter;
}
public static int favLinkId(String url) {
for (int i = 0; i < getFavLinks().size(); i++) {
if (getFavLinks().get(i).url.equals(url)) {
return i;
}
}
return -1;
}
public static String fillAffilicateUrl(String url) {
if (!URLUtil.isNetworkUrl(url)) {
return url;
}
if ((!url.contains(".qidian.com") && !url.contains(".hongxiu.com")) || url.contains("ADTAG=ssds")) {
return url;
}
StringBuilder sb = new StringBuilder();
sb.append(url);
sb.append(url.endsWith(".com") ? "/?ADTAG=ssds" : (url.endsWith(b.b) || !url.contains("?")) ? "?ADTAG=ssds" : "&ADTAG=ssds");
return sb.toString();
}
public static void fillWebBookFromTsBook(WebBook wbook, TS.Book tsBook) {
if (shorter(wbook.name, tsBook.name)) {
wbook.name = tsBook.name;
}
if (shorter(wbook.author, tsBook.author)) {
wbook.author = tsBook.author;
}
if (shorter(wbook.description, tsBook.description)) {
wbook.description = tsBook.description;
}
if (shorter(wbook.coverUrl, tsBook.cover)) {
wbook.coverUrl = tsBook.cover;
}
if (shorter(wbook.category, tsBook.category)) {
wbook.category = tsBook.category;
}
wbook.url = tsBook.url;
wbook.tag = tsBook.tag;
wbook.site = tsBook2Site(tsBook, true);
wbook.tsBook = tsBook;
}
public static void forceInitAllLinkSites() {
if (linkSites == null) {
initAllSites(false);
}
for (int size = linkSites.size() - 1; size >= 0; size--) {
if (!linkSites.get(size).ok()) {
linkSites.remove(size);
}
}
sortLinksSites();
}
public static void forceInitAllSites() {
long elapsedRealtime = SystemClock.elapsedRealtime();
for (int size = getAllSites().size() - 1; size >= 0; size--) {
if (!getAllSites().get(size).ok()) {
getAllSites().remove(size);
}
}
e50.N5("*forceInitAllSites time:" + (SystemClock.elapsedRealtime() - elapsedRealtime));
sortAllSites(true);
forceInitedAllSite = true;
}
private static void generateExtendedChapters(BookSite site, String source, ArrayList<WebChapter> chapters) {
int indexOf;
String str = VIP_CHAPTER;
try {
int indexOf2 = source.indexOf("<select");
if (indexOf2 == -1 || (indexOf = source.indexOf("<option", indexOf2)) == -1) {
return;
}
int indexOf3 = source.indexOf(">", indexOf) + 1;
String substring = source.substring(indexOf3, source.indexOf("<", indexOf3));
int z2 = o50.z2(substring.substring(substring.indexOf("-") + 1));
int lastIndexOf = source.lastIndexOf("</option", source.indexOf("</select", indexOf3));
String substring2 = source.substring(source.lastIndexOf(">", lastIndexOf) + 1, lastIndexOf);
int z22 = o50.z2(substring2.substring(substring2.indexOf("-") + 1));
if (z22 <= z2 || z2 <= 10) {
return;
}
String str2 = chapters.get(chapters.size() - 1).url;
if (!chapters.get(chapters.size() - 1).name.startsWith(VIP_CHAPTER)) {
str = UNKNOWN_CHAPTER;
}
String substring3 = str2.substring(0, str2.lastIndexOf("=") + 1);
while (true) {
z2++;
if (z2 > z22) {
return;
}
WebChapter webChapter = new WebChapter();
webChapter.name = str + "第" + z2 + "章";
StringBuilder sb = new StringBuilder();
sb.append(substring3);
sb.append(z2);
webChapter.url = sb.toString();
chapters.add(webChapter);
}
} catch (Exception e) {
e50.S0(e);
}
}
public static ArrayList<BookSite> getAllSites() {
if (allSites == null) {
initAllSites(false);
}
return allSites;
}
public static ArrayList<String> getBlockFullList() {
if (blockFullList == null) {
blockFullList = o50.C2(e50.s1("block_full"));
String str = e50.R1 + "/block_full";
if (o50.A1(str)) {
blockFullList.addAll(o50.C2(o50.p0(str)));
}
}
return blockFullList;
}
public static ArrayList<String> getBlockList() {
if (blockList == null) {
blockList = o50.C2(e50.s1("block"));
String str = e50.R1 + "/block";
if (o50.A1(str)) {
blockList.addAll(o50.C2(o50.p0(str)));
}
}
return blockList;
}
public static WebBook getBookInfo(String html, BookSite site, String tags, boolean checkMultDomain, boolean ignoreUrl) {
int length;
int i;
BookSite multiSubSite;
if (checkMultDomain && (multiSubSite = getMultiSubSite(site, site.last_url)) != site) {
String str = tags == site.bookTags ? multiSubSite.bookTags : tags == site.searchTags ? multiSubSite.searchTags : multiSubSite.mainTags;
if (str != null) {
tags = str;
}
site = multiSubSite;
}
String lowerCase = html.toLowerCase();
WebBook webBook = new WebBook();
webBook.site = site;
if (tags != null) {
int i2 = 0;
int i3 = 0;
int i4 = 0;
boolean z = true;
while (true) {
int indexOf = tags.indexOf("\n", i2);
if (indexOf != -1 && indexOf - i2 > 0) {
String substring = tags.substring(i2, indexOf);
int indexOf2 = substring.indexOf("*");
if (indexOf2 == -1) {
int indexOf3 = lowerCase.indexOf(substring, i3);
if (indexOf3 == -1 && !site.allowParkBookInfo && !isBookOk(site, webBook, ignoreUrl)) {
return new WebBook();
}
i3 = indexOf3 + substring.length();
} else if (i4 == 0) {
i4 = Integer.valueOf("" + substring.charAt(indexOf2 + 1)).intValue();
String substring2 = substring.substring(0, indexOf2);
int indexOf4 = lowerCase.indexOf(substring2, i3);
boolean z2 = indexOf4 != -1;
if (z2) {
i3 = indexOf4;
}
i3 += substring2.length();
z = z2;
} else {
String substring3 = substring.substring(0, indexOf2);
if (z) {
i = lowerCase.indexOf(substring3, i3);
if (i != -1) {
String substring4 = html.substring(i3, i);
switch (i4) {
case 1:
webBook.name = trim(Html.fromHtml(substring4).toString());
break;
case 2:
String trim = trim(Html.fromHtml(substring4).toString());
webBook.author = trim;
if (trim.startsWith(":") || webBook.author.startsWith(":")) {
webBook.author = webBook.author.substring(1);
break;
}
break;
case 3:
webBook.description = trim(Html.fromHtml(substring4).toString());
break;
case 4:
webBook.category = trim(Html.fromHtml(substring4).toString());
break;
case 5:
webBook.url = o50.M1(site.last_url, substring4);
break;
case 6:
getCoverUrl(webBook, site, substring4);
break;
case 7:
webBook.charCount = trim(substring4);
break;
case 8:
webBook.updateTime = trim(Html.fromHtml(substring4).toString());
break;
case 9:
webBook.bookId = substring4.trim();
break;
}
i3 = i;
i4 = 0;
z = true;
} else {
length = substring3.length();
}
} else {
length = substring3.length();
}
i = i3 + length;
i3 = i;
i4 = 0;
z = true;
}
i2 = indexOf + 1;
}
}
}
if (o50.F1(webBook.url) && !o50.F1(webBook.bookId) && !o50.F1(site.bookUrlFormat)) {
webBook.url = site.bookUrlFormat.replace("%id", webBook.bookId);
}
e50.N5("book: " + webBook.name + " - " + webBook.author);
return webBook;
}
public static ArrayList<WebBook> getBookList(String source, BookSite site) {
String substring;
String str;
ArrayList<WebBook> arrayList = new ArrayList<>();
if (source != null) {
try {
String lowerCase = source.toLowerCase();
int indexOf = o50.F1(site.searchStart) ? 0 : lowerCase.indexOf(site.searchStart);
int indexOf2 = o50.F1(site.searchEnd) ? -1 : lowerCase.indexOf(site.searchEnd, indexOf + 1);
String str2 = "";
if (indexOf == -1) {
substring = "";
} else {
substring = source.substring(indexOf, indexOf2 != -1 ? indexOf2 + 1 : source.length());
}
String lowerCase2 = substring.toLowerCase();
boolean z = (o50.F1(site.searchStart) && o50.F1(site.searchEnd)) || (indexOf > 0 && indexOf2 > 0);
refreshLastUrl(site, lowerCase);
int i = 0;
while (true) {
int indexOf3 = lowerCase2.indexOf(site.bookStart, i);
if (indexOf3 == -1) {
break;
}
int length = o50.F1(site.bookEnd) ? substring.length() - 1 : lowerCase2.indexOf(site.bookEnd, site.bookStart.length() + indexOf3);
if (length == -1) {
length = substring.length() - 1;
}
String str3 = site.bookStart;
int indexOf4 = lowerCase2.indexOf(str3, str3.length() + indexOf3);
if (indexOf4 != -1 && length > indexOf4) {
length = indexOf4;
}
WebBook bookInfo = getBookInfo(substring.substring(indexOf3, length + 1), site, site.searchTags, false, false);
if (isBookOk(site, bookInfo, false)) {
arrayList.add(bookInfo);
}
i = length;
}
if (!o50.F1(site.mainStart)) {
int indexOf5 = lowerCase.indexOf(site.mainStart);
int indexOf6 = lowerCase.indexOf(site.mainEnd, indexOf5 + 1);
if (indexOf5 != -1) {
str2 = source.substring(indexOf5, indexOf6 != -1 ? indexOf6 + 1 : source.length());
}
WebBook bookInfo2 = getBookInfo(str2.toLowerCase(), site, site.mainTags, false, false);
if (isBookOk(site, bookInfo2, false)) {
arrayList.add(0, bookInfo2);
}
}
site.nextPageUrl = null;
if (arrayList.size() > 1) {
if (((!o50.F1(site.currentKey)) & (!o50.F1(site.nextPageTag))) && lowerCase.contains(site.nextPageTag)) {
site.pageNo++;
String str4 = site.nextPageStyle;
StringBuilder sb = new StringBuilder();
sb.append(str4.substring(0, str4.length() - 1));
sb.append(str4.endsWith("1") ? site.pageNo : site.pageNo + 1);
String sb2 = sb.toString();
if (o50.F1(site.nextPageOriginal)) {
site.nextPageUrl = site.searchUrl.replace("%s", site.currentKey) + h1.b + sb2;
} else {
site.nextPageUrl = site.nextPageOriginal.replace(str4, sb2).replace("%s", site.currentKey);
}
e50.N5("nextPageUrl:" + site.nextPageUrl);
}
}
if ((!z || arrayList.size() == 0) && (str = site.bookTags) != null) {
WebBook bookInfo3 = getBookInfo(source, site, str, false, true);
if (o50.F1(bookInfo3.url)) {
bookInfo3.url = site.last_url;
}
if (isBookOk(site, bookInfo3, false)) {
arrayList.clear();
arrayList.add(bookInfo3);
}
}
} catch (Exception e) {
e50.N5("before error, books: " + arrayList.size());
e50.S0(e);
}
}
Object[] objArr = new Object[1];
StringBuilder sb3 = new StringBuilder();
sb3.append("books: ");
sb3.append(site.name());
sb3.append(b.b);
sb3.append(site.siteTag);
sb3.append(", books: ");
sb3.append(arrayList.size());
sb3.append(" (source:");
sb3.append(source == null ? b.p : Integer.valueOf(source.length()));
sb3.append(")");
objArr[0] = sb3.toString();
e50.N5(objArr);
return arrayList;
}
public static String getChapterContent(String source, BookSite site) {
String str = "";
if (site != null && source != null) {
BookSite multiSubSite = getMultiSubSite(site, site.last_url);
String extractContent = extractContent(source, multiSubSite.contentTags);
if (o50.F1(extractContent) && !o50.F1(multiSubSite.contentTags2)) {
extractContent = extractContent(source, multiSubSite.contentTags2);
}
if (o50.F1(multiSubSite.brokenContentTag) || !extractContent.contains(multiSubSite.brokenContentTag)) {
str = extractContent;
} else {
e50.N5("content has brokenContentTag: " + multiSubSite.brokenContentTag);
}
if (!o50.F1(str)) {
str = o50.F(str);
}
e50.N5("content: " + multiSubSite.name() + b.b + multiSubSite.siteTag + ", len: " + str.length() + ", source len: " + source.length());
return str;
}
Object[] objArr = new Object[1];
StringBuilder sb = new StringBuilder();
sb.append("source len: ");
sb.append(source == null ? b.p : Integer.valueOf(source.length()));
sb.append(", site:");
sb.append(site);
objArr[0] = sb.toString();
e50.N5(objArr);
return "";
}
public static ArrayList<WebChapter> getChapterList(String source, BookSite site) {
int indexOf;
int length;
int indexOf2;
String str = "'";
BookSite multiSubSite = getMultiSubSite(site, site.last_url);
ArrayList<WebChapter> arrayList = new ArrayList<>();
if (source != null) {
try {
String lowerCase = source.toLowerCase();
refreshLastUrl(multiSubSite, lowerCase);
String str2 = "";
int i = -1;
if (multiSubSite.chapterUrlTags != null && multiSubSite.firstExecute) {
int length2 = multiSubSite.chapterUrlBackword ? source.length() : 0;
String str3 = "";
int i2 = 0;
while (true) {
if (i2 >= multiSubSite.chapterUrlTags.size()) {
break;
}
str3 = multiSubSite.chapterUrlTags.get(i2);
int lastIndexOf = multiSubSite.chapterUrlBackword ? lowerCase.lastIndexOf(str3, length2) : lowerCase.indexOf(str3, length2);
if (lastIndexOf == -1) {
length2 = 0;
break;
}
length2 = lastIndexOf + str3.length();
i2++;
}
if (length2 > 0) {
WebChapter webChapter = new WebChapter();
if (!str3.endsWith("'")) {
str = "\"";
}
webChapter.url = o50.M1(multiSubSite.last_url, source.substring(length2, lowerCase.indexOf(str, length2)));
webChapter.name = CHAPTER_URL_TAG;
arrayList.add(webChapter);
e50.N5("chapter*: " + multiSubSite.name() + b.b + multiSubSite.siteTag + ", only has chapter url: " + webChapter.url);
return arrayList;
}
}
int indexOf3 = o50.F1(multiSubSite.chapterStart) ? 0 : lowerCase.indexOf(multiSubSite.chapterStart);
int indexOf4 = o50.F1(multiSubSite.chapterEnd) ? -1 : lowerCase.indexOf(multiSubSite.chapterEnd, indexOf3 + 1);
if (indexOf3 != -1) {
str2 = source.substring(indexOf3, indexOf4 != -1 ? indexOf4 + 1 : source.length());
}
String lowerCase2 = str2.toLowerCase();
int indexOf5 = !o50.F1(multiSubSite.vipStartTag) ? str2.indexOf(multiSubSite.vipStartTag, multiSubSite.chapterStart.length()) : -1;
String str4 = null;
if (!o50.F1(multiSubSite.chapterBookIdStart) && !o50.F1(multiSubSite.chapterBookIdEnd) && (indexOf = source.indexOf(multiSubSite.chapterBookIdStart)) != -1 && (indexOf2 = source.indexOf(multiSubSite.chapterBookIdEnd, (length = indexOf + multiSubSite.chapterBookIdStart.length()))) > length) {
str4 = source.substring(length, indexOf2);
}
int i3 = 0;
while (true) {
int indexOf6 = lowerCase2.indexOf(multiSubSite.chapterItemStart, i3);
if (indexOf6 == i) {
break;
}
String str5 = multiSubSite.chapterItemEnd;
int length3 = o50.F1(str5) ? str2.length() - 1 : lowerCase2.indexOf(str5, multiSubSite.chapterItemStart.length() + indexOf6);
if (length3 == i) {
length3 = str2.length() - 1;
}
int length4 = (o50.F1(str5) ? 1 : str5.length()) + length3;
if (length4 > str2.length()) {
length4 = str2.length();
}
String substring = str2.substring(indexOf6, length4);
String lowerCase3 = substring.toLowerCase();
WebChapter extractWebChapter = extractWebChapter(substring, lowerCase3, multiSubSite, multiSubSite.chapterTags, str4);
boolean isChapterOk = isChapterOk(multiSubSite, extractWebChapter);
if (!isChapterOk && !o50.F1(multiSubSite.chapterTags2)) {
extractWebChapter = extractWebChapter(substring, lowerCase3, multiSubSite, multiSubSite.chapterTags2, str4);
isChapterOk = isChapterOk(multiSubSite, extractWebChapter);
}
if (isChapterOk) {
if (multiSubSite.primary() && ((!o50.F1(multiSubSite.vipChapterTag) && substring.contains(multiSubSite.vipChapterTag)) || ((!o50.F1(multiSubSite.notVipChapterTag) && !substring.contains(multiSubSite.notVipChapterTag)) || (indexOf5 > 0 && indexOf6 > indexOf5)))) {
extractWebChapter.vip = true;
extractWebChapter.name = VIP_CHAPTER + extractWebChapter.name;
}
arrayList.add(extractWebChapter);
}
i3 = length3;
i = -1;
}
} catch (Exception e) {
e50.N5("before error, chapters: " + arrayList.size());
e50.S0(e);
}
}
if (multiSubSite.chapterReversed) {
ArrayList<WebChapter> arrayList2 = new ArrayList<>();
for (int size = arrayList.size() - 1; size >= 0; size--) {
arrayList2.add(arrayList.get(size));
}
arrayList = arrayList2;
}
if (multiSubSite.extendChapters && arrayList.size() >= 10) {
generateExtendedChapters(multiSubSite, source, arrayList);
}
if (multiSubSite.resortChapters) {
resortChapters(arrayList);
}
if (multiSubSite.deleteDuplicatedChapters) {
deleteDuplicatedChapters(arrayList);
}
Object[] objArr = new Object[1];
StringBuilder sb = new StringBuilder();
sb.append("chapter: ");
sb.append(multiSubSite.name());
sb.append(b.b);
sb.append(multiSubSite.siteTag);
sb.append(", chapters: ");
sb.append(arrayList.size());
sb.append(" (source:");
sb.append(source == null ? b.p : Integer.valueOf(source.length()));
sb.append(")");
objArr[0] = sb.toString();
e50.N5(objArr);
return arrayList;
}
public static WebChromeClient getChromeClient(BookSite site) {
if (site != null && (site.allowPopup || (site.primary() && !site.disableVipPopup))) {
return new NormalChromeClient();
}
return new NoPopupChromeClient();
}
public static String getClearAdDivJs() {
ArrayList<String> C2 = o50.C2(e50.s1("ad_filters"));
String str = "javascript:";
for (int i = 0; i < C2.size(); i++) {
str = str + "var adDiv" + i + "= document.getElementById('" + C2.get(i) + "');if(adDiv" + i + " != null)adDiv" + i + ".parentNode.removeChild(adDiv" + i + ");";
}
return str;
}
public static void getCoverUrl(WebBook book, BookSite site, String value) {
if ((o50.F1(book.coverUrl) || o50.F1(site.bestCoverTag) || !book.coverUrl.contains(site.bestCoverTag)) && !value.endsWith(".js")) {
book.coverUrl = o50.M1(site.last_url, value);
}
}
private static ArrayList<String> getDeletedSites() {
if (deletedSites == null) {
String str = e50.n4() + "/.deleted";
String deletedSitesFile = getDeletedSitesFile();
if (o50.A1(str)) {
if (!o50.A1(deletedSitesFile)) {
o50.v(str, deletedSitesFile, true);
}
o50.C(str);
}
deletedSites = o50.C2(o50.p0(deletedSitesFile));
}
return deletedSites;
}
public static String getDeletedSitesFile() {
return e50.R1 + "/.deletedSites";
}
public static String getDomain(String url) {
int indexOf = url.indexOf("//");
if (indexOf != -1) {
url = url.substring(indexOf + 2);
}
int indexOf2 = url.indexOf(b.b);
return indexOf2 != -1 ? url.substring(0, indexOf2) : url;
}
public static ArrayList<FavLink> getFavLinks() {
if (favLinks == null) {
favLinks = new ArrayList<>();
Iterator<String> it = o50.C2(o50.p0(e50.R1 + "/fav_links")).iterator();
while (it.hasNext()) {
String next = it.next();
int indexOf = next.indexOf("*#*");
if (indexOf != -1) {
FavLink favLink = new FavLink();
favLink.name = next.substring(0, indexOf);
favLink.url = next.substring(indexOf + 3);
favLinks.add(favLink);
}
}
}
return favLinks;
}
public static ArrayList<String> getForceWebSites() {
if (forceWebSites == null) {
forceWebSites = o50.C2(o50.p0(e50.R1 + "/forceWebSites"));
}
return forceWebSites;
}
public static ArrayList<String> getIgnoreAdTipSites() {
if (ignoreAdTipSites == null) {
ignoreAdTipSites = o50.C2(o50.p0(e50.R1 + "/ignoreAdTip"));
}
return ignoreAdTipSites;
}
public static LinkSite getLastDiscoverySite() {
if (getLinkSites().size() == 0) {
return null;
}
return getLinkSites().get(0);
}
public static LinkSite getLinkSite(String siteTag) {
try {
siteTag = siteTag.trim();
if (siteTag.length() == 0) {
return null;
}
Iterator<LinkSite> it = getLinkSites().iterator();
while (it.hasNext()) {
LinkSite next = it.next();
if (next.siteTag.equals(siteTag)) {
return next;
}
}
return null;
} catch (ConcurrentModificationException e) {
e50.S0(e);
o50.V1(200L);
return getLinkSite(siteTag);
}
}
public static ArrayList<LinkSite> getLinkSites() {
if (linkSites == null) {
initAllSites(false);
}
return linkSites;
}
public static String getLinkUserAgent(String url) {
String domain = getDomain(url);
Iterator<LinkSite> it = getLinkSites().iterator();
while (it.hasNext()) {
LinkSite next = it.next();
if (domain.equals(next.domain)) {
return next.userAgent;
}
}
return null;
}
public static BookSite getMultiSubSite(BookSite site, String lastUrl) {
BookSite subSite;
if (!site.multiDomains || o50.F1(lastUrl) || (subSite = getSubSite(getDomain(lastUrl))) == null) {
return site;
}
subSite.ok();
subSite.last_url = lastUrl;
subSite.firstExecute = site.firstExecute;
return subSite;
}
public static String getNextChapterUrl(String content, BookSite site, ArrayList<String> ignoreList) {
int indexOf;
int indexOf2;
if (site != null && !o50.F1(site.nextChapterTag) && !o50.F1(site.nextChapterEnd) && !o50.F1(content) && (indexOf = content.indexOf(site.nextChapterTag)) != -1 && (indexOf2 = content.indexOf(site.nextChapterEnd, indexOf)) != -1) {
ArrayList<o50.e> E0 = o50.E0(content.substring(indexOf, site.nextChapterEnd.length() + indexOf2), true);
if (o50.G1(E0)) {
E0 = o50.A0(content.substring(indexOf, indexOf2 + site.nextChapterEnd.length()), true);
}
Iterator<o50.e> it = E0.iterator();
while (it.hasNext()) {
o50.e next = it.next();
next.a = o50.M1(site.last_url, next.a);
}
if (!o50.G1(ignoreList)) {
Iterator<String> it2 = ignoreList.iterator();
while (it2.hasNext()) {
String next2 = it2.next();
for (int size = E0.size() - 1; size >= 0; size--) {
if (E0.get(size).a.equals(next2)) {
E0.remove(size);
}
}
}
}
if (E0.size() > 0) {
return E0.get(0).a;
}
}
return null;
}
public static String getNextContentUrl(String content, BookSite site, ArrayList<String> ignoreList, String stopUrl) {
int indexOf;
int indexOf2;
if (site != null && !o50.F1(site.nextContentTag) && !o50.F1(site.nextContentEnd) && !o50.F1(content) && (indexOf = content.indexOf(site.nextContentTag)) != -1 && (indexOf2 = content.indexOf(site.nextContentEnd, indexOf)) != -1) {
ArrayList<o50.e> E0 = o50.E0(content.substring(indexOf, site.nextContentEnd.length() + indexOf2), true);
if (o50.G1(E0)) {
E0 = o50.A0(content.substring(indexOf, indexOf2 + site.nextContentEnd.length()), true);
}
Iterator<o50.e> it = E0.iterator();
while (it.hasNext()) {
o50.e next = it.next();
next.a = o50.M1(site.last_url, next.a);
}
if (stopUrl != null) {
int i = 0;
while (true) {
if (i >= E0.size()) {
break;
}
if (E0.get(i).a.equals(stopUrl)) {
for (int size = E0.size() - 1; size >= i; size--) {
E0.remove(size);
}
} else {
i++;
}
}
}
if (!o50.G1(ignoreList)) {
Iterator<String> it2 = ignoreList.iterator();
while (it2.hasNext()) {
String next2 = it2.next();
for (int size2 = E0.size() - 1; size2 >= 0; size2--) {
if (E0.get(size2).a.equals(next2)) {
E0.remove(size2);
}
}
}
}
if (E0.size() > 0) {
return E0.get(0).a;
}
}
return null;
}
public static String getPureUrl(String url) {
int indexOf = url.indexOf("//");
return indexOf != -1 ? url.substring(indexOf + 2) : url;
}
public static String getSelectedFile() {
return e50.h ? "selected2.txt" : "selected.txt";
}
public static BookSite getSite(String siteTag, boolean forceInit) {
BookSite site = getSite(siteTag);
if (site != null && forceInit) {
site.ok();
}
return site;
}
public static String getSiteDefine(String filename) {
String u1;
try {
if (filename.startsWith(b.b)) {
u1 = o50.p0(filename);
} else {
u1 = o50.u1(e50.S1().getAssets().open(filename));
}
return clearTxt(u1);
} catch (Exception e) {
e50.S0(e);
return null;
}
}
public static BookSite getSiteFromName(String name) {
if (!o50.F1(name)) {
try {
String trim = name.trim();
if (trim.length() == 0) {
return null;
}
Iterator<BookSite> it = getAllSites().iterator();
while (it.hasNext()) {
BookSite next = it.next();
if (next.name().equals(trim)) {
return next;
}
}
} catch (Exception e) {
e50.S0(e);
}
}
return null;
}
public static ArrayList<BookSite> getSites() {
if (sites == null) {
initSites(true);
}
return sites;
}
public static String getStoreUrlFile(String name, String author) {
return e50.x + "/store/" + name + "(" + author + ").surl";
}
public static BookSite getSubSite(String siteTag) {
try {
siteTag = siteTag.trim();
if (siteTag.length() == 0) {
return null;
}
if (subSites == null) {
initAllSites(false);
}
Iterator<BookSite> it = subSites.iterator();
while (it.hasNext()) {
BookSite next = it.next();
if (next.siteTag.equals(siteTag)) {
return next;
}
}
return null;
} catch (ConcurrentModificationException e) {
e50.S0(e);
o50.V1(200L);
return getSubSite(siteTag);
}
}
public static String getTagValue(String text, String tag) {
int indexOf = text.indexOf(tag);
if (indexOf == -1) {
return null;
}
int indexOf2 = text.indexOf("\n", indexOf);
int length = indexOf + tag.length();
if (indexOf2 == -1) {
indexOf2 = text.length();
}
String trim = text.substring(length, indexOf2).trim();
if (o50.F1(trim)) {
return null;
}
return trim;
}
public static ArrayList<BookSite> getTopSites() {
if (topSites == null) {
initTopSites(true);
}
return topSites;
}
public static String getUnicode(String key) {
String str = "";
for (char c : key.toCharArray()) {
String hexString = Integer.toHexString(c);
if (hexString.length() <= 2) {
hexString = "00" + hexString;
}
str = str + "%25u" + hexString;
}
return str;
}
public static boolean ignoreAdTip(String siteTag) {
return getIgnoreAdTipSites().contains(siteTag);
}
public static void importDefaultThirdSources() {
String s1 = e50.s1("third_sources.json");
if (o50.F1(s1)) {
return;
}
TS.importSources(s1, null);
TS.resetSourcesCache();
}
public static synchronized void initAllSites(boolean forceRefresh) {
synchronized (S.class) {
if (allSites == null || forceRefresh) {
long elapsedRealtime = SystemClock.elapsedRealtime();
allSites = new ArrayList<>();
subSites = new ArrayList<>();
linkSites = new ArrayList<>();
try {
AssetManager assets = e50.S1().getAssets();
for (String str : assets.list("cnweb")) {
if ((str.endsWith(".wj") || str.endsWith(".wj2") || str.endsWith(".sub") || str.endsWith(".store")) && !isStoreSite(str)) {
BookSite bookSite = new BookSite("cnweb/" + str, (String) null, false);
if (str.endsWith(".sub")) {
subSites.add(bookSite);
} else {
allSites.add(bookSite);
}
}
}
for (String str2 : assets.list("cnweb2")) {
if (str2.endsWith(".wlink")) {
linkSites.add(new LinkSite("cnweb2/" + str2, null, false));
}
}
appendSitesInSdCard();
Iterator<String> it = getDeletedSites().iterator();
while (it.hasNext()) {
BookSite site = getSite(it.next());
if (site != null) {
linkSites.remove(site);
allSites.remove(site);
}
}
for (int size = allSites.size() - 1; size >= 0; size--) {
if (TS.isSiteBlocked(allSites.get(size).siteTag)) {
allSites.remove(size);
}
}
for (int size2 = linkSites.size() - 1; size2 >= 0; size2--) {
if (TS.isSiteBlocked(linkSites.get(size2).siteTag)) {
linkSites.remove(size2);
}
}
if (storeToDiscovery() && !linkSites.contains(store)) {
linkSites.add(0, store);
}
linkSitesSorted = false;
allSitesSorted = false;
} catch (Exception e) {
e50.S0(e);
}
e50.N5("init all sites time: " + (SystemClock.elapsedRealtime() - elapsedRealtime));
inited = true;
}
}
}
public static void initAllSitesInThread() {
if (SystemClock.elapsedRealtime() - initAllSitesTime < 300000) {
return;
}
initAllSitesTime = SystemClock.elapsedRealtime();
e50.N5("*initAllSitesInThread");
TS.getBlockSiteList();
Thread thread = new Thread() {
@Override
public void run() {
S.initAllSites(false);
S.checkOnlineSitesUpdate();
z2.blockBookList = S.getBlockList();
z2.blockFullList = S.getBlockFullList();
}
};
thread.setPriority(1);
thread.start();
}
public static void initLinkSiteParams() {
if (linkSiteParamsInited) {
return;
}
linkSiteParamsInited = true;
Iterator<LinkSite> it = getLinkSites().iterator();
while (it.hasNext()) {
initLinkSiteParams2(it.next());
}
}
public static void initLinkSiteParams2(LinkSite site) {
String str = site.bookPageFormat;
if (!o50.F1(str)) {
if (o50.F1(site.bookPageUrl)) {
site.bookPageUrl = str;
}
String pureUrl = getPureUrl(str);
site.bookPageFormat = pureUrl;
int indexOf = pureUrl.indexOf("%id");
if (indexOf != -1) {
site.bookPageStart = pureUrl.substring(0, indexOf);
site.bookPageEnd = pureUrl.substring(indexOf + 3, pureUrl.length());
}
}
String str2 = site.chapterPageForamt;
if (!o50.F1(str2)) {
if (o50.F1(site.chapterPageUrl)) {
site.chapterPageUrl = str2;
}
String pureUrl2 = getPureUrl(str2);
site.chapterPageForamt = pureUrl2;
int indexOf2 = pureUrl2.indexOf("%id");
if (indexOf2 != -1) {
site.chapterPageStart = pureUrl2.substring(0, indexOf2);
site.chapterPageEnd = pureUrl2.substring(indexOf2 + 3, pureUrl2.length());
}
}
String str3 = site.contentPageFormat;
if (o50.F1(str3)) {
return;
}
if (o50.F1(site.contentPageUrl)) {
site.contentPageUrl = str3;
}
String pureUrl3 = getPureUrl(str3);
site.contentPageFormat = pureUrl3;
int indexOf3 = pureUrl3.indexOf("%id");
if (indexOf3 != -1) {
site.contentPageStart = pureUrl3.substring(0, indexOf3);
int indexOf4 = pureUrl3.indexOf("%cid", indexOf3);
if (indexOf4 != -1) {
site.contentPageEnd = pureUrl3.substring(indexOf4 + 4, pureUrl3.length());
} else {
site.contentPageEnd = pureUrl3.substring(indexOf3 + 3, pureUrl3.length());
}
}
}
public static void initSites(boolean forceRefresh) {
if (sites == null || forceRefresh) {
sites = new ArrayList<>();
Iterator<String> it = o50.C2(o50.p0(e50.R1 + "/.selected")).iterator();
while (it.hasNext()) {
BookSite site = getSite(it.next());
if (site != null && !siteDisabled(site)) {
sites.add(site);
}
}
if (store != null && z2.storeLevel == 0 && sites.indexOf(store) == -1) {
sites.add(store);
}
if (store != null && z2.storeLevel >= 4 && sites.contains(store)) {
sites.remove(store);
}
int size = getTopSites().size();
while (true) {
size--;
if (size < 0) {
break;
}
BookSite bookSite = getTopSites().get(size);
if (sites.contains(bookSite)) {
sites.remove(bookSite);
sites.add(0, bookSite);
}
}
if (sites.size() < getAllSites().size()) {
for (int size2 = sites.size() - 1; size2 >= 0; size2--) {
getAllSites().remove(sites.get(size2));
getAllSites().add(0, sites.get(size2));
}
}
for (int size3 = getTopSites().size() - 1; size3 >= 0; size3--) {
getAllSites().remove(getTopSites().get(size3));
getAllSites().add(0, getTopSites().get(size3));
}
}
}
public static void initTopSites(boolean forceRefresh) {
if (topSites == null || forceRefresh) {
topSites = new ArrayList<>();
String str = e50.R1 + "/.top";
String str2 = e50.n4() + "/.top";
if (o50.A1(str2)) {
if (!o50.A1(str)) {
o50.v(str2, str, true);
}
o50.C(str2);
}
if (o50.A1(str)) {
Iterator<String> it = o50.C2(o50.p0(str)).iterator();
while (it.hasNext()) {
BookSite site = getSite(it.next());
if (site != null) {
topSites.add(site);
}
}
}
}
}
public static boolean isBookOk(BookSite site, WebBook book, boolean ignoreUrl) {
int i;
String str;
if (o50.F1(book.name) || bookInBlockList(book.name)) {
return false;
}
if ((!ignoreUrl && o50.F1(book.url)) || book.name.length() > 120) {
return false;
}
if (!o50.F1(site.brokenBookTag) && (book.name.contains(site.brokenBookTag) || ((str = book.url) != null && str.contains(site.brokenBookTag)))) {
return false;
}
String str2 = book.url;
if (str2 != null && str2.contains("javascript:")) {
return false;
}
String K1 = o50.K1(book.name);
book.name = K1;
int indexOf = K1.indexOf("《");
int indexOf2 = book.name.indexOf("》");
if (indexOf != -1 && indexOf2 > (i = indexOf + 1)) {
book.name = book.name.substring(i, indexOf2);
}
String str3 = book.description;
if (str3 != null && str3.length() > 600) {
book.description = book.description.substring(0, 600) + "...";
}
return true;
}
public static boolean isChapterOk(BookSite site, WebChapter c) {
if (o50.F1(c.name) || o50.F1(c.url)) {
return false;
}
return ((!o50.F1(site.brokenChapterTag) && (c.name.contains(site.brokenChapterTag) || c.url.contains(site.brokenChapterTag))) || c.url.contains("javascript:") || c.url.contains("{id}")) ? false : true;
}
public static boolean isFreeBookUrl(String url) {
return url != null && url.startsWith(FREEBOOK_URL);
}
private static boolean isStoreSite(String filename) {
if (!filename.endsWith("main.store")) {
return false;
}
if (!filename.startsWith(b.b)) {
filename = "cnweb/" + filename;
}
StoreSite storeSite = new StoreSite(filename);
if (!storeSite.ok()) {
return true;
}
StoreSite storeSite2 = store;
if (storeSite2 != null && allSites.contains(storeSite2)) {
allSites.remove(store);
}
store = storeSite;
allSites.add(storeSite);
return true;
}
public static boolean isVipChapter(String chapterName) {
return chapterName.startsWith(VIP_CHAPTER) || chapterName.startsWith(UNKNOWN_CHAPTER);
}
public static boolean openAppInWebView(final Activity act, final String url, final boolean showErrToast) {
if (e50.c5(url)) {
return false;
}
if (System.currentTimeMillis() - uriApplyTime < 2500) {
uriApplyTime = System.currentTimeMillis();
return true;
}
uriApplyTime = System.currentTimeMillis();
m.c cVar = uriDlg;
if (cVar != null) {
cVar.a();
}
m.c cVar2 = new m.c(act);
uriDlg = cVar2;
cVar2.m(Html.fromHtml("该网页请求打开你的应用, 是否继续?<br><br><small><font color=\"#888888\">Uri: " + url + "</font></small>")).v(R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
act.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(url)));
e50.N5("open app url:" + url);
} catch (Exception e) {
e50.S0(e);
if (showErrToast) {
o50.p2(act, e50.W0("没有找到指定应用"));
}
}
}
}).o(R.string.cancel, null).C();
return true;
}
private static String randomList(String text) {
if (text.contains("qidian")) {
return text;
}
ArrayList<String> C2 = o50.C2(text.replace(pl2.e, "").replace("\t", ""));
ArrayList arrayList = new ArrayList();
while (C2.size() > 0) {
arrayList.add(C2.remove(o50.R1(C2.size())));
}
return o50.B2(arrayList);
}
private static void refreshLastUrl(BookSite site, String lSource) {
int indexOf = lSource.indexOf("<base href=\"");
if (indexOf > 0) {
site.last_url = lSource.substring(indexOf + 12, lSource.indexOf("\"", indexOf + 13));
}
}
public static void resetSiteStates() {
try {
Iterator<BookSite> it = getAllSites().iterator();
while (it.hasNext()) {
restSiteState(it.next());
}
} catch (Exception e) {
e50.S0(e);
}
}
private static void resortChapters(ArrayList<WebChapter> chapters) {
Collections.sort(chapters, new Comparator<WebChapter>() {
@Override
public int compare(WebChapter c1, WebChapter c2) {
return c1.url.compareTo(c2.url);
}
});
}
public static void restSiteState(BookSite site) {
site.working = false;
site.load_time = 0L;
site.pageNo = 0;
site.last_url = null;
site.nextPageUrl = null;
site.currentKey = null;
site.err = null;
site.msg = null;
site.text1 = null;
site.text2 = null;
site.tag = null;
site.firstExecute = true;
}
public static boolean sameChapterList(ArrayList<WebChapter> c1, ArrayList<WebChapter> c2) {
return c1.size() > 0 && c2.size() > 0 && c1.get(0).url.equals(c2.get(0).url) && c1.get(0).name.equals(c2.get(0).name);
}
public static void saveFavLinks() {
ArrayList arrayList = new ArrayList();
Iterator<FavLink> it = getFavLinks().iterator();
while (it.hasNext()) {
FavLink next = it.next();
arrayList.add(next.name + "*#*" + next.url);
}
o50.i2(e50.R1 + "/fav_links", o50.B2(arrayList));
}
public static void saveSelectedSites() {
ArrayList arrayList = new ArrayList();
Iterator<BookSite> it = getSites().iterator();
while (it.hasNext()) {
arrayList.add(it.next().siteTag);
}
o50.i2(e50.R1 + "/.selected", o50.B2(arrayList));
}
public static void saveTopSites() {
ArrayList arrayList = new ArrayList();
Iterator<BookSite> it = getTopSites().iterator();
while (it.hasNext()) {
arrayList.add(it.next().siteTag);
}
o50.i2(e50.R1 + "/.top", o50.B2(arrayList));
}
public static void selectPrimarySites() {
sites = new ArrayList<>();
Iterator<BookSite> it = getAllSites().iterator();
while (it.hasNext()) {
BookSite next = it.next();
if (next.primary()) {
sites.add(next);
}
}
sortSites(sites);
saveSelectedSites();
}
private static void setDisableNormalSites(boolean disable) {
if (e50.h != disable) {
e50.h = disable;
initSites(true);
}
}
public static void setNightMode(WebView webview, boolean nightMode) {
}
public static void setWebViewSettings(WebView web) {
web.getSettings().setJavaScriptEnabled(true);
web.getSettings().setDomStorageEnabled(true);
web.getSettings().setDatabaseEnabled(true);
web.getSettings().setBuiltInZoomControls(true);
web.getSettings().setDisplayZoomControls(false);
if (Build.VERSION.SDK_INT >= 21) {
web.getSettings().setMixedContentMode(0);
}
enableWebViewCookie(web);
}
private static boolean shorter(String s1, String s2) {
if (s1 == null) {
return true;
}
return s2 != null && s1.length() < s2.length();
}
public static boolean siteDisabled(BookSite site) {
if (!e50.h || site.primary()) {
return false;
}
int i = site.siteType;
if (i != 2 || e50.i < 2) {
return i != 1 || e50.i < 3;
}
return false;
}
public static boolean sitesHaveNextPageUrl() {
Iterator<BookSite> it = getAllSites().iterator();
while (it.hasNext()) {
if (it.next().nextPageUrl != null) {
return true;
}
}
return false;
}
public static boolean sitesWorking() {
try {
Iterator<BookSite> it = getAllSites().iterator();
while (it.hasNext()) {
if (it.next().working) {
return true;
}
}
Iterator<BookSite> it2 = tempTsSites.iterator();
while (it2.hasNext()) {
if (it2.next().working) {
return true;
}
}
return false;
} catch (Exception e) {
e50.S0(e);
return false;
}
}
public static void sortAllSites(boolean forceUpdate) {
if (!allSitesSorted || forceUpdate) {
allSitesSorted = true;
Collections.sort(allSites, new Comparator<BookSite>() {
@Override
public int compare(BookSite o1, BookSite o2) {
if (o1.primary && !o2.primary) {
return -1;
}
if (o2.primary && !o1.primary) {
return 1;
}
int i = o1.siteType;
if (i > 0 && o2.siteType == 0) {
return 1;
}
int i2 = o2.siteType;
if (i2 > 0 && i == 0) {
return -1;
}
if (i > 1 && i2 <= 1) {
return 1;
}
if (i2 > 1 && i <= 1) {
return -1;
}
int i3 = o1.important;
int i4 = o2.important;
if (i3 == i4) {
return 0;
}
return i3 > i4 ? -1 : 1;
}
});
}
}
public static void sortLinksSites() {
if (linkSitesSorted) {
return;
}
linkSitesSorted = true;
Collections.sort(linkSites, new Comparator<LinkSite>() {
@Override
public int compare(LinkSite o1, LinkSite o2) {
int i = o1.important;
int i2 = o2.important;
if (i == i2) {
return 0;
}
return i > i2 ? -1 : 1;
}
});
}
public static void sortSites(ArrayList<BookSite> sites2) {
Collections.sort(sites2, new Comparator<BookSite>() {
@Override
public int compare(BookSite o1, BookSite o2) {
if (S.getTopSites().contains(o1) && !S.getTopSites().contains(o2)) {
return -1;
}
if (S.getTopSites().contains(o2) && !S.getTopSites().contains(o1)) {
return 1;
}
int i = o1.important;
int i2 = o2.important;
if (i == i2) {
return 0;
}
return i > i2 ? -1 : 1;
}
});
}
public static void startHotBookAct(Activity act, int requestCode) {
if (o50.G1(suggestFreeBooks)) {
return;
}
act.startActivityForResult(new Intent(act, (Class<?>) HotBookAct.class), requestCode);
}
public static boolean storeToDiscovery() {
return store != null && z2.storeLevel < 4;
}
public static String trim(String s) {
return s.replace("", "").replace(jy1.f, ' ').replace(e50.H9, ' ').replace('\t', ' ').replaceAll(" +", " ").trim();
}
public static BookSite tsBook2Site(TS.Book tsBook, boolean forceOk) {
BookSite bookSite = new BookSite(tsBook.sourceName, "$$" + tsBook.sourceName, tsBook.url);
bookSite.setOk(forceOk || TS.getSource(tsBook.tag) != null);
if (tsBook.downloadOnly) {
bookSite.siteType = 1;
}
return bookSite;
}
public static WebBook tsBook2WebBook(TS.Book tsBook) {
WebBook webBook = new WebBook();
fillWebBookFromTsBook(webBook, tsBook);
addTsChaptersToWebChapters(webBook.chapters, tsBook.chapters);
webBook.sources.add(webBook);
return webBook;
}
public static WebChapter tsChapter2WebChapter(TS.Chapter tc) {
WebChapter webChapter = new WebChapter();
webChapter.name = tc.name;
webChapter.url = tc.url;
webChapter.html = tc.text;
webChapter.tag = tc.tag;
webChapter.tsChapter = tc;
return webChapter;
}
public static void updateDefaultSelectedSites(boolean forceUpdate) {
try {
String str = e50.R1 + "/.selected";
String i1 = o50.i1(SELECTED_URL + getSelectedFile());
String clearTxt = i1 == null ? "" : clearTxt(i1);
boolean z = false;
if (o50.C2(clearTxt).size() >= 5) {
e50.N5("---------get online selected sites: \n" + clearTxt);
if (z2.storeLevel < 3 && !clearTxt.contains(ce.e) && store != null) {
clearTxt = "main\n" + clearTxt;
}
o50.i2(str, randomList(clearTxt));
z = true;
}
if ((forceUpdate && !z) || !o50.A1(str)) {
z = copyDefaultSelectedSites();
}
if (z) {
initSites(true);
}
} catch (Exception e) {
e50.S0(e);
}
}
private static String updateTagValue(String text, String tag, String old) {
String tagValue = getTagValue(text, tag);
return tagValue != null ? tagValue : old;
}
public static void validateFreeBookSource() {
if (TS.getSource(FREEBOOK_URL) == null) {
TS.importSources(e50.s1("free_source.json"), null);
TS.resetSourcesCache();
}
}
public static TS.Chapter webChapter2TsChapter(WebChapter wc) {
TS.Chapter chapter = new TS.Chapter();
chapter.name = wc.name;
chapter.url = wc.url;
chapter.text = wc.html;
chapter.tag = wc.tag;
wc.tsChapter = chapter;
return chapter;
}
private static int updateTagValue(String text, String tag, int old) {
String tagValue = getTagValue(text, tag);
return tagValue != null ? o50.z2(tagValue) : old;
}
public static BookSite getSite(String siteTag) {
if (!o50.F1(siteTag)) {
try {
siteTag = siteTag.trim();
if (siteTag.length() == 0) {
return null;
}
Iterator<BookSite> it = getAllSites().iterator();
while (it.hasNext()) {
BookSite next = it.next();
if (next.siteTag.equals(siteTag)) {
return next;
}
}
Iterator<LinkSite> it2 = getLinkSites().iterator();
while (it2.hasNext()) {
LinkSite next2 = it2.next();
if (next2.siteTag.equals(siteTag)) {
return next2;
}
}
} catch (ConcurrentModificationException e) {
e50.S0(e);
o50.V1(200L);
return getSite(siteTag);
}
}
return null;
}
public static class BookSite {
public int TOCDelay;
boolean allowParkBookInfo;
public boolean allowPopup;
public String authorSearchUrl;
String bestCoverTag;
String bookEnd;
public String bookPageEnd;
public String bookPageFormat;
public String bookPageStart;
public String bookPageUrl;
String bookStart;
public String bookTags;
String bookUrlFormat;
String brokenBookTag;
String brokenChapterTag;
public String brokenContentTag;
public String categoryUrl;
String chapterBookIdEnd;
String chapterBookIdStart;
String chapterEnd;
String chapterItemEnd;
String chapterItemStart;
public String chapterPageEnd;
public String chapterPageForamt;
public String chapterPageStart;
public String chapterPageUrl;
boolean chapterReversed;
String chapterStart;
String chapterTags;
String chapterTags2;
boolean chapterUrlBackword;
String chapterUrlFormat;
ArrayList<String> chapterUrlTags;
public int contentDelay;
public String contentJs;
public boolean contentKeepHtml;
public String contentPageEnd;
public String contentPageFormat;
public String contentPageStart;
public String contentPageUrl;
public boolean contentPureText;
public String contentTags;
public String contentTags2;
public int contentTimeout;
public String currentKey;
public ArrayList<String> deleteContentTags;
public ArrayList<String> deleteContentTags2;
boolean deleteDuplicatedChapters;
public boolean deleteInHtml;
public boolean disableVipPopup;
public boolean downloadable;
public String err;
boolean extendChapters;
public String filename;
public boolean firstExecute;
public boolean hasAd;
public int important;
public boolean isTsSite;
public boolean javascriptContent;
public boolean javascriptSearch;
public boolean javascriptTOC;
public String keyEncode;
public String last_url;
public long load_time;
String mainEnd;
String mainStart;
String mainTags;
public String msg;
public boolean multiDomains;
private String name;
public String nextChapterEnd;
public String nextChapterTag;
public String nextContentEnd;
public String nextContentTag;
String nextPageOriginal;
String nextPageStyle;
String nextPageTag;
public String nextPageUrl;
public String notVipChapterTag;
private Boolean ok;
public int pageNo;
public String postParams;
private boolean primary;
public String rankUrl;
boolean resortChapters;
public String searchAgent;
public int searchDelay;
String searchEnd;
String searchStart;
String searchTags;
public String searchUrl;
public String siteTag;
public int siteType;
public String site_define;
public String specialTip;
public Object tag;
public String text1;
public String text2;
public String url;
public String userAgent;
private int version;
public String vipChapterTag;
public String vipStartTag;
public int webReadLevel;
public boolean working;
public BookSite(String name, String siteTag, String url) {
this.isTsSite = true;
this.contentPureText = false;
this.contentKeepHtml = true;
this.name = name;
this.siteTag = siteTag;
this.url = url;
this.ok = Boolean.TRUE;
}
public void getDefines() {
int indexOf;
int indexOf2;
String str;
this.ok = Boolean.FALSE;
try {
if (this.site_define == null) {
this.site_define = S.getSiteDefine(this.filename);
}
String str2 = this.site_define;
int indexOf3 = str2.indexOf("name*") + 5;
this.name = str2.substring(indexOf3, str2.indexOf("\n", indexOf3));
int indexOf4 = str2.indexOf("version*");
if (indexOf4 != -1) {
this.version = o50.z2(str2.substring(indexOf4 + 8, str2.indexOf("\n", indexOf4)));
}
int indexOf5 = str2.indexOf("important*");
if (indexOf5 != -1) {
this.important = o50.z2(str2.substring(indexOf5 + 10, str2.indexOf("\n", indexOf5)));
}
int indexOf6 = str2.indexOf("siteType*");
if (indexOf6 != -1) {
this.siteType = o50.z2(str2.substring(indexOf6 + 9, str2.indexOf("\n", indexOf6)));
}
int indexOf7 = str2.indexOf("specialTip*");
if (indexOf7 != -1) {
this.specialTip = str2.substring(indexOf7 + 11, str2.indexOf("\n", indexOf7)).trim();
}
int indexOf8 = str2.indexOf("userAgent*");
if (indexOf8 != -1) {
this.userAgent = str2.substring(indexOf8 + 10, str2.indexOf("\n", indexOf8)).trim();
}
int indexOf9 = str2.indexOf("searchAgent*");
if (indexOf9 != -1) {
this.searchAgent = str2.substring(indexOf9 + 12, str2.indexOf("\n", indexOf9)).trim();
}
if (this.searchAgent == null && (str = this.userAgent) != null) {
this.searchAgent = str;
}
if (o50.F1(this.userAgent)) {
this.userAgent = S.USER_AGENT;
}
if (o50.F1(this.searchAgent)) {
this.searchAgent = S.USER_AGENT;
}
this.multiDomains = str2.contains("multiDomains*true");
this.downloadable = str2.contains("downloadable*true");
this.hasAd = str2.contains("hasAd*true");
this.allowPopup = str2.contains("allowPopup*true");
int indexOf10 = str2.indexOf("url*") + 4;
this.url = str2.substring(indexOf10, str2.indexOf("\n", indexOf10));
int indexOf11 = str2.indexOf("search*") + 7;
this.searchUrl = str2.substring(indexOf11, str2.indexOf("\n", indexOf11));
int indexOf12 = str2.indexOf("postParams*");
if (indexOf12 != -1) {
this.postParams = str2.substring(indexOf12 + 11, str2.indexOf("\n", indexOf12)).trim();
}
int indexOf13 = str2.indexOf("searchAuthor*");
if (indexOf13 != -1) {
this.authorSearchUrl = str2.substring(indexOf13 + 13, str2.indexOf("\n", indexOf13)).trim();
}
int indexOf14 = str2.indexOf("keyEncode*");
if (indexOf14 != -1) {
this.keyEncode = str2.substring(indexOf14 + 10, str2.indexOf("\n", indexOf14)).trim();
}
int indexOf15 = str2.indexOf("mainStart*");
if (indexOf15 != -1) {
int i = indexOf15 + 10;
int indexOf16 = str2.indexOf("\n", i);
String lowerCase = str2.substring(i, indexOf16).toLowerCase();
this.mainStart = lowerCase;
if (!o50.F1(lowerCase)) {
int indexOf17 = str2.indexOf("mainEnd*", indexOf16) + 8;
this.mainEnd = str2.substring(indexOf17, str2.indexOf("\n", indexOf17)).toLowerCase();
int indexOf18 = str2.indexOf("\n", str2.indexOf("//main_start")) + 1;
this.mainTags = str2.substring(indexOf18, str2.indexOf("//main_end", indexOf18)).toLowerCase();
}
}
int indexOf19 = str2.indexOf("searchStart*");
if (indexOf19 != -1) {
int i2 = indexOf19 + 12;
int indexOf20 = str2.indexOf("\n", i2);
this.searchStart = str2.substring(i2, indexOf20).toLowerCase();
int indexOf21 = str2.indexOf("searchEnd*", indexOf20) + 10;
int indexOf22 = str2.indexOf("\n", indexOf21);
this.searchEnd = str2.substring(indexOf21, indexOf22).toLowerCase();
int indexOf23 = str2.indexOf("bookStart*", indexOf22) + 10;
int indexOf24 = str2.indexOf("\n", indexOf23);
this.bookStart = str2.substring(indexOf23, indexOf24).toLowerCase();
int indexOf25 = str2.indexOf("bookEnd*", indexOf24) + 8;
int indexOf26 = str2.indexOf("\n", indexOf25);
this.bookEnd = str2.substring(indexOf25, indexOf26).toLowerCase();
int indexOf27 = str2.indexOf("\n", str2.indexOf("//search_start", indexOf26)) + 1;
this.searchTags = str2.substring(indexOf27, str2.indexOf("//search_end", indexOf27)).toLowerCase();
}
int indexOf28 = str2.indexOf("//book_start");
if (indexOf28 != -1) {
int indexOf29 = str2.indexOf("\n", indexOf28) + 1;
this.bookTags = str2.substring(indexOf29, str2.indexOf("//book_end", indexOf29)).toLowerCase();
}
int indexOf30 = str2.indexOf("chapterStart*");
if (indexOf30 != -1) {
int i3 = indexOf30 + 13;
int indexOf31 = str2.indexOf("\n", i3);
this.chapterStart = str2.substring(i3, indexOf31).toLowerCase();
int indexOf32 = str2.indexOf("chapterEnd*", indexOf31) + 11;
int indexOf33 = str2.indexOf("\n", indexOf32);
this.chapterEnd = str2.substring(indexOf32, indexOf33).toLowerCase();
int indexOf34 = str2.indexOf("chapterItemStart*", indexOf33) + 17;
int indexOf35 = str2.indexOf("\n", indexOf34);
this.chapterItemStart = str2.substring(indexOf34, indexOf35).toLowerCase();
int indexOf36 = str2.indexOf("chapterItemEnd*", indexOf35) + 15;
int indexOf37 = str2.indexOf("\n", indexOf36);
this.chapterItemEnd = str2.substring(indexOf36, indexOf37).toLowerCase();
int indexOf38 = str2.indexOf("\n", str2.indexOf("//chapter_start", indexOf37)) + 1;
int indexOf39 = str2.indexOf("//chapter_end", indexOf38);
this.chapterTags = str2.substring(indexOf38, indexOf39).toLowerCase();
int indexOf40 = str2.indexOf("//chapter_start2", indexOf39);
if (indexOf40 != -1) {
int indexOf41 = str2.indexOf("\n", indexOf40) + 1;
this.chapterTags2 = str2.substring(indexOf41, str2.indexOf("//chapter_end2", indexOf41)).toLowerCase();
}
this.chapterReversed = str2.contains("chapterReverse*true");
}
int indexOf42 = str2.indexOf("brokenBookTag*");
if (indexOf42 != -1) {
this.brokenBookTag = str2.substring(indexOf42 + 14, str2.indexOf("\n", indexOf42)).trim();
}
int indexOf43 = str2.indexOf("brokenChapterTag*");
if (indexOf43 != -1) {
this.brokenChapterTag = str2.substring(indexOf43 + 17, str2.indexOf("\n", indexOf43)).trim();
}
int indexOf44 = str2.indexOf("brokenContentTag*");
if (indexOf44 != -1) {
this.brokenContentTag = str2.substring(indexOf44 + 17, str2.indexOf("\n", indexOf44)).trim();
}
int indexOf45 = str2.indexOf("nextContentTag*");
if (indexOf45 != -1) {
this.nextContentTag = str2.substring(indexOf45 + 15, str2.indexOf("\n", indexOf45)).trim();
}
int indexOf46 = str2.indexOf("nextContentEnd*");
if (indexOf46 != -1) {
this.nextContentEnd = str2.substring(indexOf46 + 15, str2.indexOf("\n", indexOf46)).trim();
}
int indexOf47 = str2.indexOf("nextChapterTag*");
if (indexOf47 != -1) {
this.nextChapterTag = str2.substring(indexOf47 + 15, str2.indexOf("\n", indexOf47)).trim();
}
int indexOf48 = str2.indexOf("nextChapterEnd*");
if (indexOf48 != -1) {
this.nextChapterEnd = str2.substring(indexOf48 + 15, str2.indexOf("\n", indexOf48)).trim();
}
int indexOf49 = str2.indexOf("contentJs*");
if (indexOf49 != -1) {
this.contentJs = str2.substring(indexOf49 + 10, str2.indexOf("\n", indexOf49)).trim();
}
int indexOf50 = str2.indexOf("chapterUrlFormat*");
if (indexOf50 != -1) {
this.chapterUrlFormat = str2.substring(indexOf50 + 17, str2.indexOf("\n", indexOf50)).trim();
int indexOf51 = str2.indexOf("chapterBookIdStart*");
if (indexOf51 != -1) {
this.chapterBookIdStart = str2.substring(indexOf51 + 19, str2.indexOf("\n", indexOf51)).trim();
}
int indexOf52 = str2.indexOf("chapterBookIdEnd*");
if (indexOf52 != -1) {
this.chapterBookIdEnd = str2.substring(indexOf52 + 17, str2.indexOf("\n", indexOf52)).trim();
}
}
int indexOf53 = str2.indexOf("bookUrlFormat*");
if (indexOf53 != -1) {
this.bookUrlFormat = str2.substring(indexOf53 + 14, str2.indexOf("\n", indexOf53)).trim();
}
int indexOf54 = str2.indexOf("bestCoverTag*");
if (indexOf54 != -1) {
this.bestCoverTag = str2.substring(indexOf54 + 13, str2.indexOf("\n", indexOf54)).trim();
}
int i4 = 0;
while (true) {
int indexOf55 = str2.indexOf("chapterUrl*", i4);
if (indexOf55 == -1) {
break;
}
int indexOf56 = str2.indexOf("\n", indexOf55);
String substring = str2.substring(indexOf55 + 11, indexOf56);
if (substring.length() > 0) {
if (this.chapterUrlTags == null) {
this.chapterUrlTags = new ArrayList<>();
}
this.chapterUrlTags.add(substring.toLowerCase());
}
i4 = indexOf56;
}
this.chapterUrlBackword = str2.contains("chapterUrlBackword*true");
this.extendChapters = str2.contains("extendChapters*true");
this.resortChapters = str2.contains("resortChapters*true");
this.deleteDuplicatedChapters = !str2.contains("deleteDuplicatedChapters*false");
this.allowParkBookInfo = str2.contains("allowParkBookInfo*true");
boolean contains = str2.contains("javascriptSearch*true");
this.javascriptSearch = contains;
if (contains && (indexOf2 = str2.indexOf("searchDelay*")) != -1) {
this.searchDelay = o50.z2(str2.substring(indexOf2 + 12, str2.indexOf("\n", indexOf2)).trim());
}
boolean contains2 = str2.contains("javascriptTOC*true");
this.javascriptTOC = contains2;
if (contains2 && (indexOf = str2.indexOf("TOCDelay*")) != -1) {
this.TOCDelay = o50.z2(str2.substring(indexOf + 9, str2.indexOf("\n", indexOf)).trim());
}
boolean contains3 = str2.contains("javascriptContent*true");
this.javascriptContent = contains3;
if (contains3) {
int indexOf57 = str2.indexOf("contentDelay*");
if (indexOf57 != -1) {
this.contentDelay = o50.z2(str2.substring(indexOf57 + 13, str2.indexOf("\n", indexOf57)).trim());
}
int indexOf58 = str2.indexOf("contentTimeout*");
if (indexOf58 != -1) {
this.contentTimeout = o50.z2(str2.substring(indexOf58 + 15, str2.indexOf("\n", indexOf58)).trim());
}
}
int indexOf59 = str2.indexOf("webReadLevel*");
if (indexOf59 != -1) {
this.webReadLevel = o50.z2(str2.substring(indexOf59 + 13, str2.indexOf("\n", indexOf59)).trim());
}
this.contentPureText = str2.contains("contentPureText*true");
this.contentKeepHtml = str2.contains("contentKeepHtml*true");
int indexOf60 = str2.indexOf("//content_start");
if (indexOf60 != -1) {
int indexOf61 = str2.indexOf("\n", indexOf60) + 1;
int indexOf62 = str2.indexOf("//content_end");
this.contentTags = str2.substring(indexOf61, indexOf62).toLowerCase();
int indexOf63 = str2.indexOf("//content_start2", indexOf62);
if (indexOf63 != -1) {
int indexOf64 = str2.indexOf("\n", indexOf63) + 1;
this.contentTags2 = str2.substring(indexOf64, str2.indexOf("//content_end2", indexOf64)).toLowerCase();
}
}
int indexOf65 = str2.indexOf("//delete_start");
if (indexOf65 != -1) {
int indexOf66 = str2.indexOf("\n", indexOf65) + 1;
int indexOf67 = str2.indexOf("//delete_end");
if (indexOf67 > indexOf66 + 1) {
this.deleteContentTags = o50.C2(str2.substring(indexOf66, indexOf67));
}
this.deleteInHtml = str2.contains("deleteInHtml*true");
}
int indexOf68 = str2.indexOf("nextPageStyle*");
if (indexOf68 != -1) {
this.nextPageStyle = str2.substring(indexOf68 + 14, str2.indexOf("\n", indexOf68));
int indexOf69 = str2.indexOf("nextPageTag*");
this.nextPageTag = str2.substring(indexOf69 + 12, str2.indexOf("\n", indexOf69)).toLowerCase();
int indexOf70 = str2.indexOf("nextPageUrl*");
if (indexOf70 != -1) {
this.nextPageOriginal = str2.substring(indexOf70 + 12, str2.indexOf("\n", indexOf70));
}
}
if (!o50.F1(this.siteTag) && !o50.F1(this.name) && !o50.F1(this.url) && !o50.F1(this.searchUrl)) {
this.ok = Boolean.TRUE;
}
boolean contains4 = str2.contains("primary*true");
this.primary = contains4;
if (contains4) {
int indexOf71 = str2.indexOf("vip*");
if (indexOf71 != -1) {
this.vipChapterTag = str2.substring(indexOf71 + 4, str2.indexOf("\n", indexOf71)).trim();
}
int indexOf72 = str2.indexOf("vipNot*");
if (indexOf72 != -1) {
this.notVipChapterTag = str2.substring(indexOf72 + 7, str2.indexOf("\n", indexOf72)).trim();
}
int indexOf73 = str2.indexOf("vipStart*");
if (indexOf73 != -1) {
this.vipStartTag = str2.substring(indexOf73 + 9, str2.indexOf("\n", indexOf73)).trim();
}
if (str2.contains("disableVipPopup*true")) {
this.disableVipPopup = true;
}
}
if (this instanceof LinkSite) {
((LinkSite) this).getDefines2();
}
this.site_define = "";
} catch (Exception e) {
e50.N5("error: " + this.name + b.b + this.siteTag);
e50.S0(e);
this.ok = Boolean.FALSE;
}
}
public String getDeleteTagFile() {
String str = e50.n4() + "/." + this.siteTag + ".delete";
String str2 = e50.R1 + "/." + this.siteTag + ".delete";
if (o50.A1(str)) {
if (!o50.A1(str2)) {
o50.v(str, str2, true);
}
o50.C(str);
}
return str2;
}
public ArrayList<String> getDeleteTags() {
if (this.deleteContentTags2 == null) {
ArrayList<String> C2 = o50.C2(o50.p0(getDeleteTagFile()));
this.deleteContentTags2 = C2;
if (C2.size() == 0 && !o50.G1(this.deleteContentTags)) {
this.deleteContentTags2 = this.deleteContentTags;
} else {
int size = this.deleteContentTags2.size();
for (int size2 = this.deleteContentTags2.size() - 1; size2 >= 0; size2--) {
if (o50.F1(this.deleteContentTags2.get(size2))) {
this.deleteContentTags2.remove(size2);
}
}
if (size != this.deleteContentTags2.size()) {
o50.i2(getDeleteTagFile(), o50.B2(this.deleteContentTags2));
}
}
}
return this.deleteContentTags2;
}
public String name() {
return ok() ? this.name : "";
}
public boolean ok() {
if (this.ok == null) {
getDefines();
}
return this.ok.booleanValue();
}
public boolean primary() {
return true;
}
public void setDeleteTags(String text) {
ArrayList<String> C2 = o50.C2(text);
this.deleteContentTags2 = C2;
for (int size = C2.size() - 1; size >= 0; size--) {
if (o50.F1(this.deleteContentTags2.get(size))) {
this.deleteContentTags2.remove(size);
}
}
o50.i2(getDeleteTagFile(), o50.B2(this.deleteContentTags2));
}
public void setName(String name) {
this.name = name;
}
public void setOk(boolean ok) {
this.ok = Boolean.valueOf(ok);
}
public int version() {
if (ok()) {
return this.version;
}
return -1;
}
public BookSite(String filename, String site_define, boolean initeNow) {
String N0 = o50.N0(filename);
this.siteTag = N0;
if (N0.startsWith(".")) {
this.siteTag = this.siteTag.substring(1);
}
site_define = site_define != null ? S.clearTxt(site_define) : site_define;
this.filename = filename;
this.site_define = site_define;
if (initeNow) {
getDefines();
}
}
}
}