js1增加本地代理接口proxy函数
This commit is contained in:
parent
cbcfb67c44
commit
c5b3638a83
@ -1 +1 @@
|
|||||||
3.9.46beta11
|
3.9.46beta12
|
||||||
59
libs/drpy.js
59
libs/drpy.js
@ -55,7 +55,7 @@ function pre(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
let rule = {};
|
let rule = {};
|
||||||
const VERSION = 'drpy1 3.9.43beta1 20230607';
|
const VERSION = 'drpy1 3.9.46beta12 20230709';
|
||||||
/** 已知问题记录
|
/** 已知问题记录
|
||||||
* 1.影魔的jinjia2引擎不支持 {{fl}}对象直接渲染 (有能力解决的话尽量解决下,支持对象直接渲染字符串转义,如果加了|safe就不转义)[影魔牛逼,最新的文件发现这问题已经解决了]
|
* 1.影魔的jinjia2引擎不支持 {{fl}}对象直接渲染 (有能力解决的话尽量解决下,支持对象直接渲染字符串转义,如果加了|safe就不转义)[影魔牛逼,最新的文件发现这问题已经解决了]
|
||||||
* Array.prototype.append = Array.prototype.push; 这种js执行后有毛病,for in 循环列表会把属性给打印出来 (这个大毛病需要重点排除一下)
|
* Array.prototype.append = Array.prototype.push; 这种js执行后有毛病,for in 循环列表会把属性给打印出来 (这个大毛病需要重点排除一下)
|
||||||
@ -432,6 +432,18 @@ function getCryptoJS(){
|
|||||||
return 'console.log("CryptoJS已装载");'
|
return 'console.log("CryptoJS已装载");'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取壳子返回的代理地址
|
||||||
|
* @returns {string|*}
|
||||||
|
*/
|
||||||
|
function getProxyUrl(){
|
||||||
|
if(typeof(getProxy)==='function'){
|
||||||
|
return getProxy()
|
||||||
|
}else{
|
||||||
|
return 'http://127.0.0.1:9978/proxy?do=js'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 强制正序算法
|
* 强制正序算法
|
||||||
* @param lists 待正序列表
|
* @param lists 待正序列表
|
||||||
@ -2105,6 +2117,29 @@ function playParse(playObj){
|
|||||||
return JSON.stringify(lazy_play);
|
return JSON.stringify(lazy_play);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本地代理解析规则
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
function proxyParse(proxyObj){
|
||||||
|
var input = proxyObj.params;
|
||||||
|
if(proxyObj.proxy_rule){
|
||||||
|
try {
|
||||||
|
eval(proxyObj.proxy_rule);
|
||||||
|
if(input && input!== proxyObj.params && Array.isArray(input)){
|
||||||
|
return input
|
||||||
|
}else{
|
||||||
|
return [404,'text/plain','Not Found']
|
||||||
|
}
|
||||||
|
}catch (e) {
|
||||||
|
return [500,'text/plain','代理规则错误:'+e.message]
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
return [404,'text/plain','Not Found']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* js源预处理特定返回对象中的函数
|
* js源预处理特定返回对象中的函数
|
||||||
* @param ext
|
* @param ext
|
||||||
@ -2179,6 +2214,7 @@ function playParse(playObj){
|
|||||||
rule.图片来源 = rule.图片来源||'';
|
rule.图片来源 = rule.图片来源||'';
|
||||||
rule.play_json = rule.hasOwnProperty('play_json')?rule.play_json:[];
|
rule.play_json = rule.hasOwnProperty('play_json')?rule.play_json:[];
|
||||||
rule.pagecount = rule.hasOwnProperty('pagecount')?rule.pagecount:{};
|
rule.pagecount = rule.hasOwnProperty('pagecount')?rule.pagecount:{};
|
||||||
|
rule.proxy_rule = rule.hasOwnProperty('proxy_rule')?rule.proxy_rule:'';
|
||||||
if(rule.headers && typeof(rule.headers) === 'object'){
|
if(rule.headers && typeof(rule.headers) === 'object'){
|
||||||
try {
|
try {
|
||||||
let header_keys = Object.keys(rule.headers);
|
let header_keys = Object.keys(rule.headers);
|
||||||
@ -2342,6 +2378,25 @@ function search(wd, quick) {
|
|||||||
return searchParse(searchObj)
|
return searchParse(searchObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* js源本地代理返回的数据列表特定返回对象中的函数
|
||||||
|
* @param params 代理链接参数比如 /proxy?do=js&url=https://wwww.baidu.com => params就是 {do:'js','url':'https://wwww.baidu.com'}
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
function proxy(params){
|
||||||
|
if(rule.proxy_rule&&rule.proxy_rule.trim()){
|
||||||
|
rule.proxy_rule = rule.proxy_rule.trim();
|
||||||
|
}
|
||||||
|
if(rule.proxy_rule.startsWith(':js')){
|
||||||
|
rule.proxy_rule = rule.proxy_rule.replace(':js','');
|
||||||
|
}
|
||||||
|
let proxyObj = {
|
||||||
|
params:params,
|
||||||
|
proxy_rule:rule.proxy_rule
|
||||||
|
};
|
||||||
|
return proxyParse(proxyObj)
|
||||||
|
}
|
||||||
|
|
||||||
function DRPY(){//导出函数
|
function DRPY(){//导出函数
|
||||||
return {
|
return {
|
||||||
init: init,
|
init: init,
|
||||||
@ -2351,6 +2406,7 @@ function DRPY(){//导出函数
|
|||||||
detail: detail,
|
detail: detail,
|
||||||
play: play,
|
play: play,
|
||||||
search: search,
|
search: search,
|
||||||
|
proxy:proxy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2363,5 +2419,6 @@ export default {
|
|||||||
detail: detail,
|
detail: detail,
|
||||||
play: play,
|
play: play,
|
||||||
search: search,
|
search: search,
|
||||||
|
proxy:proxy,
|
||||||
DRPY:DRPY
|
DRPY:DRPY
|
||||||
}
|
}
|
||||||
|
|||||||
2
libs/drpy.min.js
vendored
2
libs/drpy.min.js
vendored
File diff suppressed because one or more lines are too long
@ -41,7 +41,7 @@ function pre(){
|
|||||||
|
|
||||||
let rule = {};
|
let rule = {};
|
||||||
let vercode = typeof(pdfl) ==='function'?'drpy2.1':'drpy2';
|
let vercode = typeof(pdfl) ==='function'?'drpy2.1':'drpy2';
|
||||||
const VERSION = vercode+' 3.9.43beta1 20230607';
|
const VERSION = vercode+' 3.9.46beta12 20230709';
|
||||||
/** 已知问题记录
|
/** 已知问题记录
|
||||||
* 1.影魔的jinjia2引擎不支持 {{fl}}对象直接渲染 (有能力解决的话尽量解决下,支持对象直接渲染字符串转义,如果加了|safe就不转义)[影魔牛逼,最新的文件发现这问题已经解决了]
|
* 1.影魔的jinjia2引擎不支持 {{fl}}对象直接渲染 (有能力解决的话尽量解决下,支持对象直接渲染字符串转义,如果加了|safe就不转义)[影魔牛逼,最新的文件发现这问题已经解决了]
|
||||||
* Array.prototype.append = Array.prototype.push; 这种js执行后有毛病,for in 循环列表会把属性给打印出来 (这个大毛病需要重点排除一下)
|
* Array.prototype.append = Array.prototype.push; 这种js执行后有毛病,for in 循环列表会把属性给打印出来 (这个大毛病需要重点排除一下)
|
||||||
@ -421,6 +421,18 @@ function getCryptoJS(){
|
|||||||
return 'console.log("CryptoJS已装载");'
|
return 'console.log("CryptoJS已装载");'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取壳子返回的代理地址
|
||||||
|
* @returns {string|*}
|
||||||
|
*/
|
||||||
|
function getProxyUrl(){
|
||||||
|
if(typeof(getProxy)==='function'){
|
||||||
|
return getProxy()
|
||||||
|
}else{
|
||||||
|
return 'http://127.0.0.1:9978/proxy?do=js'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 强制正序算法
|
* 强制正序算法
|
||||||
* @param lists 待正序列表
|
* @param lists 待正序列表
|
||||||
@ -1969,6 +1981,29 @@ function playParse(playObj){
|
|||||||
return JSON.stringify(lazy_play);
|
return JSON.stringify(lazy_play);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 本地代理解析规则
|
||||||
|
* @param params
|
||||||
|
*/
|
||||||
|
function proxyParse(proxyObj){
|
||||||
|
var input = proxyObj.params;
|
||||||
|
if(proxyObj.proxy_rule){
|
||||||
|
try {
|
||||||
|
eval(proxyObj.proxy_rule);
|
||||||
|
if(input && input!== proxyObj.params && Array.isArray(input)){
|
||||||
|
return input
|
||||||
|
}else{
|
||||||
|
return [404,'text/plain','Not Found']
|
||||||
|
}
|
||||||
|
}catch (e) {
|
||||||
|
return [500,'text/plain','代理规则错误:'+e.message]
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
return [404,'text/plain','Not Found']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* js源预处理特定返回对象中的函数
|
* js源预处理特定返回对象中的函数
|
||||||
* @param ext
|
* @param ext
|
||||||
@ -2046,6 +2081,7 @@ function init(ext) {
|
|||||||
rule.图片来源 = rule.图片来源||'';
|
rule.图片来源 = rule.图片来源||'';
|
||||||
rule.play_json = rule.hasOwnProperty('play_json')?rule.play_json:[];
|
rule.play_json = rule.hasOwnProperty('play_json')?rule.play_json:[];
|
||||||
rule.pagecount = rule.hasOwnProperty('pagecount')?rule.pagecount:{};
|
rule.pagecount = rule.hasOwnProperty('pagecount')?rule.pagecount:{};
|
||||||
|
rule.proxy_rule = rule.hasOwnProperty('proxy_rule')?rule.proxy_rule:'';
|
||||||
if(rule.headers && typeof(rule.headers) === 'object'){
|
if(rule.headers && typeof(rule.headers) === 'object'){
|
||||||
try {
|
try {
|
||||||
let header_keys = Object.keys(rule.headers);
|
let header_keys = Object.keys(rule.headers);
|
||||||
@ -2222,6 +2258,25 @@ function search(wd, quick) {
|
|||||||
return searchParse(searchObj)
|
return searchParse(searchObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* js源本地代理返回的数据列表特定返回对象中的函数
|
||||||
|
* @param params 代理链接参数比如 /proxy?do=js&url=https://wwww.baidu.com => params就是 {do:'js','url':'https://wwww.baidu.com'}
|
||||||
|
* @returns {*}
|
||||||
|
*/
|
||||||
|
function proxy(params){
|
||||||
|
if(rule.proxy_rule&&rule.proxy_rule.trim()){
|
||||||
|
rule.proxy_rule = rule.proxy_rule.trim();
|
||||||
|
}
|
||||||
|
if(rule.proxy_rule.startsWith(':js')){
|
||||||
|
rule.proxy_rule = rule.proxy_rule.replace(':js','');
|
||||||
|
}
|
||||||
|
let proxyObj = {
|
||||||
|
params:params,
|
||||||
|
proxy_rule:rule.proxy_rule
|
||||||
|
};
|
||||||
|
return proxyParse(proxyObj)
|
||||||
|
}
|
||||||
|
|
||||||
function DRPY(){//导出函数
|
function DRPY(){//导出函数
|
||||||
return {
|
return {
|
||||||
init: init,
|
init: init,
|
||||||
@ -2231,6 +2286,7 @@ function DRPY(){//导出函数
|
|||||||
detail: detail,
|
detail: detail,
|
||||||
play: play,
|
play: play,
|
||||||
search: search,
|
search: search,
|
||||||
|
proxy:proxy
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2243,5 +2299,6 @@ export default {
|
|||||||
detail: detail,
|
detail: detail,
|
||||||
play: play,
|
play: play,
|
||||||
search: search,
|
search: search,
|
||||||
|
proxy:proxy,
|
||||||
DRPY:DRPY
|
DRPY:DRPY
|
||||||
}
|
}
|
||||||
2
libs/drpy2.min.js
vendored
2
libs/drpy2.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user