pull/1/head
parent
ca94a1981b
commit
24c5be4eb4
@ -0,0 +1,53 @@ |
||||
var jiemi = { |
||||
获取私钥: function (order) { |
||||
if(typeof(order)==='string' && order.length>=848){ |
||||
return order |
||||
} |
||||
var pkcs8Private; |
||||
let pkcs8Private1 = `-----BEGIN PRIVATE KEY-----
|
||||
MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAK5WtrOWxP8FHYRu |
||||
t+qp2kz0JNfv47nj+EH9R/Ft7E7WeCUC/AcXcjrHQV0JqyAUQRec/7tBZZhOcQff |
||||
QB1flDVAsYvz8GlQfEumWK1zmf9YlljzaJq04jPXKVfr9eAiH1lcR1CsYKMqBK9b |
||||
W2Xm42QRwSFhijmUlrbNo2Cj1RC9AgMBAAECgYEAiSGQKIcpgWcmpqroY98i5XEN |
||||
IgWB3RBikJWH53INdJ3id0p3r6RTp8Rft60JO/xyjv5hcYupPDpHUmfa6L/rtQMi |
||||
AAiak6pWPasi+rMWHkWIyAHz3Lxxn89GeX1vC2FNqp9yLdRhc1qO3CMBz4AFiJPk |
||||
H2CRqZKNPc3boSW+j4kCQQDZ4j6s98yFErvN1OfJOTAfrfsB4cZdeClt63cxJpWe |
||||
cAUMBIGCloed663tgesag7a6X8JTBE2+GupxlT4VIuZDAkEAzNZWgta+H0eN6X7T |
||||
pk1Lyt/lrAW/l36PI6ft1y7fpKoJMQVA7sbIG4vHDIFW9EabAnABQ7HH3NiVDVsk |
||||
vt48/wJBAM82OnMXKzs3aMJFA7a8G4dVV80fYh6MY6I0+GMXFd3bHQGj22NNM2a9 |
||||
t+iT0PqjXwl6fn2jLyhnwqUI0UUarq8CQFyT8v2neL5CZM1HWPksrji/ANrCrlkW |
||||
BjOjTkeXE9UkVIsnSLWiegaZIhlwy5AT6TMs1CV4UFBsQtGKhA0P/JkCQC28mkKq |
||||
uc0mONTWMSenwXHfpAzhOP3l/NxJBkVXPunaOb6kOP7JejGMjMhnRHh4nDiGQRi9 |
||||
Kfo65lNN215J10s= |
||||
-----END PRIVATE KEY-----`;
|
||||
switch (order){ |
||||
default: |
||||
pkcs8Private = pkcs8Private1; |
||||
break; |
||||
} |
||||
pkcs8Private = pkcs8Private.split('\n').slice(1,-1).join(''); |
||||
return pkcs8Private |
||||
}, |
||||
rsaDec: function (data){ |
||||
order = false; |
||||
if(/data|list|msg|code|{|}/.test(data)){ |
||||
return data |
||||
} |
||||
let pkcs8Private = 获取私钥(order); |
||||
try { |
||||
let decodedData = rsaDecrypt(data, pkcs8Private, { |
||||
config: "RSA/ECB/PKCS1Padding", |
||||
type: 1, |
||||
long: 2 |
||||
}); |
||||
if(!decodedData){ |
||||
log('通讯解密不正确:',decodedData); |
||||
} |
||||
return decodedData||data |
||||
} |
||||
catch (e) { |
||||
log('通讯解密失败:'+e.message); |
||||
return data |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,22 @@ |
||||
<!doctype html> |
||||
<html> |
||||
<head> |
||||
<title>解析</title> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
||||
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE10" /> |
||||
<meta name="renderer" content="webkit|ie-comp|ie-stand"> |
||||
<meta name="viewport" content="width=device-width"> |
||||
</head> |
||||
<body> |
||||
<script> |
||||
var apiArray=["https://jx.m3u8.tv/jiexi/?url=","https://jx.parwix.com:4433/player/?url=","https://www.1717yun.com/api/?url="]; |
||||
var origin=document.location.href.split("url=")[1]; |
||||
var iframeHtml=""; |
||||
for(var i=0;i<apiArray.length;i++){ |
||||
var URL=apiArray[i]+origin; |
||||
iframeHtml=iframeHtml+"<iframe sandbox='allow-scripts allow-same-origin allow-forms' frameborder='0' allowfullscreen='true' webkitallowfullscreen='true' mozallowfullscreen='true' src="+URL+"></iframe>"; |
||||
} |
||||
document.write(iframeHtml); |
||||
</script> |
||||
</body> |
||||
</html> |
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,25 @@ |
||||
var newVersion = { |
||||
"srcDyTmpl":5.4, |
||||
"SrcJuying":1.9, |
||||
"SrcJuyingdesc":{ |
||||
"0.1":"原始搜狗改造", |
||||
"0.2":"主页界面完成", |
||||
"0.3":"搜索界面完成", |
||||
"0.4":"管理界面完成", |
||||
"0.5":"各界面联动修复bug,功能增加完善", |
||||
"0.6":"搜索结果显示优化,清除无效显示;管理-扩展中心支持记录订阅历史和切换更新;管理接口和解析增加清空操作", |
||||
"0.7":"管理接口和解析支持聚影资源码增量导入;支持自定义设置默认搜索线程数;支持自定义设置app解析保留数", |
||||
"0.8":"管理-接口支持分组保存;搜索界面支持按分组进行搜索", |
||||
"0.9":"管理-订阅切换删除逻辑加强;依赖自动更新间隔改为3小时;自动订阅更新间隔改为3小时;ua转换改为在搜索界面执行", |
||||
"1.0":"管理-批量增加接口、解析时分隔符支持中英文逗号;其他资源导入时处理注释部份;增加TVb资源导入", |
||||
"1.1":"修复版本号和分隔符提示", |
||||
"1.2":"搜索界面增加快速删除;完善搜索异常错误的处理逻辑;测试记忆", |
||||
"1.3":"管理界面-操作增加筛选定位功能", |
||||
"1.4":"管理界面-定位搜索修复;其他资源导入解析未过虑问题修复;其他小问题修复", |
||||
"1.5":"搜索接口增强兼容很多;主页底稿数据修复异常;其他资源导入提示解析是否导入", |
||||
"1.6":"搜索接口显示类型和分组;增加优看明码直解支持;增加301跳转解析支持;重构解析逻辑,加强日志显示;cache增加超时;管理-解析增加排除片源手工操作", |
||||
"1.7":"管理解析测试改用断插常规调用方式;修复优看选集错误;去除dd的的默认ua;增强片源标识取值准确性;管理扩展中的资源码更新和删除逻辑完善", |
||||
"1.8":"解析逻辑升级,自动探测跳过防盗和跳舞小视频;解析增强日志显示;修复多处小bug", |
||||
"1.9":"探测失效优化完善;解析增强日志显示;cms改为优先videolist列表;屏蔽优先改为app类的直接全局,私有的只排除单个片源;解析增加优先片源设置" |
||||
} |
||||
}; |
@ -0,0 +1,17 @@ |
||||
function verification(imgurl,headers) { |
||||
const File = java.io.File; |
||||
let javaImport = new JavaImporter(); |
||||
javaImport.importPackage( |
||||
Packages.com.example.hikerview.utils |
||||
); |
||||
var bsimg = ""; |
||||
with(javaImport) { |
||||
let png = "hiker://files/cache/SrcVerify.png"; |
||||
downloadFile(imgurl, png, JSON.parse(headers)); |
||||
let path = getPath(png).replace("file://", ""); |
||||
bsimg = _base64.encodeToString(FileUtil.fileToBytes(path), _base64.NO_WRAP); |
||||
new File(path).delete(); |
||||
} |
||||
evalPrivateJS("aHTJW8GUqk24nqdf1KutpXLSQxxUqCopcaSjWa/1BqbspogsD9sqzzRKQ0/eY1cbHWXKqK/7SmE36413GhDw1/LB4qZbC87N46M3cbGebQKVsuA+wqokqyn1sWZEySrRyJHtbzpZgnEP0XYECOKzPs0qEDbm2B+3gV+JGJA37bwIqwzm/veCOIIpZgmIiRR++Nd7tnLMDBM+/vxyS+MXfE2IYkez6NE1hioj8TQ9X7UxWHZGX1PS2hc8lotTz+2qqC3Kwy5Jx6cr8zh4grgoykYsrWLjm4wLbAoSHl3Oe6QNNx+Tloen/mKR5K8c2B7xsnPja73djQkKloPGX+pCQHx8DJHZqptu2ObISfk3jBqUk2o06nxPvcT1geVKM4Sz") |
||||
return ocr(bsimg,config.依赖); |
||||
} |
@ -0,0 +1,122 @@ |
||||
/** |
||||
* 本地网页插件链接 hiker://files/rules/js/UrlProcessor.js
|
||||
* 子页面链接 hiker://page/url-processor
|
||||
* 道长仓库链接 http://hiker.nokia.press/hikerule/rulelist.json?id=2849
|
||||
* 码云 Gitee 链接 https://gitee.com/reborn0/HikerRules/raw/master/plugins/UrlProcessor.js
|
||||
*/ |
||||
function UrlProcessor() { |
||||
this.params = {} |
||||
this.regexMap = [ |
||||
{ |
||||
reg: 'vodtype\\/(\\d+)', |
||||
exec: () => { |
||||
return this.params.url |
||||
.replace(/vodtype(\/\d+)\.html/, 'vodshow$1-----------.html') |
||||
.replace(/\d*(---\d*(\.html|\/))/, this.params.page + '$1') |
||||
} |
||||
}, |
||||
{ |
||||
reg: 'type\\/\\w+', |
||||
exec: () => { |
||||
return this.params.url |
||||
.replace(/type(\/\w+)\//, 'show$1-----------/') |
||||
.replace(/\d*(---\d*(\.html|\/))/, this.params.page + '$1') |
||||
} |
||||
}, |
||||
{ |
||||
reg: '(vodtype|videot)\\/\\w+', |
||||
exec: () => { |
||||
return this.params.url |
||||
.replace(/-\d+\.html/, '-' + this.params.page + '.html') |
||||
.replace(/((vodtype|videot)\/\w+)\.html/, '$1-' + this.params.page + '.html') |
||||
} |
||||
}, |
||||
{ |
||||
reg: '\\/?[\\w\\d]+-.*?-.*?-.*?-.*?-.*?-.*?-.*?-\\d*---\\d*(\\.html|\\/)', |
||||
exec: () => { |
||||
return this.params.url |
||||
.replace(/\d*(---\d*(\.html|\/))/, this.params.page + '$1') // 拼接页码
|
||||
} |
||||
}, |
||||
{ |
||||
reg: '((\\/vod\\/show)?(\\/area\\/[\\w\\d%]+)?(\\/by\\/[\\w\\d%]+)?(\\/id\\/\\d+)?(\\/letter\\/[\\w\\d%]+)?)(\\/page\\/\\d+)?(\\/year\\/\\d+)?\\.html', |
||||
exec: () => { |
||||
let regExp = /((\/vod\/show)?(\/area\/[\w\d%]+)?(\/by\/[\w\d%]+)?(\/id\/\d+)?(\/letter\/[\w\d%]+)?)(\/page\/\d+)?(\/year\/\d+)?\.html/ |
||||
return this.params.url |
||||
.replace(regExp, '$1' + ("/page/" + this.params.page) + '$8' + ".html") |
||||
} |
||||
} |
||||
] |
||||
} |
||||
|
||||
Object.assign(UrlProcessor.prototype, { |
||||
constructor: UrlProcessor, |
||||
checkParams() { |
||||
if (!this.params.url) { |
||||
throw new Error("请先调用 .baseUrl(url) 传入链接进行初始化!") |
||||
} |
||||
if (!this.params.page) { |
||||
throw new Error("请先调用 .page(page) 传入页码进行初始化!") |
||||
} |
||||
}, |
||||
baseUrl(url){ |
||||
this.params.url = url |
||||
return this |
||||
}, |
||||
page(page){ |
||||
this.params.page = page |
||||
return this |
||||
}, |
||||
addExtra(regExp) { |
||||
if (regExp.constructor === Array) { |
||||
this.regexMap = this.regexMap.concat(regExp) |
||||
} else { |
||||
this.regexMap.push(regExp) |
||||
} |
||||
return this; |
||||
}, |
||||
debug() { |
||||
this.params.debug = true |
||||
return this; |
||||
}, |
||||
exec() { |
||||
this.checkParams() |
||||
let true_url = '' |
||||
for (let i = 0; i < this.regexMap.length; i++) { |
||||
let regObj = this.regexMap[i]; |
||||
let urlExp = regObj.reg; |
||||
if (typeof urlExp === 'string') { |
||||
urlExp = new RegExp(urlExp) |
||||
} |
||||
if (urlExp.test(this.params.url)) { |
||||
if (this.params.debug) { |
||||
log(urlExp.toString()) |
||||
} |
||||
true_url = regObj.exec(); |
||||
break; |
||||
} |
||||
} |
||||
if (true_url) { |
||||
return true_url; |
||||
} else { |
||||
return this.params.url |
||||
} |
||||
}, |
||||
获取处理结果() { |
||||
return this.exec() |
||||
}, |
||||
链接(url) { |
||||
return this.baseUrl(url) |
||||
}, |
||||
页码(page) { |
||||
return this.page(page) |
||||
}, |
||||
插入新处理规则(regExp) { |
||||
return this.addExtra(regExp) |
||||
}, |
||||
调试模式() { |
||||
return this.debug(); |
||||
} |
||||
}) |
||||
$.exports=new UrlProcessor() |
||||
$.exports |
@ -0,0 +1,495 @@ |
||||
/** |
||||
* 本地网页插件链接 hiker://files/rules/js/categories-header.js
|
||||
* 子页面链接 hiker://page/categories-header
|
||||
* 道长仓库链接 http://hiker.nokia.press/hikerule/rulelist.json?id=2705
|
||||
* 码云 Gitee 链接 https://gitee.com/reborn0/HikerRules/raw/master/plugins/categories-header.js
|
||||
*/ |
||||
/** |
||||
* Object.assign 用法参考链接 |
||||
* |
||||
* 1.https://www.daimajiaoliu.com/daima/47139a9e7100407
|
||||
* 2.https://segmentfault.com/a/1190000011778875
|
||||
* 3.https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
||||
*/ |
||||
// 利用 Symbol 实现私有变量和私有方法,外界不可访问(参考链接2)
|
||||
const symbolMap = { |
||||
// checkParams: Symbol('checkParams'),
|
||||
mLayout: Symbol('mLayout'), |
||||
true_url: Symbol('true_url'), |
||||
mPage: Symbol('mPage'), |
||||
src: Symbol('src'), |
||||
ruleObjList: Symbol('ruleObjList'), |
||||
mFold: Symbol('mFold'), |
||||
mFoldInnerEnable: Symbol('mFoldInnerEnable'), |
||||
mFoldIndex: Symbol('mFoldIndex'), |
||||
mFoldLayout: Symbol('mFoldLayout'), |
||||
mColor: Symbol('mColor'), |
||||
mTag: Symbol('mTag'), |
||||
} |
||||
|
||||
function CategoriesHeader(color) { |
||||
// 'use strict';
|
||||
// ...
|
||||
// this[symbolMap.listRule] = []
|
||||
// this[symbolMap.subListRule] = []
|
||||
this[symbolMap.mColor] = color || "#FA7298"; |
||||
this[symbolMap.ruleObjList] = [] |
||||
this.VARMAP = { |
||||
CATEGORY: "header.category", |
||||
URL: "header.url", |
||||
FOLD: "header.fold", |
||||
} |
||||
this[symbolMap.mFoldLayout] = { |
||||
injectIndex: 1 |
||||
} |
||||
this[symbolMap.mFoldIndex] = 1 |
||||
} |
||||
|
||||
Object.assign(CategoriesHeader.prototype, { |
||||
// Override 构造方法,相当于 function.prototype.constructor = (...) => {...},new function() 的时候会自动执行
|
||||
constructor: CategoriesHeader, |
||||
// 定义私有方法
|
||||
VERSION: 202112011900, |
||||
checkParams() { |
||||
if (!this[symbolMap.mLayout]) { |
||||
throw new Error("请调用 layout(d) 传入当前界面") |
||||
} |
||||
if (!(this[symbolMap.src] || this[symbolMap.true_url])) { |
||||
throw new Error("请调用 trueUrl(url) 传入当前分类的链接或调用 html(mHtml) 传入当前分类页面的源码") |
||||
} |
||||
if (!this[symbolMap.mPage]) { |
||||
throw new Error("请调用 page(mPage) 传入当前页数") |
||||
} |
||||
if (this[symbolMap.ruleObjList].length < 1) { |
||||
throw new Error("请调用相关方法传入定位规则") |
||||
} |
||||
if (!this[symbolMap.mFold]) { |
||||
this[symbolMap.mFold] = '0' |
||||
} |
||||
}, |
||||
layout(mLayout) { |
||||
this[symbolMap.mLayout] = mLayout |
||||
return this |
||||
}, |
||||
trueUrl(url) { |
||||
this[symbolMap.true_url] = url |
||||
return this |
||||
}, |
||||
page(mPage) { |
||||
if (typeof (mPage) === 'string') { |
||||
mPage = parseInt(mPage) |
||||
} |
||||
this[symbolMap.mPage] = mPage |
||||
return this |
||||
}, |
||||
html(mSrc) { |
||||
this[symbolMap.src] = mSrc |
||||
return this |
||||
}, |
||||
list(rule) { |
||||
if (this[symbolMap.ruleObjList].length > 0) { |
||||
throw new Error("list(rule) add(ruleObj) 只能二选一!") |
||||
} |
||||
this[symbolMap.ruleObjList] = [{}] |
||||
this[symbolMap.ruleObjList][0].listRule = rule |
||||
this[symbolMap.ruleObjList][0]['一级分类'] = rule |
||||
return this |
||||
}, |
||||
subList(rule) { |
||||
if (this[symbolMap.ruleObjList].length > 1) { |
||||
throw new Error("subList(rule) add(ruleObj) 只能二选一!") |
||||
} |
||||
if (!this[symbolMap.ruleObjList][0] || (!this[symbolMap.ruleObjList][0].listRule && !this[symbolMap.ruleObjList][0]['一级分类'])) { |
||||
throw new Error("请先调用 list(rule) 或 一级分类(rule) 定位一级分类") |
||||
} |
||||
this[symbolMap.ruleObjList][0].subListRule = rule |
||||
this[symbolMap.ruleObjList][0]['子分类'] = rule |
||||
return this |
||||
}, |
||||
title(rule) { |
||||
if (this[symbolMap.ruleObjList].length > 1) { |
||||
throw new Error("title(rule) add(ruleObj) 只能二选一!") |
||||
} |
||||
if (!this[symbolMap.ruleObjList][0] || (!this[symbolMap.ruleObjList][0].listRule && !this[symbolMap.ruleObjList][0]['一级分类'])) { |
||||
throw new Error("请先调用 list(rule) 或 一级分类(rule) 定位一级分类") |
||||
} |
||||
this[symbolMap.ruleObjList][0].titleRule = rule |
||||
this[symbolMap.ruleObjList][0]['分类标题'] = this[symbolMap.ruleObjList][0].titleRule |
||||
return this |
||||
}, |
||||
url(rule) { |
||||
if (this[symbolMap.ruleObjList].length > 1) { |
||||
throw new Error("url(rule) add(ruleObj) 只能二选一!") |
||||
} |
||||
if (!this[symbolMap.ruleObjList][0] || (!this[symbolMap.ruleObjList][0].listRule && !this[symbolMap.ruleObjList][0]['一级分类'])) { |
||||
throw new Error("请先调用 list(rule) 或 一级分类(rule) 定位一级分类") |
||||
} |
||||
this[symbolMap.ruleObjList][0].urlRule = rule |
||||
this[symbolMap.ruleObjList][0]['分类链接'] = this[symbolMap.ruleObjList][0].urlRule |
||||
return this |
||||
}, |
||||
/** |
||||
* 是否开启折叠功能 |
||||
* |
||||
* @param enabled true 表示开启,false 表示禁用 |
||||
* @returns {CategoriesHeader} |
||||
*/ |
||||
foldInner(enabled) { |
||||
if (!(typeof (enabled) === 'boolean')) { |
||||
throw new Error("请传入 true 或 false 表示开启或关闭折叠功能!") |
||||
} |
||||
this[symbolMap.mFoldInnerEnable] = enabled |
||||
return this |
||||
}, |
||||
/** |
||||
* 从第 index 行开始折叠 |
||||
* |
||||
* @param index 开始折叠的行数 |
||||
* @returns {CategoriesHeader} |
||||
*/ |
||||
foldIndex(index) { |
||||
if (!(typeof (index) === 'number')) { |
||||
throw new Error("开始折叠行请传入数字!") |
||||
} |
||||
if (index < 1) { |
||||
throw new Error("开始折叠行请传入大于 0 的整数!") |
||||
} |
||||
this[symbolMap.mFoldIndex] = index || 1; |
||||
return this |
||||
}, |
||||
/** |
||||
* 折叠按钮的界面 |
||||
* |
||||
* @param layout 与 d.push 结构一致, |
||||
* 例:{ title:"标题1", url:"xxx", col_type:"scroll_button" }; |
||||
* 参数采用可选覆盖模式,不写的参数则使用默认; |
||||
* 比如传入 { col_type:"text_1" },那最终结果就是 { title:"标题1", url:"xxx", col_type:"text_1" } |
||||
* @returns {CategoriesHeader} |
||||
*/ |
||||
foldLayout(layout) { |
||||
if (typeof layout === 'object') { |
||||
let keys = Object.keys(layout) |
||||
let injectIndex = layout.injectIndex || layout['折叠按钮插入行'] |
||||
if (layout.title || layout.url || layout.col_type || injectIndex) { |
||||
for (let i = 0; i < keys.length; i++) { |
||||
const key = keys[i] |
||||
this[symbolMap.mFoldLayout][key] = layout[key]; |
||||
} |
||||
} else { |
||||
throw new Error("请传入正确的折叠界面元素!") |
||||
} |
||||
// injectIndex 折叠按钮插入第 injectIndex 行
|
||||
if (injectIndex) { |
||||
if (!(typeof (injectIndex) === 'number')) { |
||||
throw new Error("折叠按钮插入行请传入数字!") |
||||
} |
||||
if (injectIndex < 1) { |
||||
throw new Error("折叠按钮插入行请传入大于 0 的整数!") |
||||
} |
||||
if (injectIndex > this[symbolMap.mFoldIndex]) { |
||||
throw new Error("折叠按钮插入行不得大于显示折叠行数!请调用 .foldIndex(index) 或 .第几行开始折叠(index) 传入正确的显示折叠行数") |
||||
} |
||||
this[symbolMap.mFoldLayout].injectIndex = injectIndex || 1; |
||||
} |
||||
} else { |
||||
throw new Error("请传入正确的折叠界面元素!") |
||||
} |
||||
return this; |
||||
}, |
||||
// 当前是否折叠
|
||||
fold(isFold) { |
||||
if (typeof (isFold) === 'string') { |
||||
isFold = isFold === '1' |
||||
} |
||||
if (isFold) { |
||||
this[symbolMap.mFold] = '1'; |
||||
} else { |
||||
this[symbolMap.mFold] = '0'; |
||||
} |
||||
return this |
||||
}, |
||||
color(mColor) { |
||||
this[symbolMap.mColor] = mColor |
||||
return this |
||||
}, |
||||
tag(mTag) { |
||||
this[symbolMap.mTag] = mTag |
||||
return this |
||||
}, |
||||
add(ruleObj) { |
||||
// log($.stringify(ruleObj))
|
||||
if (ruleObj.constructor === Array) { |
||||
this[symbolMap.ruleObjList] = this[symbolMap.ruleObjList].concat(ruleObj) |
||||
} else { |
||||
this[symbolMap.ruleObjList].push(ruleObj) |
||||
} |
||||
return this; |
||||
}, |
||||
evalJSRule(item, jsRule) { |
||||
let rule = jsRule.replace("@js:", "") |
||||
rule = rule.trim() |
||||
// log($.stringify(rule))
|
||||
let input = item |
||||
if (rule.startsWith("(")) { |
||||
eval('result = ' + rule) |
||||
} else { |
||||
/** |
||||
* 还原成 $.toString(...) 的最终结果,达到最终处理方式跟上面的 if 一致的目的 |
||||
*/ |
||||
eval('result = ' + '(() => {' + rule + '})()') |
||||
} |
||||
return (result || '') |
||||
}, |
||||
getTitle(src, category) { |
||||
let title = '' |
||||
let titleRule = category.titleRule || 'a&&Text' |
||||
if (titleRule.startsWith("@js:")) { |
||||
title = this.evalJSRule(src, titleRule) |
||||
} else { |
||||
title = parseDomForHtml(src, titleRule) |
||||
} |
||||
return title.trim() || ""; |
||||
}, |
||||
getUrl(src, category) { |
||||
let url = '' |
||||
let urlRule = category.urlRule || 'a&&href' |
||||
if (typeof urlRule === 'object') { |
||||
let mUrlRule = urlRule.rule || urlRule['解析规则'] || 'a&&href'; |
||||
if (mUrlRule.startsWith("@js:")) { |
||||
url = this.evalJSRule(src, mUrlRule); |
||||
} else { |
||||
let parse = parseDom; |
||||
if (urlRule.parseOption) { |
||||
switch (urlRule.parseOption) { |
||||
case "parseDom": |
||||
case "pd": |
||||
parse = parseDom; |
||||
break; |
||||
case "parseDomForHtml": |
||||
case "pdfh": |
||||
parse = parseDomForHtml; |
||||
break; |
||||
default: |
||||
parse = parseDom; |
||||
} |
||||
} else if (urlRule["解析方法"]) { |
||||
switch (urlRule["解析方法"]) { |
||||
case "parseDom": |
||||
case "pd": |
||||
parse = parseDom; |
||||
break; |
||||
case "parseDomForHtml": |
||||
case "pdfh": |
||||
parse = parseDomForHtml; |
||||
break; |
||||
default: |
||||
parse = parseDom; |
||||
} |
||||
} |
||||
url = parse(src, mUrlRule); |
||||
} |
||||
if (urlRule.dealUrl) { |
||||
url = urlRule.dealUrl(url) |
||||
} else if (urlRule['二次处理']) { |
||||
url = urlRule['二次处理'](url) |
||||
} |
||||
} else { |
||||
if (urlRule.startsWith("@js:")) { |
||||
url = this.evalJSRule(src, urlRule); |
||||
} else { |
||||
url = parseDom(src, urlRule); |
||||
} |
||||
} |
||||
return url || ""; |
||||
}, |
||||
build() { |
||||
// 检测是否传入需要的参数
|
||||
this.checkParams() |
||||
// 每一个分类的唯一标识
|
||||
let mTag = this[symbolMap.mTag] || "" |
||||
//翻页 需要根据实际替换
|
||||
const html = this[symbolMap.src] || request(this[symbolMap.true_url]) |
||||
const empty = "hiker://empty" |
||||
//获取列表
|
||||
const categories = [] |
||||
this[symbolMap.ruleObjList].map(ruleObj => { |
||||
let list = [] |
||||
let listRule = ruleObj.listRule || ruleObj["一级分类"] |
||||
if (listRule.startsWith("@js:")) { |
||||
// log($.stringify(listRule))
|
||||
list = this.evalJSRule(html, listRule) |
||||
} else { |
||||
list = parseDomForArray(html, listRule) |
||||
} |
||||
// log(list)
|
||||
list.map(category => { |
||||
categories.push({ |
||||
list: category, |
||||
subListRule: ruleObj.subListRule || ruleObj["子分类"], |
||||
titleRule: ruleObj.titleRule || ruleObj["分类标题"], |
||||
urlRule: ruleObj.urlRule || ruleObj["分类链接"], |
||||
}); |
||||
}) |
||||
}) |
||||
|
||||
// log($.stringify(categories))
|
||||
|
||||
let init_cate = [] |
||||
for (let i = 0; i < 20; i++) { |
||||
init_cate.push("0") |
||||
} |
||||
|
||||
const cate_temp_json = getMyVar(mTag + this.VARMAP.CATEGORY, JSON.stringify(init_cate)) |
||||
const cate_temp = JSON.parse(cate_temp_json) |
||||
|
||||
if (this[symbolMap.mPage] === 1) { |
||||
|
||||
categories.forEach((category, index) => { |
||||
|
||||
// 折叠 UI
|
||||
if (this[symbolMap.mFoldInnerEnable] && this[symbolMap.mFoldLayout].injectIndex === (index+1)) { |
||||
let foldLayout = { |
||||
title: this[symbolMap.mFoldLayout].title || (this[symbolMap.mFold] === '1' ? '““””<b><span style="color: #FF0000">∨</span></b>' : '““””<b><span style="color: #1aad19">∧</span></b>'), |
||||
url: this[symbolMap.mFoldLayout].url || $("hiker://empty#noHistory#").lazyRule((params) => { |
||||
putMyVar(params.mTag + params.VARMAP.FOLD, getMyVar(params.mTag + params.VARMAP.FOLD, params.isFold) === '1' ? '0' : '1') |
||||
refreshPage(false); |
||||
return "hiker://empty" |
||||
}, { |
||||
mTag: mTag, |
||||
isFold: this[symbolMap.mFold], |
||||
VARMAP: this.VARMAP |
||||
}), |
||||
col_type: this[symbolMap.mFoldLayout].col_type || "scroll_button", |
||||
} |
||||
this[symbolMap.mLayout].push(foldLayout) |
||||
} |
||||
|
||||
//具体列表下的分类
|
||||
let sub_categories = []; |
||||
if (category.subListRule.startsWith("@js:")) { |
||||
sub_categories = this.evalJSRule(category.list, category.subListRule) |
||||
} else { |
||||
sub_categories = parseDomForArray(category.list, category.subListRule); |
||||
} |
||||
if (index < (this[symbolMap.mFoldIndex] || 1)) { |
||||
sub_categories.forEach((item, key) => { |
||||
let title = this.getTitle(item, category) |
||||
let url = this.getUrl(item, category) |
||||
|
||||
this[symbolMap.mLayout].push({ |
||||
title: key.toString() === cate_temp[index] ? '““””<b><font color=' + this[symbolMap.mColor] + '>' + title + ' </font></b>' : title, |
||||
url: $(url).lazyRule((params) => { |
||||
let new_cate = [] |
||||
if (params.index === 0) { |
||||
params.cate_temp.forEach((cate, index) => { |
||||
new_cate.push(index === 0 ? params.key.toString() : "0") |
||||
}); |
||||
} else { |
||||
params.cate_temp[params.index] = params.key.toString() |
||||
} |
||||
putMyVar(params.tag + params.VARMAP.CATEGORY, JSON.stringify(params.index === 0 ? new_cate : params.cate_temp)) |
||||
putMyVar(params.tag + params.VARMAP.URL, input) |
||||
refreshPage(true) |
||||
return "hiker://empty" |
||||
}, { |
||||
cate_temp: cate_temp, |
||||
index: index, |
||||
VARMAP: this.VARMAP, |
||||
tag: mTag, |
||||
key: key, |
||||
page: this[symbolMap.mPage], |
||||
}), |
||||
col_type: 'scroll_button', |
||||
}) |
||||
}) |
||||
this[symbolMap.mLayout].push({ |
||||
col_type: "blank_block" |
||||
}); |
||||
} else if (this[symbolMap.mFold] === '0') { |
||||
sub_categories.forEach((item, key) => { |
||||
let title = this.getTitle(item, category) |
||||
let url = this.getUrl(item, category) |
||||
|
||||
this[symbolMap.mLayout].push({ |
||||
title: key.toString() === cate_temp[index] ? '““””<b><font color=' + this[symbolMap.mColor] + '>' + title + ' </font></b>' : title, |
||||
url: $(url).lazyRule((params) => { |
||||
params.cate_temp[params.index] = params.key.toString() |
||||
|
||||
putMyVar(params.tag + params.VARMAP.CATEGORY, JSON.stringify(params.cate_temp)) |
||||
putMyVar(params.tag + params.VARMAP.URL, input) |
||||
refreshPage(true) |
||||
return "hiker://empty" |
||||
}, { |
||||
cate_temp: cate_temp, |
||||
index: index, |
||||
VARMAP: this.VARMAP, |
||||
tag: mTag, |
||||
key: key, |
||||
page: this[symbolMap.mPage], |
||||
}), |
||||
col_type: 'scroll_button', |
||||
}) |
||||
}) |
||||
this[symbolMap.mLayout].push({ |
||||
col_type: "blank_block" |
||||
}); |
||||
} |
||||
}); |
||||
} |
||||
}, |
||||
|
||||
界面(layout) { |
||||
return this.layout(layout) |
||||
}, |
||||
分类链接(trueUrl) { |
||||
return this.trueUrl(trueUrl); |
||||
}, |
||||
页码(page) { |
||||
return this.page(page); |
||||
}, |
||||
源码(html) { |
||||
return this.html(html); |
||||
}, |
||||
定位一级分类(list) { |
||||
return this.list(list); |
||||
}, |
||||
定位子分类(subList) { |
||||
return this.subList(subList); |
||||
}, |
||||
定位分类标题(title) { |
||||
return this.title(title); |
||||
}, |
||||
定位分类链接(url) { |
||||
return this.url(url); |
||||
}, |
||||
开启内置折叠功能() { |
||||
return this.foldInner(true); |
||||
}, |
||||
关闭内置折叠功能() { |
||||
return this.foldInner(false); |
||||
}, |
||||
第几行开始折叠(index) { |
||||
return this.foldIndex(index); |
||||
}, |
||||
折叠按钮样式(layout) { |
||||
return this.foldLayout(layout) |
||||
}, |
||||
折叠(fold) { |
||||
return this.fold(fold); |
||||
}, |
||||
选中的分类颜色(color) { |
||||
return this.color(color); |
||||
}, |
||||
唯一标识(mTag) { |
||||
return this.tag(mTag) |
||||
}, |
||||
添加分类定位(ruleObj) { |
||||
return this.add(ruleObj); |
||||
}, |
||||
开始打造分类() { |
||||
return this.build(); |
||||
}, |
||||
|
||||
}) |
||||
$.exports = new CategoriesHeader(); |
||||
$.exports |
File diff suppressed because it is too large
Load Diff
@ -0,0 +1 @@ |
||||
var configvar = {}; |
Loading…
Reference in new issue