Add files via upload
This commit is contained in:
+33
-39
@@ -1,39 +1,33 @@
|
||||
// 道长 drpy仓库 https://gitcode.net/qq_32394351/dr_py
|
||||
// 道长 drpy安卓本地搭建说明 https://gitcode.net/qq_32394351/dr_py/-/blob/master/%E5%AE%89%E5%8D%93%E6%9C%AC%E5%9C%B0%E6%90%AD%E5%BB%BA%E8%AF%B4%E6%98%8E.md
|
||||
// 道长 drpy写源 模板规则说明 https://gitcode.net/supertlo/dr_py#%E6%A8%A1%E6%9D%BF%E8%A7%84%E5%88%99%E8%AF%B4%E6%98%8E
|
||||
// 道长 drpy写源 套模模版 https://gitcode.net/qq_32394351/dr_py/-/raw/master/js/%E6%A8%A1%E6%9D%BF.js
|
||||
// 道长 drpy写源 影片教程 http://101.34.67.237:5244/%E6%95%99%E8%82%B2/drpy
|
||||
// 道长 drpy写源 影片教程(m3u8切片) https://freedrpy.run.goorm.io/txt/jc/playlist.m3u8
|
||||
// 海阔下载 https://haikuo.lanzoui.com/u/GoldRiver
|
||||
// Pluto Player官方TG https://t.me/PlutoPlayer
|
||||
// Pluto Player官方TG https://t.me/PlutoPlayerChannel
|
||||
|
||||
|
||||
var rule = {
|
||||
title:'JRKAN直播',
|
||||
host:'http://m.jrkan2023.com/',
|
||||
// JRKAN备用域名:m.jrskan8.com / m.jrkan666.com / jryyds.com / jrsbxj.com
|
||||
// JRKAN网址发布:qiumi1314.com
|
||||
url:'/fyclass',
|
||||
searchUrl:'',
|
||||
searchable:0,
|
||||
quickSearch:0,
|
||||
class_name:'全部',
|
||||
class_url:'/',
|
||||
//class_url:'?live',
|
||||
headers:{
|
||||
'User-Agent':'MOBILE_UA'
|
||||
},
|
||||
timeout:5000,
|
||||
play_parse:true,
|
||||
lazy:'',
|
||||
limit:6,
|
||||
double:false,
|
||||
推荐:'*',
|
||||
// 一级播放线路x3 可自行切换
|
||||
//一级:'.loc_match .d-touch;li&&Text;img&&src;.lab_time&&Text;a:eq(0)&&href',//play.sportsteam365.com
|
||||
一级:'.loc_match:eq(2) ul;li:gt(1):lt(4)&&Text;img&&src;li:lt(2)&&Text;a:eq(1)&&href',//play.sportsteam333.com
|
||||
//一级:'.loc_match .d-touch;li&&Text;img&&src;.lab_time&&Text;a:eq(2)&&href',//play.sportsteam666.com
|
||||
二级:{title:'.sub_list li:lt(2)&&Text;.sub_list li:eq(0)&&Text',img:'img&&src',desc:';;;.lab_team_home&&Text;.lab_team_away&&Text',content:'.sub_list ul&&Text',tabs:'',tab_text:'',lists:'.sub_channel a',list_text:'a&&Text',list_url:'a&&data-play'},
|
||||
搜索:'',
|
||||
}
|
||||
var rule = {
|
||||
title:'JRKAN直播',
|
||||
host:'http://www.jrs80.com/?lan=1',
|
||||
// JRKAN备用域名:www.jrkankan.com / www.jrkan365.com / jrsyyds.com / www.jryyds.com / jrskan.com / jrsbxj.com /Jrkan备用域名1: www.jrkan2022.com 备用域名2: www.jrs23.com 备用域名2: www.jrskk.com 最新网址发布:www.qiumi1314.co
|
||||
|
||||
url:'/fyclass',
|
||||
searchUrl:'/x/search/?q=**',
|
||||
searchable:1,
|
||||
quickSearch:1,
|
||||
class_name:'全部',
|
||||
class_url:'/',
|
||||
//class_url:'?live',
|
||||
headers:{
|
||||
'User-Agent':'MOBILE_UA'
|
||||
},
|
||||
timeout:5000,
|
||||
play_parse:true,
|
||||
lazy:"",
|
||||
limit:6,
|
||||
double:false,
|
||||
推荐:'*',
|
||||
// 一级:'.loc_match:eq(2) ul;li:gt(1):lt(4)&&Text;img&&src;li:lt(2)&&Text;a:eq(1)&&href',//play.sportsteam333.com
|
||||
一级:"js:var items=[];pdfh=jsp.pdfh;pdfa=jsp.pdfa;pd=jsp.pd;var html=request(input);var tabs=pdfa(html,'body&&.d-touch');tabs.forEach(function(it){var pz=pdfh(it,'.name:eq(1)&&Text');var ps=pdfh(it,'.name:eq(0)&&Text');var pk=pdfh(it,'.name:eq(2)&&Text');var img=pd(it,'img&&src');var url=pd(it,'a.me&&href');var timer=pdfh(it,'.lab_time&&Text');var parts = timer.split(' ');var dateParts = parts[0].split('-');var timeParts = parts[1].split(':');var year = new Date().getFullYear();var date = new Date(year, dateParts[0] - 1, dateParts[1], timeParts[0], timeParts[1]);var now = new Date();var hundredMinutesAgo = new Date(now.getTime() - 100 * 60 * 1000);if (date > hundredMinutesAgo) {timer = timer.split(' ')[1];items.push({desc:timer+ ' '+'🏆'+ps,title:pz+' 🆚 '+pk,pic_url:img,url:url})}});setResult(items);",
|
||||
二级:{
|
||||
"title":".sub_list li:lt(2)&&Text;.sub_list li:eq(0)&&Text",
|
||||
"img":"img&&src",
|
||||
"desc":";;;.lab_team_home&&Text;.lab_team_away&&Text",
|
||||
"content":".sub_list ul&&Text",
|
||||
"tabs":"js:TABS=['实时直播']",
|
||||
"lists":"js:LISTS=[];pdfh=jsp.pdfh;pdfa=jsp.pdfa;pd=jsp.pd;let html=request(input);let data=pdfa(html,'.sub_playlist&&a');TABS.forEach(function(tab){let d=data.map(function(it){let name=pdfh(it,'strong&&Text');let url=pd(it,'a&&data-play');return name+'$'+url});LISTS.push(d)});",
|
||||
},
|
||||
搜索:'js:let d=[];setResult(d);',
|
||||
}
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -0,0 +1,6140 @@
|
||||
/*globals window, global, require*/
|
||||
|
||||
/**
|
||||
* CryptoJS core components.
|
||||
*/
|
||||
var CryptoJS = CryptoJS || (function (Math, undefined) {
|
||||
|
||||
var crypto;
|
||||
|
||||
// Native crypto from window (Browser)
|
||||
if (typeof window !== 'undefined' && window.crypto) {
|
||||
crypto = window.crypto;
|
||||
}
|
||||
|
||||
// Native (experimental IE 11) crypto from window (Browser)
|
||||
if (!crypto && typeof window !== 'undefined' && window.msCrypto) {
|
||||
crypto = window.msCrypto;
|
||||
}
|
||||
|
||||
// Native crypto from global (NodeJS)
|
||||
if (!crypto && typeof global !== 'undefined' && global.crypto) {
|
||||
crypto = global.crypto;
|
||||
}
|
||||
|
||||
// Native crypto import via require (NodeJS)
|
||||
if (!crypto && typeof require === 'function') {
|
||||
try {
|
||||
crypto = require('crypto');
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
/*
|
||||
* Cryptographically secure pseudorandom number generator
|
||||
*
|
||||
* As Math.random() is cryptographically not safe to use
|
||||
*/
|
||||
var cryptoSecureRandomInt = function () {
|
||||
if (crypto) {
|
||||
// Use getRandomValues method (Browser)
|
||||
if (typeof crypto.getRandomValues === 'function') {
|
||||
try {
|
||||
return crypto.getRandomValues(new Uint32Array(1))[0];
|
||||
} catch (err) {}
|
||||
}
|
||||
|
||||
// Use randomBytes method (NodeJS)
|
||||
if (typeof crypto.randomBytes === 'function') {
|
||||
try {
|
||||
return crypto.randomBytes(4).readInt32LE();
|
||||
} catch (err) {}
|
||||
}
|
||||
}
|
||||
|
||||
throw new Error('Native crypto module could not be used to get secure random number.');
|
||||
};
|
||||
|
||||
/*
|
||||
* Local polyfill of Object.create
|
||||
*/
|
||||
var create = Object.create || (function () {
|
||||
function F() {}
|
||||
|
||||
return function (obj) {
|
||||
var subtype;
|
||||
|
||||
F.prototype = obj;
|
||||
|
||||
subtype = new F();
|
||||
|
||||
F.prototype = null;
|
||||
|
||||
return subtype;
|
||||
};
|
||||
}())
|
||||
|
||||
/**
|
||||
* CryptoJS namespace.
|
||||
*/
|
||||
var C = {};
|
||||
|
||||
/**
|
||||
* Library namespace.
|
||||
*/
|
||||
var C_lib = C.lib = {};
|
||||
|
||||
/**
|
||||
* Base object for prototypal inheritance.
|
||||
*/
|
||||
var Base = C_lib.Base = (function () {
|
||||
|
||||
|
||||
return {
|
||||
/**
|
||||
* Creates a new object that inherits from this object.
|
||||
*
|
||||
* @param {Object} overrides Properties to copy into the new object.
|
||||
*
|
||||
* @return {Object} The new object.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var MyType = CryptoJS.lib.Base.extend({
|
||||
* field: 'value',
|
||||
*
|
||||
* method: function () {
|
||||
* }
|
||||
* });
|
||||
*/
|
||||
extend: function (overrides) {
|
||||
// Spawn
|
||||
var subtype = create(this);
|
||||
|
||||
// Augment
|
||||
if (overrides) {
|
||||
subtype.mixIn(overrides);
|
||||
}
|
||||
|
||||
// Create default initializer
|
||||
if (!subtype.hasOwnProperty('init') || this.init === subtype.init) {
|
||||
subtype.init = function () {
|
||||
subtype.$super.init.apply(this, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
// Initializer's prototype is the subtype object
|
||||
subtype.init.prototype = subtype;
|
||||
|
||||
// Reference supertype
|
||||
subtype.$super = this;
|
||||
|
||||
return subtype;
|
||||
},
|
||||
|
||||
/**
|
||||
* Extends this object and runs the init method.
|
||||
* Arguments to create() will be passed to init().
|
||||
*
|
||||
* @return {Object} The new object.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var instance = MyType.create();
|
||||
*/
|
||||
create: function () {
|
||||
var instance = this.extend();
|
||||
instance.init.apply(instance, arguments);
|
||||
|
||||
return instance;
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes a newly created object.
|
||||
* Override this method to add some logic when your objects are created.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var MyType = CryptoJS.lib.Base.extend({
|
||||
* init: function () {
|
||||
* // ...
|
||||
* }
|
||||
* });
|
||||
*/
|
||||
init: function () {
|
||||
},
|
||||
|
||||
/**
|
||||
* Copies properties into this object.
|
||||
*
|
||||
* @param {Object} properties The properties to mix in.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* MyType.mixIn({
|
||||
* field: 'value'
|
||||
* });
|
||||
*/
|
||||
mixIn: function (properties) {
|
||||
for (var propertyName in properties) {
|
||||
if (properties.hasOwnProperty(propertyName)) {
|
||||
this[propertyName] = properties[propertyName];
|
||||
}
|
||||
}
|
||||
|
||||
// IE won't copy toString using the loop above
|
||||
if (properties.hasOwnProperty('toString')) {
|
||||
this.toString = properties.toString;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a copy of this object.
|
||||
*
|
||||
* @return {Object} The clone.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var clone = instance.clone();
|
||||
*/
|
||||
clone: function () {
|
||||
return this.init.prototype.extend(this);
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
||||
/**
|
||||
* An array of 32-bit words.
|
||||
*
|
||||
* @property {Array} words The array of 32-bit words.
|
||||
* @property {number} sigBytes The number of significant bytes in this word array.
|
||||
*/
|
||||
var WordArray = C_lib.WordArray = Base.extend({
|
||||
/**
|
||||
* Initializes a newly created word array.
|
||||
*
|
||||
* @param {Array} words (Optional) An array of 32-bit words.
|
||||
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var wordArray = CryptoJS.lib.WordArray.create();
|
||||
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
|
||||
* var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
|
||||
*/
|
||||
init: function (words, sigBytes) {
|
||||
words = this.words = words || [];
|
||||
|
||||
if (sigBytes != undefined) {
|
||||
this.sigBytes = sigBytes;
|
||||
} else {
|
||||
this.sigBytes = words.length * 4;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts this word array to a string.
|
||||
*
|
||||
* @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
|
||||
*
|
||||
* @return {string} The stringified word array.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var string = wordArray + '';
|
||||
* var string = wordArray.toString();
|
||||
* var string = wordArray.toString(CryptoJS.enc.Utf8);
|
||||
*/
|
||||
toString: function (encoder) {
|
||||
return (encoder || Hex).stringify(this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Concatenates a word array to this word array.
|
||||
*
|
||||
* @param {WordArray} wordArray The word array to append.
|
||||
*
|
||||
* @return {WordArray} This word array.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* wordArray1.concat(wordArray2);
|
||||
*/
|
||||
concat: function (wordArray) {
|
||||
// Shortcuts
|
||||
var thisWords = this.words;
|
||||
var thatWords = wordArray.words;
|
||||
var thisSigBytes = this.sigBytes;
|
||||
var thatSigBytes = wordArray.sigBytes;
|
||||
|
||||
// Clamp excess bits
|
||||
this.clamp();
|
||||
|
||||
// Concat
|
||||
if (thisSigBytes % 4) {
|
||||
// Copy one byte at a time
|
||||
for (var i = 0; i < thatSigBytes; i++) {
|
||||
var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
||||
thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
|
||||
}
|
||||
} else {
|
||||
// Copy one word at a time
|
||||
for (var i = 0; i < thatSigBytes; i += 4) {
|
||||
thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
|
||||
}
|
||||
}
|
||||
this.sigBytes += thatSigBytes;
|
||||
|
||||
// Chainable
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes insignificant bits.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* wordArray.clamp();
|
||||
*/
|
||||
clamp: function () {
|
||||
// Shortcuts
|
||||
var words = this.words;
|
||||
var sigBytes = this.sigBytes;
|
||||
|
||||
// Clamp
|
||||
words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
|
||||
words.length = Math.ceil(sigBytes / 4);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a copy of this word array.
|
||||
*
|
||||
* @return {WordArray} The clone.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var clone = wordArray.clone();
|
||||
*/
|
||||
clone: function () {
|
||||
var clone = Base.clone.call(this);
|
||||
clone.words = this.words.slice(0);
|
||||
|
||||
return clone;
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a word array filled with random bytes.
|
||||
*
|
||||
* @param {number} nBytes The number of random bytes to generate.
|
||||
*
|
||||
* @return {WordArray} The random word array.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var wordArray = CryptoJS.lib.WordArray.random(16);
|
||||
*/
|
||||
random: function (nBytes) {
|
||||
var words = [];
|
||||
|
||||
for (var i = 0; i < nBytes; i += 4) {
|
||||
words.push(cryptoSecureRandomInt());
|
||||
}
|
||||
|
||||
return new WordArray.init(words, nBytes);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Encoder namespace.
|
||||
*/
|
||||
var C_enc = C.enc = {};
|
||||
|
||||
/**
|
||||
* Hex encoding strategy.
|
||||
*/
|
||||
var Hex = C_enc.Hex = {
|
||||
/**
|
||||
* Converts a word array to a hex string.
|
||||
*
|
||||
* @param {WordArray} wordArray The word array.
|
||||
*
|
||||
* @return {string} The hex string.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hexString = CryptoJS.enc.Hex.stringify(wordArray);
|
||||
*/
|
||||
stringify: function (wordArray) {
|
||||
// Shortcuts
|
||||
var words = wordArray.words;
|
||||
var sigBytes = wordArray.sigBytes;
|
||||
|
||||
// Convert
|
||||
var hexChars = [];
|
||||
for (var i = 0; i < sigBytes; i++) {
|
||||
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
||||
hexChars.push((bite >>> 4).toString(16));
|
||||
hexChars.push((bite & 0x0f).toString(16));
|
||||
}
|
||||
|
||||
return hexChars.join('');
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts a hex string to a word array.
|
||||
*
|
||||
* @param {string} hexStr The hex string.
|
||||
*
|
||||
* @return {WordArray} The word array.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var wordArray = CryptoJS.enc.Hex.parse(hexString);
|
||||
*/
|
||||
parse: function (hexStr) {
|
||||
// Shortcut
|
||||
var hexStrLength = hexStr.length;
|
||||
|
||||
// Convert
|
||||
var words = [];
|
||||
for (var i = 0; i < hexStrLength; i += 2) {
|
||||
words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
|
||||
}
|
||||
|
||||
return new WordArray.init(words, hexStrLength / 2);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Latin1 encoding strategy.
|
||||
*/
|
||||
var Latin1 = C_enc.Latin1 = {
|
||||
/**
|
||||
* Converts a word array to a Latin1 string.
|
||||
*
|
||||
* @param {WordArray} wordArray The word array.
|
||||
*
|
||||
* @return {string} The Latin1 string.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
|
||||
*/
|
||||
stringify: function (wordArray) {
|
||||
// Shortcuts
|
||||
var words = wordArray.words;
|
||||
var sigBytes = wordArray.sigBytes;
|
||||
|
||||
// Convert
|
||||
var latin1Chars = [];
|
||||
for (var i = 0; i < sigBytes; i++) {
|
||||
var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
||||
latin1Chars.push(String.fromCharCode(bite));
|
||||
}
|
||||
|
||||
return latin1Chars.join('');
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts a Latin1 string to a word array.
|
||||
*
|
||||
* @param {string} latin1Str The Latin1 string.
|
||||
*
|
||||
* @return {WordArray} The word array.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
|
||||
*/
|
||||
parse: function (latin1Str) {
|
||||
// Shortcut
|
||||
var latin1StrLength = latin1Str.length;
|
||||
|
||||
// Convert
|
||||
var words = [];
|
||||
for (var i = 0; i < latin1StrLength; i++) {
|
||||
words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
|
||||
}
|
||||
|
||||
return new WordArray.init(words, latin1StrLength);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* UTF-8 encoding strategy.
|
||||
*/
|
||||
var Utf8 = C_enc.Utf8 = {
|
||||
/**
|
||||
* Converts a word array to a UTF-8 string.
|
||||
*
|
||||
* @param {WordArray} wordArray The word array.
|
||||
*
|
||||
* @return {string} The UTF-8 string.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
|
||||
*/
|
||||
stringify: function (wordArray) {
|
||||
try {
|
||||
return decodeURIComponent(escape(Latin1.stringify(wordArray)));
|
||||
} catch (e) {
|
||||
throw new Error('Malformed UTF-8 data');
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts a UTF-8 string to a word array.
|
||||
*
|
||||
* @param {string} utf8Str The UTF-8 string.
|
||||
*
|
||||
* @return {WordArray} The word array.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
|
||||
*/
|
||||
parse: function (utf8Str) {
|
||||
return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Abstract buffered block algorithm template.
|
||||
*
|
||||
* The property blockSize must be implemented in a concrete subtype.
|
||||
*
|
||||
* @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0
|
||||
*/
|
||||
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
|
||||
/**
|
||||
* Resets this block algorithm's data buffer to its initial state.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* bufferedBlockAlgorithm.reset();
|
||||
*/
|
||||
reset: function () {
|
||||
// Initial values
|
||||
this._data = new WordArray.init();
|
||||
this._nDataBytes = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds new data to this block algorithm's buffer.
|
||||
*
|
||||
* @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* bufferedBlockAlgorithm._append('data');
|
||||
* bufferedBlockAlgorithm._append(wordArray);
|
||||
*/
|
||||
_append: function (data) {
|
||||
// Convert string to WordArray, else assume WordArray already
|
||||
if (typeof data == 'string') {
|
||||
data = Utf8.parse(data);
|
||||
}
|
||||
|
||||
// Append
|
||||
this._data.concat(data);
|
||||
this._nDataBytes += data.sigBytes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Processes available data blocks.
|
||||
*
|
||||
* This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
|
||||
*
|
||||
* @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
|
||||
*
|
||||
* @return {WordArray} The processed data.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var processedData = bufferedBlockAlgorithm._process();
|
||||
* var processedData = bufferedBlockAlgorithm._process(!!'flush');
|
||||
*/
|
||||
_process: function (doFlush) {
|
||||
var processedWords;
|
||||
|
||||
// Shortcuts
|
||||
var data = this._data;
|
||||
var dataWords = data.words;
|
||||
var dataSigBytes = data.sigBytes;
|
||||
var blockSize = this.blockSize;
|
||||
var blockSizeBytes = blockSize * 4;
|
||||
|
||||
// Count blocks ready
|
||||
var nBlocksReady = dataSigBytes / blockSizeBytes;
|
||||
if (doFlush) {
|
||||
// Round up to include partial blocks
|
||||
nBlocksReady = Math.ceil(nBlocksReady);
|
||||
} else {
|
||||
// Round down to include only full blocks,
|
||||
// less the number of blocks that must remain in the buffer
|
||||
nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
||||
}
|
||||
|
||||
// Count words ready
|
||||
var nWordsReady = nBlocksReady * blockSize;
|
||||
|
||||
// Count bytes ready
|
||||
var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
|
||||
|
||||
// Process blocks
|
||||
if (nWordsReady) {
|
||||
for (var offset = 0; offset < nWordsReady; offset += blockSize) {
|
||||
// Perform concrete-algorithm logic
|
||||
this._doProcessBlock(dataWords, offset);
|
||||
}
|
||||
|
||||
// Remove processed words
|
||||
processedWords = dataWords.splice(0, nWordsReady);
|
||||
data.sigBytes -= nBytesReady;
|
||||
}
|
||||
|
||||
// Return processed words
|
||||
return new WordArray.init(processedWords, nBytesReady);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a copy of this object.
|
||||
*
|
||||
* @return {Object} The clone.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var clone = bufferedBlockAlgorithm.clone();
|
||||
*/
|
||||
clone: function () {
|
||||
var clone = Base.clone.call(this);
|
||||
clone._data = this._data.clone();
|
||||
|
||||
return clone;
|
||||
},
|
||||
|
||||
_minBufferSize: 0
|
||||
});
|
||||
|
||||
/**
|
||||
* Abstract hasher template.
|
||||
*
|
||||
* @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits)
|
||||
*/
|
||||
var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
|
||||
/**
|
||||
* Configuration options.
|
||||
*/
|
||||
cfg: Base.extend(),
|
||||
|
||||
/**
|
||||
* Initializes a newly created hasher.
|
||||
*
|
||||
* @param {Object} cfg (Optional) The configuration options to use for this hash computation.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hasher = CryptoJS.algo.SHA256.create();
|
||||
*/
|
||||
init: function (cfg) {
|
||||
// Apply config defaults
|
||||
this.cfg = this.cfg.extend(cfg);
|
||||
|
||||
// Set initial values
|
||||
this.reset();
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets this hasher to its initial state.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* hasher.reset();
|
||||
*/
|
||||
reset: function () {
|
||||
// Reset data buffer
|
||||
BufferedBlockAlgorithm.reset.call(this);
|
||||
|
||||
// Perform concrete-hasher logic
|
||||
this._doReset();
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates this hasher with a message.
|
||||
*
|
||||
* @param {WordArray|string} messageUpdate The message to append.
|
||||
*
|
||||
* @return {Hasher} This hasher.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* hasher.update('message');
|
||||
* hasher.update(wordArray);
|
||||
*/
|
||||
update: function (messageUpdate) {
|
||||
// Append
|
||||
this._append(messageUpdate);
|
||||
|
||||
// Update the hash
|
||||
this._process();
|
||||
|
||||
// Chainable
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Finalizes the hash computation.
|
||||
* Note that the finalize operation is effectively a destructive, read-once operation.
|
||||
*
|
||||
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
||||
*
|
||||
* @return {WordArray} The hash.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hash = hasher.finalize();
|
||||
* var hash = hasher.finalize('message');
|
||||
* var hash = hasher.finalize(wordArray);
|
||||
*/
|
||||
finalize: function (messageUpdate) {
|
||||
// Final message update
|
||||
if (messageUpdate) {
|
||||
this._append(messageUpdate);
|
||||
}
|
||||
|
||||
// Perform concrete-hasher logic
|
||||
var hash = this._doFinalize();
|
||||
|
||||
return hash;
|
||||
},
|
||||
|
||||
blockSize: 512/32,
|
||||
|
||||
/**
|
||||
* Creates a shortcut function to a hasher's object interface.
|
||||
*
|
||||
* @param {Hasher} hasher The hasher to create a helper for.
|
||||
*
|
||||
* @return {Function} The shortcut function.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
|
||||
*/
|
||||
_createHelper: function (hasher) {
|
||||
return function (message, cfg) {
|
||||
return new hasher.init(cfg).finalize(message);
|
||||
};
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a shortcut function to the HMAC's object interface.
|
||||
*
|
||||
* @param {Hasher} hasher The hasher to use in this HMAC helper.
|
||||
*
|
||||
* @return {Function} The shortcut function.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
|
||||
*/
|
||||
_createHmacHelper: function (hasher) {
|
||||
return function (message, key) {
|
||||
return new C_algo.HMAC.init(hasher, key).finalize(message);
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Algorithm namespace.
|
||||
*/
|
||||
var C_algo = C.algo = {};
|
||||
|
||||
return C;
|
||||
}(Math));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function (undefined) {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var Base = C_lib.Base;
|
||||
var X32WordArray = C_lib.WordArray;
|
||||
|
||||
/**
|
||||
* x64 namespace.
|
||||
*/
|
||||
var C_x64 = C.x64 = {};
|
||||
|
||||
/**
|
||||
* A 64-bit word.
|
||||
*/
|
||||
var X64Word = C_x64.Word = Base.extend({
|
||||
/**
|
||||
* Initializes a newly created 64-bit word.
|
||||
*
|
||||
* @param {number} high The high 32 bits.
|
||||
* @param {number} low The low 32 bits.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
|
||||
*/
|
||||
init: function (high, low) {
|
||||
this.high = high;
|
||||
this.low = low;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bitwise NOTs this word.
|
||||
*
|
||||
* @return {X64Word} A new x64-Word object after negating.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var negated = x64Word.not();
|
||||
*/
|
||||
// not: function () {
|
||||
// var high = ~this.high;
|
||||
// var low = ~this.low;
|
||||
|
||||
// return X64Word.create(high, low);
|
||||
// },
|
||||
|
||||
/**
|
||||
* Bitwise ANDs this word with the passed word.
|
||||
*
|
||||
* @param {X64Word} word The x64-Word to AND with this word.
|
||||
*
|
||||
* @return {X64Word} A new x64-Word object after ANDing.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var anded = x64Word.and(anotherX64Word);
|
||||
*/
|
||||
// and: function (word) {
|
||||
// var high = this.high & word.high;
|
||||
// var low = this.low & word.low;
|
||||
|
||||
// return X64Word.create(high, low);
|
||||
// },
|
||||
|
||||
/**
|
||||
* Bitwise ORs this word with the passed word.
|
||||
*
|
||||
* @param {X64Word} word The x64-Word to OR with this word.
|
||||
*
|
||||
* @return {X64Word} A new x64-Word object after ORing.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var ored = x64Word.or(anotherX64Word);
|
||||
*/
|
||||
// or: function (word) {
|
||||
// var high = this.high | word.high;
|
||||
// var low = this.low | word.low;
|
||||
|
||||
// return X64Word.create(high, low);
|
||||
// },
|
||||
|
||||
/**
|
||||
* Bitwise XORs this word with the passed word.
|
||||
*
|
||||
* @param {X64Word} word The x64-Word to XOR with this word.
|
||||
*
|
||||
* @return {X64Word} A new x64-Word object after XORing.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var xored = x64Word.xor(anotherX64Word);
|
||||
*/
|
||||
// xor: function (word) {
|
||||
// var high = this.high ^ word.high;
|
||||
// var low = this.low ^ word.low;
|
||||
|
||||
// return X64Word.create(high, low);
|
||||
// },
|
||||
|
||||
/**
|
||||
* Shifts this word n bits to the left.
|
||||
*
|
||||
* @param {number} n The number of bits to shift.
|
||||
*
|
||||
* @return {X64Word} A new x64-Word object after shifting.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var shifted = x64Word.shiftL(25);
|
||||
*/
|
||||
// shiftL: function (n) {
|
||||
// if (n < 32) {
|
||||
// var high = (this.high << n) | (this.low >>> (32 - n));
|
||||
// var low = this.low << n;
|
||||
// } else {
|
||||
// var high = this.low << (n - 32);
|
||||
// var low = 0;
|
||||
// }
|
||||
|
||||
// return X64Word.create(high, low);
|
||||
// },
|
||||
|
||||
/**
|
||||
* Shifts this word n bits to the right.
|
||||
*
|
||||
* @param {number} n The number of bits to shift.
|
||||
*
|
||||
* @return {X64Word} A new x64-Word object after shifting.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var shifted = x64Word.shiftR(7);
|
||||
*/
|
||||
// shiftR: function (n) {
|
||||
// if (n < 32) {
|
||||
// var low = (this.low >>> n) | (this.high << (32 - n));
|
||||
// var high = this.high >>> n;
|
||||
// } else {
|
||||
// var low = this.high >>> (n - 32);
|
||||
// var high = 0;
|
||||
// }
|
||||
|
||||
// return X64Word.create(high, low);
|
||||
// },
|
||||
|
||||
/**
|
||||
* Rotates this word n bits to the left.
|
||||
*
|
||||
* @param {number} n The number of bits to rotate.
|
||||
*
|
||||
* @return {X64Word} A new x64-Word object after rotating.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var rotated = x64Word.rotL(25);
|
||||
*/
|
||||
// rotL: function (n) {
|
||||
// return this.shiftL(n).or(this.shiftR(64 - n));
|
||||
// },
|
||||
|
||||
/**
|
||||
* Rotates this word n bits to the right.
|
||||
*
|
||||
* @param {number} n The number of bits to rotate.
|
||||
*
|
||||
* @return {X64Word} A new x64-Word object after rotating.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var rotated = x64Word.rotR(7);
|
||||
*/
|
||||
// rotR: function (n) {
|
||||
// return this.shiftR(n).or(this.shiftL(64 - n));
|
||||
// },
|
||||
|
||||
/**
|
||||
* Adds this word with the passed word.
|
||||
*
|
||||
* @param {X64Word} word The x64-Word to add with this word.
|
||||
*
|
||||
* @return {X64Word} A new x64-Word object after adding.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var added = x64Word.add(anotherX64Word);
|
||||
*/
|
||||
// add: function (word) {
|
||||
// var low = (this.low + word.low) | 0;
|
||||
// var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
|
||||
// var high = (this.high + word.high + carry) | 0;
|
||||
|
||||
// return X64Word.create(high, low);
|
||||
// }
|
||||
});
|
||||
|
||||
/**
|
||||
* An array of 64-bit words.
|
||||
*
|
||||
* @property {Array} words The array of CryptoJS.x64.Word objects.
|
||||
* @property {number} sigBytes The number of significant bytes in this word array.
|
||||
*/
|
||||
var X64WordArray = C_x64.WordArray = Base.extend({
|
||||
/**
|
||||
* Initializes a newly created word array.
|
||||
*
|
||||
* @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
|
||||
* @param {number} sigBytes (Optional) The number of significant bytes in the words.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var wordArray = CryptoJS.x64.WordArray.create();
|
||||
*
|
||||
* var wordArray = CryptoJS.x64.WordArray.create([
|
||||
* CryptoJS.x64.Word.create(0x00010203, 0x04050607),
|
||||
* CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
|
||||
* ]);
|
||||
*
|
||||
* var wordArray = CryptoJS.x64.WordArray.create([
|
||||
* CryptoJS.x64.Word.create(0x00010203, 0x04050607),
|
||||
* CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
|
||||
* ], 10);
|
||||
*/
|
||||
init: function (words, sigBytes) {
|
||||
words = this.words = words || [];
|
||||
|
||||
if (sigBytes != undefined) {
|
||||
this.sigBytes = sigBytes;
|
||||
} else {
|
||||
this.sigBytes = words.length * 8;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts this 64-bit word array to a 32-bit word array.
|
||||
*
|
||||
* @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var x32WordArray = x64WordArray.toX32();
|
||||
*/
|
||||
toX32: function () {
|
||||
// Shortcuts
|
||||
var x64Words = this.words;
|
||||
var x64WordsLength = x64Words.length;
|
||||
|
||||
// Convert
|
||||
var x32Words = [];
|
||||
for (var i = 0; i < x64WordsLength; i++) {
|
||||
var x64Word = x64Words[i];
|
||||
x32Words.push(x64Word.high);
|
||||
x32Words.push(x64Word.low);
|
||||
}
|
||||
|
||||
return X32WordArray.create(x32Words, this.sigBytes);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a copy of this word array.
|
||||
*
|
||||
* @return {X64WordArray} The clone.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var clone = x64WordArray.clone();
|
||||
*/
|
||||
clone: function () {
|
||||
var clone = Base.clone.call(this);
|
||||
|
||||
// Clone "words" array
|
||||
var words = clone.words = this.words.slice(0);
|
||||
|
||||
// Clone each X64Word object
|
||||
var wordsLength = words.length;
|
||||
for (var i = 0; i < wordsLength; i++) {
|
||||
words[i] = words[i].clone();
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
// Check if typed arrays are supported
|
||||
if (typeof ArrayBuffer != 'function') {
|
||||
return;
|
||||
}
|
||||
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var WordArray = C_lib.WordArray;
|
||||
|
||||
// Reference original init
|
||||
var superInit = WordArray.init;
|
||||
|
||||
// Augment WordArray.init to handle typed arrays
|
||||
var subInit = WordArray.init = function (typedArray) {
|
||||
// Convert buffers to uint8
|
||||
if (typedArray instanceof ArrayBuffer) {
|
||||
typedArray = new Uint8Array(typedArray);
|
||||
}
|
||||
|
||||
// Convert other array views to uint8
|
||||
if (
|
||||
typedArray instanceof Int8Array ||
|
||||
(typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) ||
|
||||
typedArray instanceof Int16Array ||
|
||||
typedArray instanceof Uint16Array ||
|
||||
typedArray instanceof Int32Array ||
|
||||
typedArray instanceof Uint32Array ||
|
||||
typedArray instanceof Float32Array ||
|
||||
typedArray instanceof Float64Array
|
||||
) {
|
||||
typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength);
|
||||
}
|
||||
|
||||
// Handle Uint8Array
|
||||
if (typedArray instanceof Uint8Array) {
|
||||
// Shortcut
|
||||
var typedArrayByteLength = typedArray.byteLength;
|
||||
|
||||
// Extract bytes
|
||||
var words = [];
|
||||
for (var i = 0; i < typedArrayByteLength; i++) {
|
||||
words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8);
|
||||
}
|
||||
|
||||
// Initialize this word array
|
||||
superInit.call(this, words, typedArrayByteLength);
|
||||
} else {
|
||||
// Else call normal init
|
||||
superInit.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
subInit.prototype = WordArray;
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var WordArray = C_lib.WordArray;
|
||||
var C_enc = C.enc;
|
||||
|
||||
/**
|
||||
* UTF-16 BE encoding strategy.
|
||||
*/
|
||||
var Utf16BE = C_enc.Utf16 = C_enc.Utf16BE = {
|
||||
/**
|
||||
* Converts a word array to a UTF-16 BE string.
|
||||
*
|
||||
* @param {WordArray} wordArray The word array.
|
||||
*
|
||||
* @return {string} The UTF-16 BE string.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
|
||||
*/
|
||||
stringify: function (wordArray) {
|
||||
// Shortcuts
|
||||
var words = wordArray.words;
|
||||
var sigBytes = wordArray.sigBytes;
|
||||
|
||||
// Convert
|
||||
var utf16Chars = [];
|
||||
for (var i = 0; i < sigBytes; i += 2) {
|
||||
var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff;
|
||||
utf16Chars.push(String.fromCharCode(codePoint));
|
||||
}
|
||||
|
||||
return utf16Chars.join('');
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts a UTF-16 BE string to a word array.
|
||||
*
|
||||
* @param {string} utf16Str The UTF-16 BE string.
|
||||
*
|
||||
* @return {WordArray} The word array.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
|
||||
*/
|
||||
parse: function (utf16Str) {
|
||||
// Shortcut
|
||||
var utf16StrLength = utf16Str.length;
|
||||
|
||||
// Convert
|
||||
var words = [];
|
||||
for (var i = 0; i < utf16StrLength; i++) {
|
||||
words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16);
|
||||
}
|
||||
|
||||
return WordArray.create(words, utf16StrLength * 2);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* UTF-16 LE encoding strategy.
|
||||
*/
|
||||
C_enc.Utf16LE = {
|
||||
/**
|
||||
* Converts a word array to a UTF-16 LE string.
|
||||
*
|
||||
* @param {WordArray} wordArray The word array.
|
||||
*
|
||||
* @return {string} The UTF-16 LE string.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
|
||||
*/
|
||||
stringify: function (wordArray) {
|
||||
// Shortcuts
|
||||
var words = wordArray.words;
|
||||
var sigBytes = wordArray.sigBytes;
|
||||
|
||||
// Convert
|
||||
var utf16Chars = [];
|
||||
for (var i = 0; i < sigBytes; i += 2) {
|
||||
var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff);
|
||||
utf16Chars.push(String.fromCharCode(codePoint));
|
||||
}
|
||||
|
||||
return utf16Chars.join('');
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts a UTF-16 LE string to a word array.
|
||||
*
|
||||
* @param {string} utf16Str The UTF-16 LE string.
|
||||
*
|
||||
* @return {WordArray} The word array.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
|
||||
*/
|
||||
parse: function (utf16Str) {
|
||||
// Shortcut
|
||||
var utf16StrLength = utf16Str.length;
|
||||
|
||||
// Convert
|
||||
var words = [];
|
||||
for (var i = 0; i < utf16StrLength; i++) {
|
||||
words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16));
|
||||
}
|
||||
|
||||
return WordArray.create(words, utf16StrLength * 2);
|
||||
}
|
||||
};
|
||||
|
||||
function swapEndian(word) {
|
||||
return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff);
|
||||
}
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var WordArray = C_lib.WordArray;
|
||||
var C_enc = C.enc;
|
||||
|
||||
/**
|
||||
* Base64 encoding strategy.
|
||||
*/
|
||||
var Base64 = C_enc.Base64 = {
|
||||
/**
|
||||
* Converts a word array to a Base64 string.
|
||||
*
|
||||
* @param {WordArray} wordArray The word array.
|
||||
*
|
||||
* @return {string} The Base64 string.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var base64String = CryptoJS.enc.Base64.stringify(wordArray);
|
||||
*/
|
||||
stringify: function (wordArray) {
|
||||
// Shortcuts
|
||||
var words = wordArray.words;
|
||||
var sigBytes = wordArray.sigBytes;
|
||||
var map = this._map;
|
||||
|
||||
// Clamp excess bits
|
||||
wordArray.clamp();
|
||||
|
||||
// Convert
|
||||
var base64Chars = [];
|
||||
for (var i = 0; i < sigBytes; i += 3) {
|
||||
var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
||||
var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
|
||||
var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
|
||||
|
||||
var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
|
||||
|
||||
for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
|
||||
base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
|
||||
}
|
||||
}
|
||||
|
||||
// Add padding
|
||||
var paddingChar = map.charAt(64);
|
||||
if (paddingChar) {
|
||||
while (base64Chars.length % 4) {
|
||||
base64Chars.push(paddingChar);
|
||||
}
|
||||
}
|
||||
|
||||
return base64Chars.join('');
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts a Base64 string to a word array.
|
||||
*
|
||||
* @param {string} base64Str The Base64 string.
|
||||
*
|
||||
* @return {WordArray} The word array.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var wordArray = CryptoJS.enc.Base64.parse(base64String);
|
||||
*/
|
||||
parse: function (base64Str) {
|
||||
// Shortcuts
|
||||
var base64StrLength = base64Str.length;
|
||||
var map = this._map;
|
||||
var reverseMap = this._reverseMap;
|
||||
|
||||
if (!reverseMap) {
|
||||
reverseMap = this._reverseMap = [];
|
||||
for (var j = 0; j < map.length; j++) {
|
||||
reverseMap[map.charCodeAt(j)] = j;
|
||||
}
|
||||
}
|
||||
|
||||
// Ignore padding
|
||||
var paddingChar = map.charAt(64);
|
||||
if (paddingChar) {
|
||||
var paddingIndex = base64Str.indexOf(paddingChar);
|
||||
if (paddingIndex !== -1) {
|
||||
base64StrLength = paddingIndex;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert
|
||||
return parseLoop(base64Str, base64StrLength, reverseMap);
|
||||
|
||||
},
|
||||
|
||||
_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
|
||||
};
|
||||
|
||||
function parseLoop(base64Str, base64StrLength, reverseMap) {
|
||||
var words = [];
|
||||
var nBytes = 0;
|
||||
for (var i = 0; i < base64StrLength; i++) {
|
||||
if (i % 4) {
|
||||
var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2);
|
||||
var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2);
|
||||
var bitsCombined = bits1 | bits2;
|
||||
words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8);
|
||||
nBytes++;
|
||||
}
|
||||
}
|
||||
return WordArray.create(words, nBytes);
|
||||
}
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function (Math) {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var WordArray = C_lib.WordArray;
|
||||
var Hasher = C_lib.Hasher;
|
||||
var C_algo = C.algo;
|
||||
|
||||
// Constants table
|
||||
var T = [];
|
||||
|
||||
// Compute constants
|
||||
(function () {
|
||||
for (var i = 0; i < 64; i++) {
|
||||
T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
|
||||
}
|
||||
}());
|
||||
|
||||
/**
|
||||
* MD5 hash algorithm.
|
||||
*/
|
||||
var MD5 = C_algo.MD5 = Hasher.extend({
|
||||
_doReset: function () {
|
||||
this._hash = new WordArray.init([
|
||||
0x67452301, 0xefcdab89,
|
||||
0x98badcfe, 0x10325476
|
||||
]);
|
||||
},
|
||||
|
||||
_doProcessBlock: function (M, offset) {
|
||||
// Swap endian
|
||||
for (var i = 0; i < 16; i++) {
|
||||
// Shortcuts
|
||||
var offset_i = offset + i;
|
||||
var M_offset_i = M[offset_i];
|
||||
|
||||
M[offset_i] = (
|
||||
(((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
|
||||
(((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
|
||||
);
|
||||
}
|
||||
|
||||
// Shortcuts
|
||||
var H = this._hash.words;
|
||||
|
||||
var M_offset_0 = M[offset + 0];
|
||||
var M_offset_1 = M[offset + 1];
|
||||
var M_offset_2 = M[offset + 2];
|
||||
var M_offset_3 = M[offset + 3];
|
||||
var M_offset_4 = M[offset + 4];
|
||||
var M_offset_5 = M[offset + 5];
|
||||
var M_offset_6 = M[offset + 6];
|
||||
var M_offset_7 = M[offset + 7];
|
||||
var M_offset_8 = M[offset + 8];
|
||||
var M_offset_9 = M[offset + 9];
|
||||
var M_offset_10 = M[offset + 10];
|
||||
var M_offset_11 = M[offset + 11];
|
||||
var M_offset_12 = M[offset + 12];
|
||||
var M_offset_13 = M[offset + 13];
|
||||
var M_offset_14 = M[offset + 14];
|
||||
var M_offset_15 = M[offset + 15];
|
||||
|
||||
// Working varialbes
|
||||
var a = H[0];
|
||||
var b = H[1];
|
||||
var c = H[2];
|
||||
var d = H[3];
|
||||
|
||||
// Computation
|
||||
a = FF(a, b, c, d, M_offset_0, 7, T[0]);
|
||||
d = FF(d, a, b, c, M_offset_1, 12, T[1]);
|
||||
c = FF(c, d, a, b, M_offset_2, 17, T[2]);
|
||||
b = FF(b, c, d, a, M_offset_3, 22, T[3]);
|
||||
a = FF(a, b, c, d, M_offset_4, 7, T[4]);
|
||||
d = FF(d, a, b, c, M_offset_5, 12, T[5]);
|
||||
c = FF(c, d, a, b, M_offset_6, 17, T[6]);
|
||||
b = FF(b, c, d, a, M_offset_7, 22, T[7]);
|
||||
a = FF(a, b, c, d, M_offset_8, 7, T[8]);
|
||||
d = FF(d, a, b, c, M_offset_9, 12, T[9]);
|
||||
c = FF(c, d, a, b, M_offset_10, 17, T[10]);
|
||||
b = FF(b, c, d, a, M_offset_11, 22, T[11]);
|
||||
a = FF(a, b, c, d, M_offset_12, 7, T[12]);
|
||||
d = FF(d, a, b, c, M_offset_13, 12, T[13]);
|
||||
c = FF(c, d, a, b, M_offset_14, 17, T[14]);
|
||||
b = FF(b, c, d, a, M_offset_15, 22, T[15]);
|
||||
|
||||
a = GG(a, b, c, d, M_offset_1, 5, T[16]);
|
||||
d = GG(d, a, b, c, M_offset_6, 9, T[17]);
|
||||
c = GG(c, d, a, b, M_offset_11, 14, T[18]);
|
||||
b = GG(b, c, d, a, M_offset_0, 20, T[19]);
|
||||
a = GG(a, b, c, d, M_offset_5, 5, T[20]);
|
||||
d = GG(d, a, b, c, M_offset_10, 9, T[21]);
|
||||
c = GG(c, d, a, b, M_offset_15, 14, T[22]);
|
||||
b = GG(b, c, d, a, M_offset_4, 20, T[23]);
|
||||
a = GG(a, b, c, d, M_offset_9, 5, T[24]);
|
||||
d = GG(d, a, b, c, M_offset_14, 9, T[25]);
|
||||
c = GG(c, d, a, b, M_offset_3, 14, T[26]);
|
||||
b = GG(b, c, d, a, M_offset_8, 20, T[27]);
|
||||
a = GG(a, b, c, d, M_offset_13, 5, T[28]);
|
||||
d = GG(d, a, b, c, M_offset_2, 9, T[29]);
|
||||
c = GG(c, d, a, b, M_offset_7, 14, T[30]);
|
||||
b = GG(b, c, d, a, M_offset_12, 20, T[31]);
|
||||
|
||||
a = HH(a, b, c, d, M_offset_5, 4, T[32]);
|
||||
d = HH(d, a, b, c, M_offset_8, 11, T[33]);
|
||||
c = HH(c, d, a, b, M_offset_11, 16, T[34]);
|
||||
b = HH(b, c, d, a, M_offset_14, 23, T[35]);
|
||||
a = HH(a, b, c, d, M_offset_1, 4, T[36]);
|
||||
d = HH(d, a, b, c, M_offset_4, 11, T[37]);
|
||||
c = HH(c, d, a, b, M_offset_7, 16, T[38]);
|
||||
b = HH(b, c, d, a, M_offset_10, 23, T[39]);
|
||||
a = HH(a, b, c, d, M_offset_13, 4, T[40]);
|
||||
d = HH(d, a, b, c, M_offset_0, 11, T[41]);
|
||||
c = HH(c, d, a, b, M_offset_3, 16, T[42]);
|
||||
b = HH(b, c, d, a, M_offset_6, 23, T[43]);
|
||||
a = HH(a, b, c, d, M_offset_9, 4, T[44]);
|
||||
d = HH(d, a, b, c, M_offset_12, 11, T[45]);
|
||||
c = HH(c, d, a, b, M_offset_15, 16, T[46]);
|
||||
b = HH(b, c, d, a, M_offset_2, 23, T[47]);
|
||||
|
||||
a = II(a, b, c, d, M_offset_0, 6, T[48]);
|
||||
d = II(d, a, b, c, M_offset_7, 10, T[49]);
|
||||
c = II(c, d, a, b, M_offset_14, 15, T[50]);
|
||||
b = II(b, c, d, a, M_offset_5, 21, T[51]);
|
||||
a = II(a, b, c, d, M_offset_12, 6, T[52]);
|
||||
d = II(d, a, b, c, M_offset_3, 10, T[53]);
|
||||
c = II(c, d, a, b, M_offset_10, 15, T[54]);
|
||||
b = II(b, c, d, a, M_offset_1, 21, T[55]);
|
||||
a = II(a, b, c, d, M_offset_8, 6, T[56]);
|
||||
d = II(d, a, b, c, M_offset_15, 10, T[57]);
|
||||
c = II(c, d, a, b, M_offset_6, 15, T[58]);
|
||||
b = II(b, c, d, a, M_offset_13, 21, T[59]);
|
||||
a = II(a, b, c, d, M_offset_4, 6, T[60]);
|
||||
d = II(d, a, b, c, M_offset_11, 10, T[61]);
|
||||
c = II(c, d, a, b, M_offset_2, 15, T[62]);
|
||||
b = II(b, c, d, a, M_offset_9, 21, T[63]);
|
||||
|
||||
// Intermediate hash value
|
||||
H[0] = (H[0] + a) | 0;
|
||||
H[1] = (H[1] + b) | 0;
|
||||
H[2] = (H[2] + c) | 0;
|
||||
H[3] = (H[3] + d) | 0;
|
||||
},
|
||||
|
||||
_doFinalize: function () {
|
||||
// Shortcuts
|
||||
var data = this._data;
|
||||
var dataWords = data.words;
|
||||
|
||||
var nBitsTotal = this._nDataBytes * 8;
|
||||
var nBitsLeft = data.sigBytes * 8;
|
||||
|
||||
// Add padding
|
||||
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
||||
|
||||
var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
|
||||
var nBitsTotalL = nBitsTotal;
|
||||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
|
||||
(((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
|
||||
(((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
|
||||
);
|
||||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
|
||||
(((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
|
||||
(((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
|
||||
);
|
||||
|
||||
data.sigBytes = (dataWords.length + 1) * 4;
|
||||
|
||||
// Hash final blocks
|
||||
this._process();
|
||||
|
||||
// Shortcuts
|
||||
var hash = this._hash;
|
||||
var H = hash.words;
|
||||
|
||||
// Swap endian
|
||||
for (var i = 0; i < 4; i++) {
|
||||
// Shortcut
|
||||
var H_i = H[i];
|
||||
|
||||
H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
|
||||
(((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
|
||||
}
|
||||
|
||||
// Return final computed hash
|
||||
return hash;
|
||||
},
|
||||
|
||||
clone: function () {
|
||||
var clone = Hasher.clone.call(this);
|
||||
clone._hash = this._hash.clone();
|
||||
|
||||
return clone;
|
||||
}
|
||||
});
|
||||
|
||||
function FF(a, b, c, d, x, s, t) {
|
||||
var n = a + ((b & c) | (~b & d)) + x + t;
|
||||
return ((n << s) | (n >>> (32 - s))) + b;
|
||||
}
|
||||
|
||||
function GG(a, b, c, d, x, s, t) {
|
||||
var n = a + ((b & d) | (c & ~d)) + x + t;
|
||||
return ((n << s) | (n >>> (32 - s))) + b;
|
||||
}
|
||||
|
||||
function HH(a, b, c, d, x, s, t) {
|
||||
var n = a + (b ^ c ^ d) + x + t;
|
||||
return ((n << s) | (n >>> (32 - s))) + b;
|
||||
}
|
||||
|
||||
function II(a, b, c, d, x, s, t) {
|
||||
var n = a + (c ^ (b | ~d)) + x + t;
|
||||
return ((n << s) | (n >>> (32 - s))) + b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut function to the hasher's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
*
|
||||
* @return {WordArray} The hash.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hash = CryptoJS.MD5('message');
|
||||
* var hash = CryptoJS.MD5(wordArray);
|
||||
*/
|
||||
C.MD5 = Hasher._createHelper(MD5);
|
||||
|
||||
/**
|
||||
* Shortcut function to the HMAC's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
* @param {WordArray|string} key The secret key.
|
||||
*
|
||||
* @return {WordArray} The HMAC.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hmac = CryptoJS.HmacMD5(message, key);
|
||||
*/
|
||||
C.HmacMD5 = Hasher._createHmacHelper(MD5);
|
||||
}(Math));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var WordArray = C_lib.WordArray;
|
||||
var Hasher = C_lib.Hasher;
|
||||
var C_algo = C.algo;
|
||||
|
||||
// Reusable object
|
||||
var W = [];
|
||||
|
||||
/**
|
||||
* SHA-1 hash algorithm.
|
||||
*/
|
||||
var SHA1 = C_algo.SHA1 = Hasher.extend({
|
||||
_doReset: function () {
|
||||
this._hash = new WordArray.init([
|
||||
0x67452301, 0xefcdab89,
|
||||
0x98badcfe, 0x10325476,
|
||||
0xc3d2e1f0
|
||||
]);
|
||||
},
|
||||
|
||||
_doProcessBlock: function (M, offset) {
|
||||
// Shortcut
|
||||
var H = this._hash.words;
|
||||
|
||||
// Working variables
|
||||
var a = H[0];
|
||||
var b = H[1];
|
||||
var c = H[2];
|
||||
var d = H[3];
|
||||
var e = H[4];
|
||||
|
||||
// Computation
|
||||
for (var i = 0; i < 80; i++) {
|
||||
if (i < 16) {
|
||||
W[i] = M[offset + i] | 0;
|
||||
} else {
|
||||
var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16];
|
||||
W[i] = (n << 1) | (n >>> 31);
|
||||
}
|
||||
|
||||
var t = ((a << 5) | (a >>> 27)) + e + W[i];
|
||||
if (i < 20) {
|
||||
t += ((b & c) | (~b & d)) + 0x5a827999;
|
||||
} else if (i < 40) {
|
||||
t += (b ^ c ^ d) + 0x6ed9eba1;
|
||||
} else if (i < 60) {
|
||||
t += ((b & c) | (b & d) | (c & d)) - 0x70e44324;
|
||||
} else /* if (i < 80) */ {
|
||||
t += (b ^ c ^ d) - 0x359d3e2a;
|
||||
}
|
||||
|
||||
e = d;
|
||||
d = c;
|
||||
c = (b << 30) | (b >>> 2);
|
||||
b = a;
|
||||
a = t;
|
||||
}
|
||||
|
||||
// Intermediate hash value
|
||||
H[0] = (H[0] + a) | 0;
|
||||
H[1] = (H[1] + b) | 0;
|
||||
H[2] = (H[2] + c) | 0;
|
||||
H[3] = (H[3] + d) | 0;
|
||||
H[4] = (H[4] + e) | 0;
|
||||
},
|
||||
|
||||
_doFinalize: function () {
|
||||
// Shortcuts
|
||||
var data = this._data;
|
||||
var dataWords = data.words;
|
||||
|
||||
var nBitsTotal = this._nDataBytes * 8;
|
||||
var nBitsLeft = data.sigBytes * 8;
|
||||
|
||||
// Add padding
|
||||
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
||||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
|
||||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
|
||||
data.sigBytes = dataWords.length * 4;
|
||||
|
||||
// Hash final blocks
|
||||
this._process();
|
||||
|
||||
// Return final computed hash
|
||||
return this._hash;
|
||||
},
|
||||
|
||||
clone: function () {
|
||||
var clone = Hasher.clone.call(this);
|
||||
clone._hash = this._hash.clone();
|
||||
|
||||
return clone;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Shortcut function to the hasher's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
*
|
||||
* @return {WordArray} The hash.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hash = CryptoJS.SHA1('message');
|
||||
* var hash = CryptoJS.SHA1(wordArray);
|
||||
*/
|
||||
C.SHA1 = Hasher._createHelper(SHA1);
|
||||
|
||||
/**
|
||||
* Shortcut function to the HMAC's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
* @param {WordArray|string} key The secret key.
|
||||
*
|
||||
* @return {WordArray} The HMAC.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hmac = CryptoJS.HmacSHA1(message, key);
|
||||
*/
|
||||
C.HmacSHA1 = Hasher._createHmacHelper(SHA1);
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function (Math) {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var WordArray = C_lib.WordArray;
|
||||
var Hasher = C_lib.Hasher;
|
||||
var C_algo = C.algo;
|
||||
|
||||
// Initialization and round constants tables
|
||||
var H = [];
|
||||
var K = [];
|
||||
|
||||
// Compute constants
|
||||
(function () {
|
||||
function isPrime(n) {
|
||||
var sqrtN = Math.sqrt(n);
|
||||
for (var factor = 2; factor <= sqrtN; factor++) {
|
||||
if (!(n % factor)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getFractionalBits(n) {
|
||||
return ((n - (n | 0)) * 0x100000000) | 0;
|
||||
}
|
||||
|
||||
var n = 2;
|
||||
var nPrime = 0;
|
||||
while (nPrime < 64) {
|
||||
if (isPrime(n)) {
|
||||
if (nPrime < 8) {
|
||||
H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
|
||||
}
|
||||
K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
|
||||
|
||||
nPrime++;
|
||||
}
|
||||
|
||||
n++;
|
||||
}
|
||||
}());
|
||||
|
||||
// Reusable object
|
||||
var W = [];
|
||||
|
||||
/**
|
||||
* SHA-256 hash algorithm.
|
||||
*/
|
||||
var SHA256 = C_algo.SHA256 = Hasher.extend({
|
||||
_doReset: function () {
|
||||
this._hash = new WordArray.init(H.slice(0));
|
||||
},
|
||||
|
||||
_doProcessBlock: function (M, offset) {
|
||||
// Shortcut
|
||||
var H = this._hash.words;
|
||||
|
||||
// Working variables
|
||||
var a = H[0];
|
||||
var b = H[1];
|
||||
var c = H[2];
|
||||
var d = H[3];
|
||||
var e = H[4];
|
||||
var f = H[5];
|
||||
var g = H[6];
|
||||
var h = H[7];
|
||||
|
||||
// Computation
|
||||
for (var i = 0; i < 64; i++) {
|
||||
if (i < 16) {
|
||||
W[i] = M[offset + i] | 0;
|
||||
} else {
|
||||
var gamma0x = W[i - 15];
|
||||
var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
|
||||
((gamma0x << 14) | (gamma0x >>> 18)) ^
|
||||
(gamma0x >>> 3);
|
||||
|
||||
var gamma1x = W[i - 2];
|
||||
var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
|
||||
((gamma1x << 13) | (gamma1x >>> 19)) ^
|
||||
(gamma1x >>> 10);
|
||||
|
||||
W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
|
||||
}
|
||||
|
||||
var ch = (e & f) ^ (~e & g);
|
||||
var maj = (a & b) ^ (a & c) ^ (b & c);
|
||||
|
||||
var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
|
||||
var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
|
||||
|
||||
var t1 = h + sigma1 + ch + K[i] + W[i];
|
||||
var t2 = sigma0 + maj;
|
||||
|
||||
h = g;
|
||||
g = f;
|
||||
f = e;
|
||||
e = (d + t1) | 0;
|
||||
d = c;
|
||||
c = b;
|
||||
b = a;
|
||||
a = (t1 + t2) | 0;
|
||||
}
|
||||
|
||||
// Intermediate hash value
|
||||
H[0] = (H[0] + a) | 0;
|
||||
H[1] = (H[1] + b) | 0;
|
||||
H[2] = (H[2] + c) | 0;
|
||||
H[3] = (H[3] + d) | 0;
|
||||
H[4] = (H[4] + e) | 0;
|
||||
H[5] = (H[5] + f) | 0;
|
||||
H[6] = (H[6] + g) | 0;
|
||||
H[7] = (H[7] + h) | 0;
|
||||
},
|
||||
|
||||
_doFinalize: function () {
|
||||
// Shortcuts
|
||||
var data = this._data;
|
||||
var dataWords = data.words;
|
||||
|
||||
var nBitsTotal = this._nDataBytes * 8;
|
||||
var nBitsLeft = data.sigBytes * 8;
|
||||
|
||||
// Add padding
|
||||
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
||||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
|
||||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
|
||||
data.sigBytes = dataWords.length * 4;
|
||||
|
||||
// Hash final blocks
|
||||
this._process();
|
||||
|
||||
// Return final computed hash
|
||||
return this._hash;
|
||||
},
|
||||
|
||||
clone: function () {
|
||||
var clone = Hasher.clone.call(this);
|
||||
clone._hash = this._hash.clone();
|
||||
|
||||
return clone;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Shortcut function to the hasher's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
*
|
||||
* @return {WordArray} The hash.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hash = CryptoJS.SHA256('message');
|
||||
* var hash = CryptoJS.SHA256(wordArray);
|
||||
*/
|
||||
C.SHA256 = Hasher._createHelper(SHA256);
|
||||
|
||||
/**
|
||||
* Shortcut function to the HMAC's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
* @param {WordArray|string} key The secret key.
|
||||
*
|
||||
* @return {WordArray} The HMAC.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hmac = CryptoJS.HmacSHA256(message, key);
|
||||
*/
|
||||
C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
|
||||
}(Math));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var WordArray = C_lib.WordArray;
|
||||
var C_algo = C.algo;
|
||||
var SHA256 = C_algo.SHA256;
|
||||
|
||||
/**
|
||||
* SHA-224 hash algorithm.
|
||||
*/
|
||||
var SHA224 = C_algo.SHA224 = SHA256.extend({
|
||||
_doReset: function () {
|
||||
this._hash = new WordArray.init([
|
||||
0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
|
||||
0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
|
||||
]);
|
||||
},
|
||||
|
||||
_doFinalize: function () {
|
||||
var hash = SHA256._doFinalize.call(this);
|
||||
|
||||
hash.sigBytes -= 4;
|
||||
|
||||
return hash;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Shortcut function to the hasher's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
*
|
||||
* @return {WordArray} The hash.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hash = CryptoJS.SHA224('message');
|
||||
* var hash = CryptoJS.SHA224(wordArray);
|
||||
*/
|
||||
C.SHA224 = SHA256._createHelper(SHA224);
|
||||
|
||||
/**
|
||||
* Shortcut function to the HMAC's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
* @param {WordArray|string} key The secret key.
|
||||
*
|
||||
* @return {WordArray} The HMAC.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hmac = CryptoJS.HmacSHA224(message, key);
|
||||
*/
|
||||
C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var Hasher = C_lib.Hasher;
|
||||
var C_x64 = C.x64;
|
||||
var X64Word = C_x64.Word;
|
||||
var X64WordArray = C_x64.WordArray;
|
||||
var C_algo = C.algo;
|
||||
|
||||
function X64Word_create() {
|
||||
return X64Word.create.apply(X64Word, arguments);
|
||||
}
|
||||
|
||||
// Constants
|
||||
var K = [
|
||||
X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd),
|
||||
X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc),
|
||||
X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019),
|
||||
X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118),
|
||||
X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe),
|
||||
X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2),
|
||||
X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1),
|
||||
X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694),
|
||||
X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3),
|
||||
X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65),
|
||||
X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483),
|
||||
X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5),
|
||||
X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210),
|
||||
X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4),
|
||||
X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725),
|
||||
X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70),
|
||||
X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926),
|
||||
X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df),
|
||||
X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8),
|
||||
X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b),
|
||||
X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001),
|
||||
X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30),
|
||||
X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910),
|
||||
X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8),
|
||||
X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53),
|
||||
X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8),
|
||||
X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb),
|
||||
X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3),
|
||||
X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60),
|
||||
X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec),
|
||||
X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9),
|
||||
X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b),
|
||||
X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207),
|
||||
X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178),
|
||||
X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6),
|
||||
X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b),
|
||||
X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493),
|
||||
X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c),
|
||||
X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a),
|
||||
X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817)
|
||||
];
|
||||
|
||||
// Reusable objects
|
||||
var W = [];
|
||||
(function () {
|
||||
for (var i = 0; i < 80; i++) {
|
||||
W[i] = X64Word_create();
|
||||
}
|
||||
}());
|
||||
|
||||
/**
|
||||
* SHA-512 hash algorithm.
|
||||
*/
|
||||
var SHA512 = C_algo.SHA512 = Hasher.extend({
|
||||
_doReset: function () {
|
||||
this._hash = new X64WordArray.init([
|
||||
new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b),
|
||||
new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1),
|
||||
new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f),
|
||||
new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179)
|
||||
]);
|
||||
},
|
||||
|
||||
_doProcessBlock: function (M, offset) {
|
||||
// Shortcuts
|
||||
var H = this._hash.words;
|
||||
|
||||
var H0 = H[0];
|
||||
var H1 = H[1];
|
||||
var H2 = H[2];
|
||||
var H3 = H[3];
|
||||
var H4 = H[4];
|
||||
var H5 = H[5];
|
||||
var H6 = H[6];
|
||||
var H7 = H[7];
|
||||
|
||||
var H0h = H0.high;
|
||||
var H0l = H0.low;
|
||||
var H1h = H1.high;
|
||||
var H1l = H1.low;
|
||||
var H2h = H2.high;
|
||||
var H2l = H2.low;
|
||||
var H3h = H3.high;
|
||||
var H3l = H3.low;
|
||||
var H4h = H4.high;
|
||||
var H4l = H4.low;
|
||||
var H5h = H5.high;
|
||||
var H5l = H5.low;
|
||||
var H6h = H6.high;
|
||||
var H6l = H6.low;
|
||||
var H7h = H7.high;
|
||||
var H7l = H7.low;
|
||||
|
||||
// Working variables
|
||||
var ah = H0h;
|
||||
var al = H0l;
|
||||
var bh = H1h;
|
||||
var bl = H1l;
|
||||
var ch = H2h;
|
||||
var cl = H2l;
|
||||
var dh = H3h;
|
||||
var dl = H3l;
|
||||
var eh = H4h;
|
||||
var el = H4l;
|
||||
var fh = H5h;
|
||||
var fl = H5l;
|
||||
var gh = H6h;
|
||||
var gl = H6l;
|
||||
var hh = H7h;
|
||||
var hl = H7l;
|
||||
|
||||
// Rounds
|
||||
for (var i = 0; i < 80; i++) {
|
||||
var Wil;
|
||||
var Wih;
|
||||
|
||||
// Shortcut
|
||||
var Wi = W[i];
|
||||
|
||||
// Extend message
|
||||
if (i < 16) {
|
||||
Wih = Wi.high = M[offset + i * 2] | 0;
|
||||
Wil = Wi.low = M[offset + i * 2 + 1] | 0;
|
||||
} else {
|
||||
// Gamma0
|
||||
var gamma0x = W[i - 15];
|
||||
var gamma0xh = gamma0x.high;
|
||||
var gamma0xl = gamma0x.low;
|
||||
var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7);
|
||||
var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25));
|
||||
|
||||
// Gamma1
|
||||
var gamma1x = W[i - 2];
|
||||
var gamma1xh = gamma1x.high;
|
||||
var gamma1xl = gamma1x.low;
|
||||
var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6);
|
||||
var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26));
|
||||
|
||||
// W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]
|
||||
var Wi7 = W[i - 7];
|
||||
var Wi7h = Wi7.high;
|
||||
var Wi7l = Wi7.low;
|
||||
|
||||
var Wi16 = W[i - 16];
|
||||
var Wi16h = Wi16.high;
|
||||
var Wi16l = Wi16.low;
|
||||
|
||||
Wil = gamma0l + Wi7l;
|
||||
Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0);
|
||||
Wil = Wil + gamma1l;
|
||||
Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0);
|
||||
Wil = Wil + Wi16l;
|
||||
Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0);
|
||||
|
||||
Wi.high = Wih;
|
||||
Wi.low = Wil;
|
||||
}
|
||||
|
||||
var chh = (eh & fh) ^ (~eh & gh);
|
||||
var chl = (el & fl) ^ (~el & gl);
|
||||
var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch);
|
||||
var majl = (al & bl) ^ (al & cl) ^ (bl & cl);
|
||||
|
||||
var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7));
|
||||
var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7));
|
||||
var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9));
|
||||
var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9));
|
||||
|
||||
// t1 = h + sigma1 + ch + K[i] + W[i]
|
||||
var Ki = K[i];
|
||||
var Kih = Ki.high;
|
||||
var Kil = Ki.low;
|
||||
|
||||
var t1l = hl + sigma1l;
|
||||
var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0);
|
||||
var t1l = t1l + chl;
|
||||
var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0);
|
||||
var t1l = t1l + Kil;
|
||||
var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0);
|
||||
var t1l = t1l + Wil;
|
||||
var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0);
|
||||
|
||||
// t2 = sigma0 + maj
|
||||
var t2l = sigma0l + majl;
|
||||
var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0);
|
||||
|
||||
// Update working variables
|
||||
hh = gh;
|
||||
hl = gl;
|
||||
gh = fh;
|
||||
gl = fl;
|
||||
fh = eh;
|
||||
fl = el;
|
||||
el = (dl + t1l) | 0;
|
||||
eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0;
|
||||
dh = ch;
|
||||
dl = cl;
|
||||
ch = bh;
|
||||
cl = bl;
|
||||
bh = ah;
|
||||
bl = al;
|
||||
al = (t1l + t2l) | 0;
|
||||
ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0;
|
||||
}
|
||||
|
||||
// Intermediate hash value
|
||||
H0l = H0.low = (H0l + al);
|
||||
H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0));
|
||||
H1l = H1.low = (H1l + bl);
|
||||
H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0));
|
||||
H2l = H2.low = (H2l + cl);
|
||||
H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0));
|
||||
H3l = H3.low = (H3l + dl);
|
||||
H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0));
|
||||
H4l = H4.low = (H4l + el);
|
||||
H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0));
|
||||
H5l = H5.low = (H5l + fl);
|
||||
H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0));
|
||||
H6l = H6.low = (H6l + gl);
|
||||
H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0));
|
||||
H7l = H7.low = (H7l + hl);
|
||||
H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0));
|
||||
},
|
||||
|
||||
_doFinalize: function () {
|
||||
// Shortcuts
|
||||
var data = this._data;
|
||||
var dataWords = data.words;
|
||||
|
||||
var nBitsTotal = this._nDataBytes * 8;
|
||||
var nBitsLeft = data.sigBytes * 8;
|
||||
|
||||
// Add padding
|
||||
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
||||
dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000);
|
||||
dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal;
|
||||
data.sigBytes = dataWords.length * 4;
|
||||
|
||||
// Hash final blocks
|
||||
this._process();
|
||||
|
||||
// Convert hash to 32-bit word array before returning
|
||||
var hash = this._hash.toX32();
|
||||
|
||||
// Return final computed hash
|
||||
return hash;
|
||||
},
|
||||
|
||||
clone: function () {
|
||||
var clone = Hasher.clone.call(this);
|
||||
clone._hash = this._hash.clone();
|
||||
|
||||
return clone;
|
||||
},
|
||||
|
||||
blockSize: 1024/32
|
||||
});
|
||||
|
||||
/**
|
||||
* Shortcut function to the hasher's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
*
|
||||
* @return {WordArray} The hash.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hash = CryptoJS.SHA512('message');
|
||||
* var hash = CryptoJS.SHA512(wordArray);
|
||||
*/
|
||||
C.SHA512 = Hasher._createHelper(SHA512);
|
||||
|
||||
/**
|
||||
* Shortcut function to the HMAC's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
* @param {WordArray|string} key The secret key.
|
||||
*
|
||||
* @return {WordArray} The HMAC.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hmac = CryptoJS.HmacSHA512(message, key);
|
||||
*/
|
||||
C.HmacSHA512 = Hasher._createHmacHelper(SHA512);
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_x64 = C.x64;
|
||||
var X64Word = C_x64.Word;
|
||||
var X64WordArray = C_x64.WordArray;
|
||||
var C_algo = C.algo;
|
||||
var SHA512 = C_algo.SHA512;
|
||||
|
||||
/**
|
||||
* SHA-384 hash algorithm.
|
||||
*/
|
||||
var SHA384 = C_algo.SHA384 = SHA512.extend({
|
||||
_doReset: function () {
|
||||
this._hash = new X64WordArray.init([
|
||||
new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507),
|
||||
new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939),
|
||||
new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511),
|
||||
new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4)
|
||||
]);
|
||||
},
|
||||
|
||||
_doFinalize: function () {
|
||||
var hash = SHA512._doFinalize.call(this);
|
||||
|
||||
hash.sigBytes -= 16;
|
||||
|
||||
return hash;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Shortcut function to the hasher's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
*
|
||||
* @return {WordArray} The hash.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hash = CryptoJS.SHA384('message');
|
||||
* var hash = CryptoJS.SHA384(wordArray);
|
||||
*/
|
||||
C.SHA384 = SHA512._createHelper(SHA384);
|
||||
|
||||
/**
|
||||
* Shortcut function to the HMAC's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
* @param {WordArray|string} key The secret key.
|
||||
*
|
||||
* @return {WordArray} The HMAC.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hmac = CryptoJS.HmacSHA384(message, key);
|
||||
*/
|
||||
C.HmacSHA384 = SHA512._createHmacHelper(SHA384);
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function (Math) {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var WordArray = C_lib.WordArray;
|
||||
var Hasher = C_lib.Hasher;
|
||||
var C_x64 = C.x64;
|
||||
var X64Word = C_x64.Word;
|
||||
var C_algo = C.algo;
|
||||
|
||||
// Constants tables
|
||||
var RHO_OFFSETS = [];
|
||||
var PI_INDEXES = [];
|
||||
var ROUND_CONSTANTS = [];
|
||||
|
||||
// Compute Constants
|
||||
(function () {
|
||||
// Compute rho offset constants
|
||||
var x = 1, y = 0;
|
||||
for (var t = 0; t < 24; t++) {
|
||||
RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64;
|
||||
|
||||
var newX = y % 5;
|
||||
var newY = (2 * x + 3 * y) % 5;
|
||||
x = newX;
|
||||
y = newY;
|
||||
}
|
||||
|
||||
// Compute pi index constants
|
||||
for (var x = 0; x < 5; x++) {
|
||||
for (var y = 0; y < 5; y++) {
|
||||
PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5;
|
||||
}
|
||||
}
|
||||
|
||||
// Compute round constants
|
||||
var LFSR = 0x01;
|
||||
for (var i = 0; i < 24; i++) {
|
||||
var roundConstantMsw = 0;
|
||||
var roundConstantLsw = 0;
|
||||
|
||||
for (var j = 0; j < 7; j++) {
|
||||
if (LFSR & 0x01) {
|
||||
var bitPosition = (1 << j) - 1;
|
||||
if (bitPosition < 32) {
|
||||
roundConstantLsw ^= 1 << bitPosition;
|
||||
} else /* if (bitPosition >= 32) */ {
|
||||
roundConstantMsw ^= 1 << (bitPosition - 32);
|
||||
}
|
||||
}
|
||||
|
||||
// Compute next LFSR
|
||||
if (LFSR & 0x80) {
|
||||
// Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1
|
||||
LFSR = (LFSR << 1) ^ 0x71;
|
||||
} else {
|
||||
LFSR <<= 1;
|
||||
}
|
||||
}
|
||||
|
||||
ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw);
|
||||
}
|
||||
}());
|
||||
|
||||
// Reusable objects for temporary values
|
||||
var T = [];
|
||||
(function () {
|
||||
for (var i = 0; i < 25; i++) {
|
||||
T[i] = X64Word.create();
|
||||
}
|
||||
}());
|
||||
|
||||
/**
|
||||
* SHA-3 hash algorithm.
|
||||
*/
|
||||
var SHA3 = C_algo.SHA3 = Hasher.extend({
|
||||
/**
|
||||
* Configuration options.
|
||||
*
|
||||
* @property {number} outputLength
|
||||
* The desired number of bits in the output hash.
|
||||
* Only values permitted are: 224, 256, 384, 512.
|
||||
* Default: 512
|
||||
*/
|
||||
cfg: Hasher.cfg.extend({
|
||||
outputLength: 512
|
||||
}),
|
||||
|
||||
_doReset: function () {
|
||||
var state = this._state = []
|
||||
for (var i = 0; i < 25; i++) {
|
||||
state[i] = new X64Word.init();
|
||||
}
|
||||
|
||||
this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
|
||||
},
|
||||
|
||||
_doProcessBlock: function (M, offset) {
|
||||
// Shortcuts
|
||||
var state = this._state;
|
||||
var nBlockSizeLanes = this.blockSize / 2;
|
||||
|
||||
// Absorb
|
||||
for (var i = 0; i < nBlockSizeLanes; i++) {
|
||||
// Shortcuts
|
||||
var M2i = M[offset + 2 * i];
|
||||
var M2i1 = M[offset + 2 * i + 1];
|
||||
|
||||
// Swap endian
|
||||
M2i = (
|
||||
(((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) |
|
||||
(((M2i << 24) | (M2i >>> 8)) & 0xff00ff00)
|
||||
);
|
||||
M2i1 = (
|
||||
(((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) |
|
||||
(((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00)
|
||||
);
|
||||
|
||||
// Absorb message into state
|
||||
var lane = state[i];
|
||||
lane.high ^= M2i1;
|
||||
lane.low ^= M2i;
|
||||
}
|
||||
|
||||
// Rounds
|
||||
for (var round = 0; round < 24; round++) {
|
||||
// Theta
|
||||
for (var x = 0; x < 5; x++) {
|
||||
// Mix column lanes
|
||||
var tMsw = 0, tLsw = 0;
|
||||
for (var y = 0; y < 5; y++) {
|
||||
var lane = state[x + 5 * y];
|
||||
tMsw ^= lane.high;
|
||||
tLsw ^= lane.low;
|
||||
}
|
||||
|
||||
// Temporary values
|
||||
var Tx = T[x];
|
||||
Tx.high = tMsw;
|
||||
Tx.low = tLsw;
|
||||
}
|
||||
for (var x = 0; x < 5; x++) {
|
||||
// Shortcuts
|
||||
var Tx4 = T[(x + 4) % 5];
|
||||
var Tx1 = T[(x + 1) % 5];
|
||||
var Tx1Msw = Tx1.high;
|
||||
var Tx1Lsw = Tx1.low;
|
||||
|
||||
// Mix surrounding columns
|
||||
var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31));
|
||||
var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31));
|
||||
for (var y = 0; y < 5; y++) {
|
||||
var lane = state[x + 5 * y];
|
||||
lane.high ^= tMsw;
|
||||
lane.low ^= tLsw;
|
||||
}
|
||||
}
|
||||
|
||||
// Rho Pi
|
||||
for (var laneIndex = 1; laneIndex < 25; laneIndex++) {
|
||||
var tMsw;
|
||||
var tLsw;
|
||||
|
||||
// Shortcuts
|
||||
var lane = state[laneIndex];
|
||||
var laneMsw = lane.high;
|
||||
var laneLsw = lane.low;
|
||||
var rhoOffset = RHO_OFFSETS[laneIndex];
|
||||
|
||||
// Rotate lanes
|
||||
if (rhoOffset < 32) {
|
||||
tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset));
|
||||
tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset));
|
||||
} else /* if (rhoOffset >= 32) */ {
|
||||
tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset));
|
||||
tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset));
|
||||
}
|
||||
|
||||
// Transpose lanes
|
||||
var TPiLane = T[PI_INDEXES[laneIndex]];
|
||||
TPiLane.high = tMsw;
|
||||
TPiLane.low = tLsw;
|
||||
}
|
||||
|
||||
// Rho pi at x = y = 0
|
||||
var T0 = T[0];
|
||||
var state0 = state[0];
|
||||
T0.high = state0.high;
|
||||
T0.low = state0.low;
|
||||
|
||||
// Chi
|
||||
for (var x = 0; x < 5; x++) {
|
||||
for (var y = 0; y < 5; y++) {
|
||||
// Shortcuts
|
||||
var laneIndex = x + 5 * y;
|
||||
var lane = state[laneIndex];
|
||||
var TLane = T[laneIndex];
|
||||
var Tx1Lane = T[((x + 1) % 5) + 5 * y];
|
||||
var Tx2Lane = T[((x + 2) % 5) + 5 * y];
|
||||
|
||||
// Mix rows
|
||||
lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high);
|
||||
lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low);
|
||||
}
|
||||
}
|
||||
|
||||
// Iota
|
||||
var lane = state[0];
|
||||
var roundConstant = ROUND_CONSTANTS[round];
|
||||
lane.high ^= roundConstant.high;
|
||||
lane.low ^= roundConstant.low;
|
||||
}
|
||||
},
|
||||
|
||||
_doFinalize: function () {
|
||||
// Shortcuts
|
||||
var data = this._data;
|
||||
var dataWords = data.words;
|
||||
var nBitsTotal = this._nDataBytes * 8;
|
||||
var nBitsLeft = data.sigBytes * 8;
|
||||
var blockSizeBits = this.blockSize * 32;
|
||||
|
||||
// Add padding
|
||||
dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32);
|
||||
dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80;
|
||||
data.sigBytes = dataWords.length * 4;
|
||||
|
||||
// Hash final blocks
|
||||
this._process();
|
||||
|
||||
// Shortcuts
|
||||
var state = this._state;
|
||||
var outputLengthBytes = this.cfg.outputLength / 8;
|
||||
var outputLengthLanes = outputLengthBytes / 8;
|
||||
|
||||
// Squeeze
|
||||
var hashWords = [];
|
||||
for (var i = 0; i < outputLengthLanes; i++) {
|
||||
// Shortcuts
|
||||
var lane = state[i];
|
||||
var laneMsw = lane.high;
|
||||
var laneLsw = lane.low;
|
||||
|
||||
// Swap endian
|
||||
laneMsw = (
|
||||
(((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) |
|
||||
(((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00)
|
||||
);
|
||||
laneLsw = (
|
||||
(((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) |
|
||||
(((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00)
|
||||
);
|
||||
|
||||
// Squeeze state to retrieve hash
|
||||
hashWords.push(laneLsw);
|
||||
hashWords.push(laneMsw);
|
||||
}
|
||||
|
||||
// Return final computed hash
|
||||
return new WordArray.init(hashWords, outputLengthBytes);
|
||||
},
|
||||
|
||||
clone: function () {
|
||||
var clone = Hasher.clone.call(this);
|
||||
|
||||
var state = clone._state = this._state.slice(0);
|
||||
for (var i = 0; i < 25; i++) {
|
||||
state[i] = state[i].clone();
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Shortcut function to the hasher's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
*
|
||||
* @return {WordArray} The hash.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hash = CryptoJS.SHA3('message');
|
||||
* var hash = CryptoJS.SHA3(wordArray);
|
||||
*/
|
||||
C.SHA3 = Hasher._createHelper(SHA3);
|
||||
|
||||
/**
|
||||
* Shortcut function to the HMAC's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
* @param {WordArray|string} key The secret key.
|
||||
*
|
||||
* @return {WordArray} The HMAC.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hmac = CryptoJS.HmacSHA3(message, key);
|
||||
*/
|
||||
C.HmacSHA3 = Hasher._createHmacHelper(SHA3);
|
||||
}(Math));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** @preserve
|
||||
(c) 2012 by Cédric Mesnil. All rights reserved.
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
(function (Math) {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var WordArray = C_lib.WordArray;
|
||||
var Hasher = C_lib.Hasher;
|
||||
var C_algo = C.algo;
|
||||
|
||||
// Constants table
|
||||
var _zl = WordArray.create([
|
||||
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
|
||||
7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8,
|
||||
3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12,
|
||||
1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2,
|
||||
4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]);
|
||||
var _zr = WordArray.create([
|
||||
5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12,
|
||||
6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2,
|
||||
15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13,
|
||||
8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14,
|
||||
12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]);
|
||||
var _sl = WordArray.create([
|
||||
11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8,
|
||||
7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12,
|
||||
11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5,
|
||||
11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12,
|
||||
9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6 ]);
|
||||
var _sr = WordArray.create([
|
||||
8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6,
|
||||
9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11,
|
||||
9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5,
|
||||
15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8,
|
||||
8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11 ]);
|
||||
|
||||
var _hl = WordArray.create([ 0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]);
|
||||
var _hr = WordArray.create([ 0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]);
|
||||
|
||||
/**
|
||||
* RIPEMD160 hash algorithm.
|
||||
*/
|
||||
var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({
|
||||
_doReset: function () {
|
||||
this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]);
|
||||
},
|
||||
|
||||
_doProcessBlock: function (M, offset) {
|
||||
|
||||
// Swap endian
|
||||
for (var i = 0; i < 16; i++) {
|
||||
// Shortcuts
|
||||
var offset_i = offset + i;
|
||||
var M_offset_i = M[offset_i];
|
||||
|
||||
// Swap
|
||||
M[offset_i] = (
|
||||
(((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
|
||||
(((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
|
||||
);
|
||||
}
|
||||
// Shortcut
|
||||
var H = this._hash.words;
|
||||
var hl = _hl.words;
|
||||
var hr = _hr.words;
|
||||
var zl = _zl.words;
|
||||
var zr = _zr.words;
|
||||
var sl = _sl.words;
|
||||
var sr = _sr.words;
|
||||
|
||||
// Working variables
|
||||
var al, bl, cl, dl, el;
|
||||
var ar, br, cr, dr, er;
|
||||
|
||||
ar = al = H[0];
|
||||
br = bl = H[1];
|
||||
cr = cl = H[2];
|
||||
dr = dl = H[3];
|
||||
er = el = H[4];
|
||||
// Computation
|
||||
var t;
|
||||
for (var i = 0; i < 80; i += 1) {
|
||||
t = (al + M[offset+zl[i]])|0;
|
||||
if (i<16){
|
||||
t += f1(bl,cl,dl) + hl[0];
|
||||
} else if (i<32) {
|
||||
t += f2(bl,cl,dl) + hl[1];
|
||||
} else if (i<48) {
|
||||
t += f3(bl,cl,dl) + hl[2];
|
||||
} else if (i<64) {
|
||||
t += f4(bl,cl,dl) + hl[3];
|
||||
} else {// if (i<80) {
|
||||
t += f5(bl,cl,dl) + hl[4];
|
||||
}
|
||||
t = t|0;
|
||||
t = rotl(t,sl[i]);
|
||||
t = (t+el)|0;
|
||||
al = el;
|
||||
el = dl;
|
||||
dl = rotl(cl, 10);
|
||||
cl = bl;
|
||||
bl = t;
|
||||
|
||||
t = (ar + M[offset+zr[i]])|0;
|
||||
if (i<16){
|
||||
t += f5(br,cr,dr) + hr[0];
|
||||
} else if (i<32) {
|
||||
t += f4(br,cr,dr) + hr[1];
|
||||
} else if (i<48) {
|
||||
t += f3(br,cr,dr) + hr[2];
|
||||
} else if (i<64) {
|
||||
t += f2(br,cr,dr) + hr[3];
|
||||
} else {// if (i<80) {
|
||||
t += f1(br,cr,dr) + hr[4];
|
||||
}
|
||||
t = t|0;
|
||||
t = rotl(t,sr[i]) ;
|
||||
t = (t+er)|0;
|
||||
ar = er;
|
||||
er = dr;
|
||||
dr = rotl(cr, 10);
|
||||
cr = br;
|
||||
br = t;
|
||||
}
|
||||
// Intermediate hash value
|
||||
t = (H[1] + cl + dr)|0;
|
||||
H[1] = (H[2] + dl + er)|0;
|
||||
H[2] = (H[3] + el + ar)|0;
|
||||
H[3] = (H[4] + al + br)|0;
|
||||
H[4] = (H[0] + bl + cr)|0;
|
||||
H[0] = t;
|
||||
},
|
||||
|
||||
_doFinalize: function () {
|
||||
// Shortcuts
|
||||
var data = this._data;
|
||||
var dataWords = data.words;
|
||||
|
||||
var nBitsTotal = this._nDataBytes * 8;
|
||||
var nBitsLeft = data.sigBytes * 8;
|
||||
|
||||
// Add padding
|
||||
dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
||||
dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
|
||||
(((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
|
||||
(((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00)
|
||||
);
|
||||
data.sigBytes = (dataWords.length + 1) * 4;
|
||||
|
||||
// Hash final blocks
|
||||
this._process();
|
||||
|
||||
// Shortcuts
|
||||
var hash = this._hash;
|
||||
var H = hash.words;
|
||||
|
||||
// Swap endian
|
||||
for (var i = 0; i < 5; i++) {
|
||||
// Shortcut
|
||||
var H_i = H[i];
|
||||
|
||||
// Swap
|
||||
H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
|
||||
(((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
|
||||
}
|
||||
|
||||
// Return final computed hash
|
||||
return hash;
|
||||
},
|
||||
|
||||
clone: function () {
|
||||
var clone = Hasher.clone.call(this);
|
||||
clone._hash = this._hash.clone();
|
||||
|
||||
return clone;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function f1(x, y, z) {
|
||||
return ((x) ^ (y) ^ (z));
|
||||
|
||||
}
|
||||
|
||||
function f2(x, y, z) {
|
||||
return (((x)&(y)) | ((~x)&(z)));
|
||||
}
|
||||
|
||||
function f3(x, y, z) {
|
||||
return (((x) | (~(y))) ^ (z));
|
||||
}
|
||||
|
||||
function f4(x, y, z) {
|
||||
return (((x) & (z)) | ((y)&(~(z))));
|
||||
}
|
||||
|
||||
function f5(x, y, z) {
|
||||
return ((x) ^ ((y) |(~(z))));
|
||||
|
||||
}
|
||||
|
||||
function rotl(x,n) {
|
||||
return (x<<n) | (x>>>(32-n));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Shortcut function to the hasher's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
*
|
||||
* @return {WordArray} The hash.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hash = CryptoJS.RIPEMD160('message');
|
||||
* var hash = CryptoJS.RIPEMD160(wordArray);
|
||||
*/
|
||||
C.RIPEMD160 = Hasher._createHelper(RIPEMD160);
|
||||
|
||||
/**
|
||||
* Shortcut function to the HMAC's object interface.
|
||||
*
|
||||
* @param {WordArray|string} message The message to hash.
|
||||
* @param {WordArray|string} key The secret key.
|
||||
*
|
||||
* @return {WordArray} The HMAC.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hmac = CryptoJS.HmacRIPEMD160(message, key);
|
||||
*/
|
||||
C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160);
|
||||
}(Math));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var Base = C_lib.Base;
|
||||
var C_enc = C.enc;
|
||||
var Utf8 = C_enc.Utf8;
|
||||
var C_algo = C.algo;
|
||||
|
||||
/**
|
||||
* HMAC algorithm.
|
||||
*/
|
||||
var HMAC = C_algo.HMAC = Base.extend({
|
||||
/**
|
||||
* Initializes a newly created HMAC.
|
||||
*
|
||||
* @param {Hasher} hasher The hash algorithm to use.
|
||||
* @param {WordArray|string} key The secret key.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
|
||||
*/
|
||||
init: function (hasher, key) {
|
||||
// Init hasher
|
||||
hasher = this._hasher = new hasher.init();
|
||||
|
||||
// Convert string to WordArray, else assume WordArray already
|
||||
if (typeof key == 'string') {
|
||||
key = Utf8.parse(key);
|
||||
}
|
||||
|
||||
// Shortcuts
|
||||
var hasherBlockSize = hasher.blockSize;
|
||||
var hasherBlockSizeBytes = hasherBlockSize * 4;
|
||||
|
||||
// Allow arbitrary length keys
|
||||
if (key.sigBytes > hasherBlockSizeBytes) {
|
||||
key = hasher.finalize(key);
|
||||
}
|
||||
|
||||
// Clamp excess bits
|
||||
key.clamp();
|
||||
|
||||
// Clone key for inner and outer pads
|
||||
var oKey = this._oKey = key.clone();
|
||||
var iKey = this._iKey = key.clone();
|
||||
|
||||
// Shortcuts
|
||||
var oKeyWords = oKey.words;
|
||||
var iKeyWords = iKey.words;
|
||||
|
||||
// XOR keys with pad constants
|
||||
for (var i = 0; i < hasherBlockSize; i++) {
|
||||
oKeyWords[i] ^= 0x5c5c5c5c;
|
||||
iKeyWords[i] ^= 0x36363636;
|
||||
}
|
||||
oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes;
|
||||
|
||||
// Set initial values
|
||||
this.reset();
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets this HMAC to its initial state.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* hmacHasher.reset();
|
||||
*/
|
||||
reset: function () {
|
||||
// Shortcut
|
||||
var hasher = this._hasher;
|
||||
|
||||
// Reset
|
||||
hasher.reset();
|
||||
hasher.update(this._iKey);
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates this HMAC with a message.
|
||||
*
|
||||
* @param {WordArray|string} messageUpdate The message to append.
|
||||
*
|
||||
* @return {HMAC} This HMAC instance.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* hmacHasher.update('message');
|
||||
* hmacHasher.update(wordArray);
|
||||
*/
|
||||
update: function (messageUpdate) {
|
||||
this._hasher.update(messageUpdate);
|
||||
|
||||
// Chainable
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Finalizes the HMAC computation.
|
||||
* Note that the finalize operation is effectively a destructive, read-once operation.
|
||||
*
|
||||
* @param {WordArray|string} messageUpdate (Optional) A final message update.
|
||||
*
|
||||
* @return {WordArray} The HMAC.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hmac = hmacHasher.finalize();
|
||||
* var hmac = hmacHasher.finalize('message');
|
||||
* var hmac = hmacHasher.finalize(wordArray);
|
||||
*/
|
||||
finalize: function (messageUpdate) {
|
||||
// Shortcut
|
||||
var hasher = this._hasher;
|
||||
|
||||
// Compute HMAC
|
||||
var innerHash = hasher.finalize(messageUpdate);
|
||||
hasher.reset();
|
||||
var hmac = hasher.finalize(this._oKey.clone().concat(innerHash));
|
||||
|
||||
return hmac;
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var Base = C_lib.Base;
|
||||
var WordArray = C_lib.WordArray;
|
||||
var C_algo = C.algo;
|
||||
var SHA1 = C_algo.SHA1;
|
||||
var HMAC = C_algo.HMAC;
|
||||
|
||||
/**
|
||||
* Password-Based Key Derivation Function 2 algorithm.
|
||||
*/
|
||||
var PBKDF2 = C_algo.PBKDF2 = Base.extend({
|
||||
/**
|
||||
* Configuration options.
|
||||
*
|
||||
* @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
|
||||
* @property {Hasher} hasher The hasher to use. Default: SHA1
|
||||
* @property {number} iterations The number of iterations to perform. Default: 1
|
||||
*/
|
||||
cfg: Base.extend({
|
||||
keySize: 128/32,
|
||||
hasher: SHA1,
|
||||
iterations: 1
|
||||
}),
|
||||
|
||||
/**
|
||||
* Initializes a newly created key derivation function.
|
||||
*
|
||||
* @param {Object} cfg (Optional) The configuration options to use for the derivation.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var kdf = CryptoJS.algo.PBKDF2.create();
|
||||
* var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
|
||||
* var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
|
||||
*/
|
||||
init: function (cfg) {
|
||||
this.cfg = this.cfg.extend(cfg);
|
||||
},
|
||||
|
||||
/**
|
||||
* Computes the Password-Based Key Derivation Function 2.
|
||||
*
|
||||
* @param {WordArray|string} password The password.
|
||||
* @param {WordArray|string} salt A salt.
|
||||
*
|
||||
* @return {WordArray} The derived key.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var key = kdf.compute(password, salt);
|
||||
*/
|
||||
compute: function (password, salt) {
|
||||
// Shortcut
|
||||
var cfg = this.cfg;
|
||||
|
||||
// Init HMAC
|
||||
var hmac = HMAC.create(cfg.hasher, password);
|
||||
|
||||
// Initial values
|
||||
var derivedKey = WordArray.create();
|
||||
var blockIndex = WordArray.create([0x00000001]);
|
||||
|
||||
// Shortcuts
|
||||
var derivedKeyWords = derivedKey.words;
|
||||
var blockIndexWords = blockIndex.words;
|
||||
var keySize = cfg.keySize;
|
||||
var iterations = cfg.iterations;
|
||||
|
||||
// Generate key
|
||||
while (derivedKeyWords.length < keySize) {
|
||||
var block = hmac.update(salt).finalize(blockIndex);
|
||||
hmac.reset();
|
||||
|
||||
// Shortcuts
|
||||
var blockWords = block.words;
|
||||
var blockWordsLength = blockWords.length;
|
||||
|
||||
// Iterations
|
||||
var intermediate = block;
|
||||
for (var i = 1; i < iterations; i++) {
|
||||
intermediate = hmac.finalize(intermediate);
|
||||
hmac.reset();
|
||||
|
||||
// Shortcut
|
||||
var intermediateWords = intermediate.words;
|
||||
|
||||
// XOR intermediate with block
|
||||
for (var j = 0; j < blockWordsLength; j++) {
|
||||
blockWords[j] ^= intermediateWords[j];
|
||||
}
|
||||
}
|
||||
|
||||
derivedKey.concat(block);
|
||||
blockIndexWords[0]++;
|
||||
}
|
||||
derivedKey.sigBytes = keySize * 4;
|
||||
|
||||
return derivedKey;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Computes the Password-Based Key Derivation Function 2.
|
||||
*
|
||||
* @param {WordArray|string} password The password.
|
||||
* @param {WordArray|string} salt A salt.
|
||||
* @param {Object} cfg (Optional) The configuration options to use for this computation.
|
||||
*
|
||||
* @return {WordArray} The derived key.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var key = CryptoJS.PBKDF2(password, salt);
|
||||
* var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 });
|
||||
* var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 });
|
||||
*/
|
||||
C.PBKDF2 = function (password, salt, cfg) {
|
||||
return PBKDF2.create(cfg).compute(password, salt);
|
||||
};
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Cipher core components.
|
||||
*/
|
||||
CryptoJS.lib.Cipher || (function (undefined) {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var Base = C_lib.Base;
|
||||
var WordArray = C_lib.WordArray;
|
||||
var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
|
||||
var C_enc = C.enc;
|
||||
var Utf8 = C_enc.Utf8;
|
||||
var Base64 = C_enc.Base64;
|
||||
var C_algo = C.algo;
|
||||
var EvpKDF = C_algo.EvpKDF;
|
||||
|
||||
/**
|
||||
* Abstract base cipher template.
|
||||
*
|
||||
* @property {number} keySize This cipher's key size. Default: 4 (128 bits)
|
||||
* @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
|
||||
* @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
|
||||
* @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
|
||||
*/
|
||||
var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
|
||||
/**
|
||||
* Configuration options.
|
||||
*
|
||||
* @property {WordArray} iv The IV to use for this operation.
|
||||
*/
|
||||
cfg: Base.extend(),
|
||||
|
||||
/**
|
||||
* Creates this cipher in encryption mode.
|
||||
*
|
||||
* @param {WordArray} key The key.
|
||||
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
||||
*
|
||||
* @return {Cipher} A cipher instance.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
|
||||
*/
|
||||
createEncryptor: function (key, cfg) {
|
||||
return this.create(this._ENC_XFORM_MODE, key, cfg);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates this cipher in decryption mode.
|
||||
*
|
||||
* @param {WordArray} key The key.
|
||||
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
||||
*
|
||||
* @return {Cipher} A cipher instance.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
|
||||
*/
|
||||
createDecryptor: function (key, cfg) {
|
||||
return this.create(this._DEC_XFORM_MODE, key, cfg);
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes a newly created cipher.
|
||||
*
|
||||
* @param {number} xformMode Either the encryption or decryption transormation mode constant.
|
||||
* @param {WordArray} key The key.
|
||||
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
|
||||
*/
|
||||
init: function (xformMode, key, cfg) {
|
||||
// Apply config defaults
|
||||
this.cfg = this.cfg.extend(cfg);
|
||||
|
||||
// Store transform mode and key
|
||||
this._xformMode = xformMode;
|
||||
this._key = key;
|
||||
|
||||
// Set initial values
|
||||
this.reset();
|
||||
},
|
||||
|
||||
/**
|
||||
* Resets this cipher to its initial state.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* cipher.reset();
|
||||
*/
|
||||
reset: function () {
|
||||
// Reset data buffer
|
||||
BufferedBlockAlgorithm.reset.call(this);
|
||||
|
||||
// Perform concrete-cipher logic
|
||||
this._doReset();
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds data to be encrypted or decrypted.
|
||||
*
|
||||
* @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
|
||||
*
|
||||
* @return {WordArray} The data after processing.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var encrypted = cipher.process('data');
|
||||
* var encrypted = cipher.process(wordArray);
|
||||
*/
|
||||
process: function (dataUpdate) {
|
||||
// Append
|
||||
this._append(dataUpdate);
|
||||
|
||||
// Process available blocks
|
||||
return this._process();
|
||||
},
|
||||
|
||||
/**
|
||||
* Finalizes the encryption or decryption process.
|
||||
* Note that the finalize operation is effectively a destructive, read-once operation.
|
||||
*
|
||||
* @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
|
||||
*
|
||||
* @return {WordArray} The data after final processing.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var encrypted = cipher.finalize();
|
||||
* var encrypted = cipher.finalize('data');
|
||||
* var encrypted = cipher.finalize(wordArray);
|
||||
*/
|
||||
finalize: function (dataUpdate) {
|
||||
// Final data update
|
||||
if (dataUpdate) {
|
||||
this._append(dataUpdate);
|
||||
}
|
||||
|
||||
// Perform concrete-cipher logic
|
||||
var finalProcessedData = this._doFinalize();
|
||||
|
||||
return finalProcessedData;
|
||||
},
|
||||
|
||||
keySize: 128/32,
|
||||
|
||||
ivSize: 128/32,
|
||||
|
||||
_ENC_XFORM_MODE: 1,
|
||||
|
||||
_DEC_XFORM_MODE: 2,
|
||||
|
||||
/**
|
||||
* Creates shortcut functions to a cipher's object interface.
|
||||
*
|
||||
* @param {Cipher} cipher The cipher to create a helper for.
|
||||
*
|
||||
* @return {Object} An object with encrypt and decrypt shortcut functions.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
|
||||
*/
|
||||
_createHelper: (function () {
|
||||
function selectCipherStrategy(key) {
|
||||
if (typeof key == 'string') {
|
||||
return PasswordBasedCipher;
|
||||
} else {
|
||||
return SerializableCipher;
|
||||
}
|
||||
}
|
||||
|
||||
return function (cipher) {
|
||||
return {
|
||||
encrypt: function (message, key, cfg) {
|
||||
return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
|
||||
},
|
||||
|
||||
decrypt: function (ciphertext, key, cfg) {
|
||||
return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
|
||||
}
|
||||
};
|
||||
};
|
||||
}())
|
||||
});
|
||||
|
||||
/**
|
||||
* Abstract base stream cipher template.
|
||||
*
|
||||
* @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
|
||||
*/
|
||||
var StreamCipher = C_lib.StreamCipher = Cipher.extend({
|
||||
_doFinalize: function () {
|
||||
// Process partial blocks
|
||||
var finalProcessedBlocks = this._process(!!'flush');
|
||||
|
||||
return finalProcessedBlocks;
|
||||
},
|
||||
|
||||
blockSize: 1
|
||||
});
|
||||
|
||||
/**
|
||||
* Mode namespace.
|
||||
*/
|
||||
var C_mode = C.mode = {};
|
||||
|
||||
/**
|
||||
* Abstract base block cipher mode template.
|
||||
*/
|
||||
var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
|
||||
/**
|
||||
* Creates this mode for encryption.
|
||||
*
|
||||
* @param {Cipher} cipher A block cipher instance.
|
||||
* @param {Array} iv The IV words.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
|
||||
*/
|
||||
createEncryptor: function (cipher, iv) {
|
||||
return this.Encryptor.create(cipher, iv);
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates this mode for decryption.
|
||||
*
|
||||
* @param {Cipher} cipher A block cipher instance.
|
||||
* @param {Array} iv The IV words.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
|
||||
*/
|
||||
createDecryptor: function (cipher, iv) {
|
||||
return this.Decryptor.create(cipher, iv);
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes a newly created mode.
|
||||
*
|
||||
* @param {Cipher} cipher A block cipher instance.
|
||||
* @param {Array} iv The IV words.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
|
||||
*/
|
||||
init: function (cipher, iv) {
|
||||
this._cipher = cipher;
|
||||
this._iv = iv;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Cipher Block Chaining mode.
|
||||
*/
|
||||
var CBC = C_mode.CBC = (function () {
|
||||
/**
|
||||
* Abstract base CBC mode.
|
||||
*/
|
||||
var CBC = BlockCipherMode.extend();
|
||||
|
||||
/**
|
||||
* CBC encryptor.
|
||||
*/
|
||||
CBC.Encryptor = CBC.extend({
|
||||
/**
|
||||
* Processes the data block at offset.
|
||||
*
|
||||
* @param {Array} words The data words to operate on.
|
||||
* @param {number} offset The offset where the block starts.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* mode.processBlock(data.words, offset);
|
||||
*/
|
||||
processBlock: function (words, offset) {
|
||||
// Shortcuts
|
||||
var cipher = this._cipher;
|
||||
var blockSize = cipher.blockSize;
|
||||
|
||||
// XOR and encrypt
|
||||
xorBlock.call(this, words, offset, blockSize);
|
||||
cipher.encryptBlock(words, offset);
|
||||
|
||||
// Remember this block to use with next block
|
||||
this._prevBlock = words.slice(offset, offset + blockSize);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* CBC decryptor.
|
||||
*/
|
||||
CBC.Decryptor = CBC.extend({
|
||||
/**
|
||||
* Processes the data block at offset.
|
||||
*
|
||||
* @param {Array} words The data words to operate on.
|
||||
* @param {number} offset The offset where the block starts.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* mode.processBlock(data.words, offset);
|
||||
*/
|
||||
processBlock: function (words, offset) {
|
||||
// Shortcuts
|
||||
var cipher = this._cipher;
|
||||
var blockSize = cipher.blockSize;
|
||||
|
||||
// Remember this block to use with next block
|
||||
var thisBlock = words.slice(offset, offset + blockSize);
|
||||
|
||||
// Decrypt and XOR
|
||||
cipher.decryptBlock(words, offset);
|
||||
xorBlock.call(this, words, offset, blockSize);
|
||||
|
||||
// This block becomes the previous block
|
||||
this._prevBlock = thisBlock;
|
||||
}
|
||||
});
|
||||
|
||||
function xorBlock(words, offset, blockSize) {
|
||||
var block;
|
||||
|
||||
// Shortcut
|
||||
var iv = this._iv;
|
||||
|
||||
// Choose mixing block
|
||||
if (iv) {
|
||||
block = iv;
|
||||
|
||||
// Remove IV for subsequent blocks
|
||||
this._iv = undefined;
|
||||
} else {
|
||||
block = this._prevBlock;
|
||||
}
|
||||
|
||||
// XOR blocks
|
||||
for (var i = 0; i < blockSize; i++) {
|
||||
words[offset + i] ^= block[i];
|
||||
}
|
||||
}
|
||||
|
||||
return CBC;
|
||||
}());
|
||||
|
||||
/**
|
||||
* Padding namespace.
|
||||
*/
|
||||
var C_pad = C.pad = {};
|
||||
|
||||
/**
|
||||
* PKCS #5/7 padding strategy.
|
||||
*/
|
||||
var Pkcs7 = C_pad.Pkcs7 = {
|
||||
/**
|
||||
* Pads data using the algorithm defined in PKCS #5/7.
|
||||
*
|
||||
* @param {WordArray} data The data to pad.
|
||||
* @param {number} blockSize The multiple that the data should be padded to.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* CryptoJS.pad.Pkcs7.pad(wordArray, 4);
|
||||
*/
|
||||
pad: function (data, blockSize) {
|
||||
// Shortcut
|
||||
var blockSizeBytes = blockSize * 4;
|
||||
|
||||
// Count padding bytes
|
||||
var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
|
||||
|
||||
// Create padding word
|
||||
var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
|
||||
|
||||
// Create padding
|
||||
var paddingWords = [];
|
||||
for (var i = 0; i < nPaddingBytes; i += 4) {
|
||||
paddingWords.push(paddingWord);
|
||||
}
|
||||
var padding = WordArray.create(paddingWords, nPaddingBytes);
|
||||
|
||||
// Add padding
|
||||
data.concat(padding);
|
||||
},
|
||||
|
||||
/**
|
||||
* Unpads data that had been padded using the algorithm defined in PKCS #5/7.
|
||||
*
|
||||
* @param {WordArray} data The data to unpad.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* CryptoJS.pad.Pkcs7.unpad(wordArray);
|
||||
*/
|
||||
unpad: function (data) {
|
||||
// Get number of padding bytes from last byte
|
||||
var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
|
||||
|
||||
// Remove padding
|
||||
data.sigBytes -= nPaddingBytes;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Abstract base block cipher template.
|
||||
*
|
||||
* @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
|
||||
*/
|
||||
var BlockCipher = C_lib.BlockCipher = Cipher.extend({
|
||||
/**
|
||||
* Configuration options.
|
||||
*
|
||||
* @property {Mode} mode The block mode to use. Default: CBC
|
||||
* @property {Padding} padding The padding strategy to use. Default: Pkcs7
|
||||
*/
|
||||
cfg: Cipher.cfg.extend({
|
||||
mode: CBC,
|
||||
padding: Pkcs7
|
||||
}),
|
||||
|
||||
reset: function () {
|
||||
var modeCreator;
|
||||
|
||||
// Reset cipher
|
||||
Cipher.reset.call(this);
|
||||
|
||||
// Shortcuts
|
||||
var cfg = this.cfg;
|
||||
var iv = cfg.iv;
|
||||
var mode = cfg.mode;
|
||||
|
||||
// Reset block mode
|
||||
if (this._xformMode == this._ENC_XFORM_MODE) {
|
||||
modeCreator = mode.createEncryptor;
|
||||
} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
|
||||
modeCreator = mode.createDecryptor;
|
||||
// Keep at least one block in the buffer for unpadding
|
||||
this._minBufferSize = 1;
|
||||
}
|
||||
|
||||
if (this._mode && this._mode.__creator == modeCreator) {
|
||||
this._mode.init(this, iv && iv.words);
|
||||
} else {
|
||||
this._mode = modeCreator.call(mode, this, iv && iv.words);
|
||||
this._mode.__creator = modeCreator;
|
||||
}
|
||||
},
|
||||
|
||||
_doProcessBlock: function (words, offset) {
|
||||
this._mode.processBlock(words, offset);
|
||||
},
|
||||
|
||||
_doFinalize: function () {
|
||||
var finalProcessedBlocks;
|
||||
|
||||
// Shortcut
|
||||
var padding = this.cfg.padding;
|
||||
|
||||
// Finalize
|
||||
if (this._xformMode == this._ENC_XFORM_MODE) {
|
||||
// Pad data
|
||||
padding.pad(this._data, this.blockSize);
|
||||
|
||||
// Process final blocks
|
||||
finalProcessedBlocks = this._process(!!'flush');
|
||||
} else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
|
||||
// Process final blocks
|
||||
finalProcessedBlocks = this._process(!!'flush');
|
||||
|
||||
// Unpad data
|
||||
padding.unpad(finalProcessedBlocks);
|
||||
}
|
||||
|
||||
return finalProcessedBlocks;
|
||||
},
|
||||
|
||||
blockSize: 128/32
|
||||
});
|
||||
|
||||
/**
|
||||
* A collection of cipher parameters.
|
||||
*
|
||||
* @property {WordArray} ciphertext The raw ciphertext.
|
||||
* @property {WordArray} key The key to this ciphertext.
|
||||
* @property {WordArray} iv The IV used in the ciphering operation.
|
||||
* @property {WordArray} salt The salt used with a key derivation function.
|
||||
* @property {Cipher} algorithm The cipher algorithm.
|
||||
* @property {Mode} mode The block mode used in the ciphering operation.
|
||||
* @property {Padding} padding The padding scheme used in the ciphering operation.
|
||||
* @property {number} blockSize The block size of the cipher.
|
||||
* @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
|
||||
*/
|
||||
var CipherParams = C_lib.CipherParams = Base.extend({
|
||||
/**
|
||||
* Initializes a newly created cipher params object.
|
||||
*
|
||||
* @param {Object} cipherParams An object with any of the possible cipher parameters.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var cipherParams = CryptoJS.lib.CipherParams.create({
|
||||
* ciphertext: ciphertextWordArray,
|
||||
* key: keyWordArray,
|
||||
* iv: ivWordArray,
|
||||
* salt: saltWordArray,
|
||||
* algorithm: CryptoJS.algo.AES,
|
||||
* mode: CryptoJS.mode.CBC,
|
||||
* padding: CryptoJS.pad.PKCS7,
|
||||
* blockSize: 4,
|
||||
* formatter: CryptoJS.format.OpenSSL
|
||||
* });
|
||||
*/
|
||||
init: function (cipherParams) {
|
||||
this.mixIn(cipherParams);
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts this cipher params object to a string.
|
||||
*
|
||||
* @param {Format} formatter (Optional) The formatting strategy to use.
|
||||
*
|
||||
* @return {string} The stringified cipher params.
|
||||
*
|
||||
* @throws Error If neither the formatter nor the default formatter is set.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var string = cipherParams + '';
|
||||
* var string = cipherParams.toString();
|
||||
* var string = cipherParams.toString(CryptoJS.format.OpenSSL);
|
||||
*/
|
||||
toString: function (formatter) {
|
||||
return (formatter || this.formatter).stringify(this);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Format namespace.
|
||||
*/
|
||||
var C_format = C.format = {};
|
||||
|
||||
/**
|
||||
* OpenSSL formatting strategy.
|
||||
*/
|
||||
var OpenSSLFormatter = C_format.OpenSSL = {
|
||||
/**
|
||||
* Converts a cipher params object to an OpenSSL-compatible string.
|
||||
*
|
||||
* @param {CipherParams} cipherParams The cipher params object.
|
||||
*
|
||||
* @return {string} The OpenSSL-compatible string.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
|
||||
*/
|
||||
stringify: function (cipherParams) {
|
||||
var wordArray;
|
||||
|
||||
// Shortcuts
|
||||
var ciphertext = cipherParams.ciphertext;
|
||||
var salt = cipherParams.salt;
|
||||
|
||||
// Format
|
||||
if (salt) {
|
||||
wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
|
||||
} else {
|
||||
wordArray = ciphertext;
|
||||
}
|
||||
|
||||
return wordArray.toString(Base64);
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts an OpenSSL-compatible string to a cipher params object.
|
||||
*
|
||||
* @param {string} openSSLStr The OpenSSL-compatible string.
|
||||
*
|
||||
* @return {CipherParams} The cipher params object.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
|
||||
*/
|
||||
parse: function (openSSLStr) {
|
||||
var salt;
|
||||
|
||||
// Parse base64
|
||||
var ciphertext = Base64.parse(openSSLStr);
|
||||
|
||||
// Shortcut
|
||||
var ciphertextWords = ciphertext.words;
|
||||
|
||||
// Test for salt
|
||||
if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
|
||||
// Extract salt
|
||||
salt = WordArray.create(ciphertextWords.slice(2, 4));
|
||||
|
||||
// Remove salt from ciphertext
|
||||
ciphertextWords.splice(0, 4);
|
||||
ciphertext.sigBytes -= 16;
|
||||
}
|
||||
|
||||
return CipherParams.create({ ciphertext: ciphertext, salt: salt });
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A cipher wrapper that returns ciphertext as a serializable cipher params object.
|
||||
*/
|
||||
var SerializableCipher = C_lib.SerializableCipher = Base.extend({
|
||||
/**
|
||||
* Configuration options.
|
||||
*
|
||||
* @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
|
||||
*/
|
||||
cfg: Base.extend({
|
||||
format: OpenSSLFormatter
|
||||
}),
|
||||
|
||||
/**
|
||||
* Encrypts a message.
|
||||
*
|
||||
* @param {Cipher} cipher The cipher algorithm to use.
|
||||
* @param {WordArray|string} message The message to encrypt.
|
||||
* @param {WordArray} key The key.
|
||||
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
||||
*
|
||||
* @return {CipherParams} A cipher params object.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
|
||||
* var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
|
||||
* var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
||||
*/
|
||||
encrypt: function (cipher, message, key, cfg) {
|
||||
// Apply config defaults
|
||||
cfg = this.cfg.extend(cfg);
|
||||
|
||||
// Encrypt
|
||||
var encryptor = cipher.createEncryptor(key, cfg);
|
||||
var ciphertext = encryptor.finalize(message);
|
||||
|
||||
// Shortcut
|
||||
var cipherCfg = encryptor.cfg;
|
||||
|
||||
// Create and return serializable cipher params
|
||||
return CipherParams.create({
|
||||
ciphertext: ciphertext,
|
||||
key: key,
|
||||
iv: cipherCfg.iv,
|
||||
algorithm: cipher,
|
||||
mode: cipherCfg.mode,
|
||||
padding: cipherCfg.padding,
|
||||
blockSize: cipher.blockSize,
|
||||
formatter: cfg.format
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Decrypts serialized ciphertext.
|
||||
*
|
||||
* @param {Cipher} cipher The cipher algorithm to use.
|
||||
* @param {CipherParams|string} ciphertext The ciphertext to decrypt.
|
||||
* @param {WordArray} key The key.
|
||||
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
||||
*
|
||||
* @return {WordArray} The plaintext.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
||||
* var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
||||
*/
|
||||
decrypt: function (cipher, ciphertext, key, cfg) {
|
||||
// Apply config defaults
|
||||
cfg = this.cfg.extend(cfg);
|
||||
|
||||
// Convert string to CipherParams
|
||||
ciphertext = this._parse(ciphertext, cfg.format);
|
||||
|
||||
// Decrypt
|
||||
var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
|
||||
|
||||
return plaintext;
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts serialized ciphertext to CipherParams,
|
||||
* else assumed CipherParams already and returns ciphertext unchanged.
|
||||
*
|
||||
* @param {CipherParams|string} ciphertext The ciphertext.
|
||||
* @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
|
||||
*
|
||||
* @return {CipherParams} The unserialized ciphertext.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
|
||||
*/
|
||||
_parse: function (ciphertext, format) {
|
||||
if (typeof ciphertext == 'string') {
|
||||
return format.parse(ciphertext, this);
|
||||
} else {
|
||||
return ciphertext;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Key derivation function namespace.
|
||||
*/
|
||||
var C_kdf = C.kdf = {};
|
||||
|
||||
/**
|
||||
* OpenSSL key derivation function.
|
||||
*/
|
||||
var OpenSSLKdf = C_kdf.OpenSSL = {
|
||||
/**
|
||||
* Derives a key and IV from a password.
|
||||
*
|
||||
* @param {string} password The password to derive from.
|
||||
* @param {number} keySize The size in words of the key to generate.
|
||||
* @param {number} ivSize The size in words of the IV to generate.
|
||||
* @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
|
||||
*
|
||||
* @return {CipherParams} A cipher params object with the key, IV, and salt.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
|
||||
* var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
|
||||
*/
|
||||
execute: function (password, keySize, ivSize, salt) {
|
||||
// Generate random salt
|
||||
if (!salt) {
|
||||
salt = WordArray.random(64/8);
|
||||
}
|
||||
|
||||
// Derive key and IV
|
||||
var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
|
||||
|
||||
// Separate key and IV
|
||||
var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
|
||||
key.sigBytes = keySize * 4;
|
||||
|
||||
// Return params
|
||||
return CipherParams.create({ key: key, iv: iv, salt: salt });
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A serializable cipher wrapper that derives the key from a password,
|
||||
* and returns ciphertext as a serializable cipher params object.
|
||||
*/
|
||||
var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
|
||||
/**
|
||||
* Configuration options.
|
||||
*
|
||||
* @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
|
||||
*/
|
||||
cfg: SerializableCipher.cfg.extend({
|
||||
kdf: OpenSSLKdf
|
||||
}),
|
||||
|
||||
/**
|
||||
* Encrypts a message using a password.
|
||||
*
|
||||
* @param {Cipher} cipher The cipher algorithm to use.
|
||||
* @param {WordArray|string} message The message to encrypt.
|
||||
* @param {string} password The password.
|
||||
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
||||
*
|
||||
* @return {CipherParams} A cipher params object.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
|
||||
* var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
|
||||
*/
|
||||
encrypt: function (cipher, message, password, cfg) {
|
||||
// Apply config defaults
|
||||
cfg = this.cfg.extend(cfg);
|
||||
|
||||
// Derive key and other params
|
||||
var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
|
||||
|
||||
// Add IV to config
|
||||
cfg.iv = derivedParams.iv;
|
||||
|
||||
// Encrypt
|
||||
var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
|
||||
|
||||
// Mix in derived params
|
||||
ciphertext.mixIn(derivedParams);
|
||||
|
||||
return ciphertext;
|
||||
},
|
||||
|
||||
/**
|
||||
* Decrypts serialized ciphertext using a password.
|
||||
*
|
||||
* @param {Cipher} cipher The cipher algorithm to use.
|
||||
* @param {CipherParams|string} ciphertext The ciphertext to decrypt.
|
||||
* @param {string} password The password.
|
||||
* @param {Object} cfg (Optional) The configuration options to use for this operation.
|
||||
*
|
||||
* @return {WordArray} The plaintext.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
|
||||
* var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
|
||||
*/
|
||||
decrypt: function (cipher, ciphertext, password, cfg) {
|
||||
// Apply config defaults
|
||||
cfg = this.cfg.extend(cfg);
|
||||
|
||||
// Convert string to CipherParams
|
||||
ciphertext = this._parse(ciphertext, cfg.format);
|
||||
|
||||
// Derive key and other params
|
||||
var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
|
||||
|
||||
// Add IV to config
|
||||
cfg.iv = derivedParams.iv;
|
||||
|
||||
// Decrypt
|
||||
var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
|
||||
|
||||
return plaintext;
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Cipher Feedback block mode.
|
||||
*/
|
||||
CryptoJS.mode.CFB = (function () {
|
||||
var CFB = CryptoJS.lib.BlockCipherMode.extend();
|
||||
|
||||
CFB.Encryptor = CFB.extend({
|
||||
processBlock: function (words, offset) {
|
||||
// Shortcuts
|
||||
var cipher = this._cipher;
|
||||
var blockSize = cipher.blockSize;
|
||||
|
||||
generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
|
||||
|
||||
// Remember this block to use with next block
|
||||
this._prevBlock = words.slice(offset, offset + blockSize);
|
||||
}
|
||||
});
|
||||
|
||||
CFB.Decryptor = CFB.extend({
|
||||
processBlock: function (words, offset) {
|
||||
// Shortcuts
|
||||
var cipher = this._cipher;
|
||||
var blockSize = cipher.blockSize;
|
||||
|
||||
// Remember this block to use with next block
|
||||
var thisBlock = words.slice(offset, offset + blockSize);
|
||||
|
||||
generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher);
|
||||
|
||||
// This block becomes the previous block
|
||||
this._prevBlock = thisBlock;
|
||||
}
|
||||
});
|
||||
|
||||
function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) {
|
||||
var keystream;
|
||||
|
||||
// Shortcut
|
||||
var iv = this._iv;
|
||||
|
||||
// Generate keystream
|
||||
if (iv) {
|
||||
keystream = iv.slice(0);
|
||||
|
||||
// Remove IV for subsequent blocks
|
||||
this._iv = undefined;
|
||||
} else {
|
||||
keystream = this._prevBlock;
|
||||
}
|
||||
cipher.encryptBlock(keystream, 0);
|
||||
|
||||
// Encrypt
|
||||
for (var i = 0; i < blockSize; i++) {
|
||||
words[offset + i] ^= keystream[i];
|
||||
}
|
||||
}
|
||||
|
||||
return CFB;
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Counter block mode.
|
||||
*/
|
||||
CryptoJS.mode.CTR = (function () {
|
||||
var CTR = CryptoJS.lib.BlockCipherMode.extend();
|
||||
|
||||
var Encryptor = CTR.Encryptor = CTR.extend({
|
||||
processBlock: function (words, offset) {
|
||||
// Shortcuts
|
||||
var cipher = this._cipher
|
||||
var blockSize = cipher.blockSize;
|
||||
var iv = this._iv;
|
||||
var counter = this._counter;
|
||||
|
||||
// Generate keystream
|
||||
if (iv) {
|
||||
counter = this._counter = iv.slice(0);
|
||||
|
||||
// Remove IV for subsequent blocks
|
||||
this._iv = undefined;
|
||||
}
|
||||
var keystream = counter.slice(0);
|
||||
cipher.encryptBlock(keystream, 0);
|
||||
|
||||
// Increment counter
|
||||
counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0
|
||||
|
||||
// Encrypt
|
||||
for (var i = 0; i < blockSize; i++) {
|
||||
words[offset + i] ^= keystream[i];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CTR.Decryptor = Encryptor;
|
||||
|
||||
return CTR;
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/** @preserve
|
||||
* Counter block mode compatible with Dr Brian Gladman fileenc.c
|
||||
* derived from CryptoJS.mode.CTR
|
||||
* Jan Hruby [email protected]
|
||||
*/
|
||||
CryptoJS.mode.CTRGladman = (function () {
|
||||
var CTRGladman = CryptoJS.lib.BlockCipherMode.extend();
|
||||
|
||||
function incWord(word)
|
||||
{
|
||||
if (((word >> 24) & 0xff) === 0xff) { //overflow
|
||||
var b1 = (word >> 16)&0xff;
|
||||
var b2 = (word >> 8)&0xff;
|
||||
var b3 = word & 0xff;
|
||||
|
||||
if (b1 === 0xff) // overflow b1
|
||||
{
|
||||
b1 = 0;
|
||||
if (b2 === 0xff)
|
||||
{
|
||||
b2 = 0;
|
||||
if (b3 === 0xff)
|
||||
{
|
||||
b3 = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
++b3;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++b2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++b1;
|
||||
}
|
||||
|
||||
word = 0;
|
||||
word += (b1 << 16);
|
||||
word += (b2 << 8);
|
||||
word += b3;
|
||||
}
|
||||
else
|
||||
{
|
||||
word += (0x01 << 24);
|
||||
}
|
||||
return word;
|
||||
}
|
||||
|
||||
function incCounter(counter)
|
||||
{
|
||||
if ((counter[0] = incWord(counter[0])) === 0)
|
||||
{
|
||||
// encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8
|
||||
counter[1] = incWord(counter[1]);
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({
|
||||
processBlock: function (words, offset) {
|
||||
// Shortcuts
|
||||
var cipher = this._cipher
|
||||
var blockSize = cipher.blockSize;
|
||||
var iv = this._iv;
|
||||
var counter = this._counter;
|
||||
|
||||
// Generate keystream
|
||||
if (iv) {
|
||||
counter = this._counter = iv.slice(0);
|
||||
|
||||
// Remove IV for subsequent blocks
|
||||
this._iv = undefined;
|
||||
}
|
||||
|
||||
incCounter(counter);
|
||||
|
||||
var keystream = counter.slice(0);
|
||||
cipher.encryptBlock(keystream, 0);
|
||||
|
||||
// Encrypt
|
||||
for (var i = 0; i < blockSize; i++) {
|
||||
words[offset + i] ^= keystream[i];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CTRGladman.Decryptor = Encryptor;
|
||||
|
||||
return CTRGladman;
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Output Feedback block mode.
|
||||
*/
|
||||
CryptoJS.mode.OFB = (function () {
|
||||
var OFB = CryptoJS.lib.BlockCipherMode.extend();
|
||||
|
||||
var Encryptor = OFB.Encryptor = OFB.extend({
|
||||
processBlock: function (words, offset) {
|
||||
// Shortcuts
|
||||
var cipher = this._cipher
|
||||
var blockSize = cipher.blockSize;
|
||||
var iv = this._iv;
|
||||
var keystream = this._keystream;
|
||||
|
||||
// Generate keystream
|
||||
if (iv) {
|
||||
keystream = this._keystream = iv.slice(0);
|
||||
|
||||
// Remove IV for subsequent blocks
|
||||
this._iv = undefined;
|
||||
}
|
||||
cipher.encryptBlock(keystream, 0);
|
||||
|
||||
// Encrypt
|
||||
for (var i = 0; i < blockSize; i++) {
|
||||
words[offset + i] ^= keystream[i];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
OFB.Decryptor = Encryptor;
|
||||
|
||||
return OFB;
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Electronic Codebook block mode.
|
||||
*/
|
||||
CryptoJS.mode.ECB = (function () {
|
||||
var ECB = CryptoJS.lib.BlockCipherMode.extend();
|
||||
|
||||
ECB.Encryptor = ECB.extend({
|
||||
processBlock: function (words, offset) {
|
||||
this._cipher.encryptBlock(words, offset);
|
||||
}
|
||||
});
|
||||
|
||||
ECB.Decryptor = ECB.extend({
|
||||
processBlock: function (words, offset) {
|
||||
this._cipher.decryptBlock(words, offset);
|
||||
}
|
||||
});
|
||||
|
||||
return ECB;
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ANSI X.923 padding strategy.
|
||||
*/
|
||||
CryptoJS.pad.AnsiX923 = {
|
||||
pad: function (data, blockSize) {
|
||||
// Shortcuts
|
||||
var dataSigBytes = data.sigBytes;
|
||||
var blockSizeBytes = blockSize * 4;
|
||||
|
||||
// Count padding bytes
|
||||
var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes;
|
||||
|
||||
// Compute last byte position
|
||||
var lastBytePos = dataSigBytes + nPaddingBytes - 1;
|
||||
|
||||
// Pad
|
||||
data.clamp();
|
||||
data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8);
|
||||
data.sigBytes += nPaddingBytes;
|
||||
},
|
||||
|
||||
unpad: function (data) {
|
||||
// Get number of padding bytes from last byte
|
||||
var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
|
||||
|
||||
// Remove padding
|
||||
data.sigBytes -= nPaddingBytes;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ISO 10126 padding strategy.
|
||||
*/
|
||||
CryptoJS.pad.Iso10126 = {
|
||||
pad: function (data, blockSize) {
|
||||
// Shortcut
|
||||
var blockSizeBytes = blockSize * 4;
|
||||
|
||||
// Count padding bytes
|
||||
var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
|
||||
|
||||
// Pad
|
||||
data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).
|
||||
concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1));
|
||||
},
|
||||
|
||||
unpad: function (data) {
|
||||
// Get number of padding bytes from last byte
|
||||
var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
|
||||
|
||||
// Remove padding
|
||||
data.sigBytes -= nPaddingBytes;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ISO/IEC 9797-1 Padding Method 2.
|
||||
*/
|
||||
CryptoJS.pad.Iso97971 = {
|
||||
pad: function (data, blockSize) {
|
||||
// Add 0x80 byte
|
||||
data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1));
|
||||
|
||||
// Zero pad the rest
|
||||
CryptoJS.pad.ZeroPadding.pad(data, blockSize);
|
||||
},
|
||||
|
||||
unpad: function (data) {
|
||||
// Remove zero padding
|
||||
CryptoJS.pad.ZeroPadding.unpad(data);
|
||||
|
||||
// Remove one more byte -- the 0x80 byte
|
||||
data.sigBytes--;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Zero padding strategy.
|
||||
*/
|
||||
CryptoJS.pad.ZeroPadding = {
|
||||
pad: function (data, blockSize) {
|
||||
// Shortcut
|
||||
var blockSizeBytes = blockSize * 4;
|
||||
|
||||
// Pad
|
||||
data.clamp();
|
||||
data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes);
|
||||
},
|
||||
|
||||
unpad: function (data) {
|
||||
// Shortcut
|
||||
var dataWords = data.words;
|
||||
|
||||
// Unpad
|
||||
var i = data.sigBytes - 1;
|
||||
for (var i = data.sigBytes - 1; i >= 0; i--) {
|
||||
if (((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) {
|
||||
data.sigBytes = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A noop padding strategy.
|
||||
*/
|
||||
CryptoJS.pad.NoPadding = {
|
||||
pad: function () {
|
||||
},
|
||||
|
||||
unpad: function () {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
(function (undefined) {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var CipherParams = C_lib.CipherParams;
|
||||
var C_enc = C.enc;
|
||||
var Hex = C_enc.Hex;
|
||||
var C_format = C.format;
|
||||
|
||||
var HexFormatter = C_format.Hex = {
|
||||
/**
|
||||
* Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
|
||||
*
|
||||
* @param {CipherParams} cipherParams The cipher params object.
|
||||
*
|
||||
* @return {string} The hexadecimally encoded string.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var hexString = CryptoJS.format.Hex.stringify(cipherParams);
|
||||
*/
|
||||
stringify: function (cipherParams) {
|
||||
return cipherParams.ciphertext.toString(Hex);
|
||||
},
|
||||
|
||||
/**
|
||||
* Converts a hexadecimally encoded ciphertext string to a cipher params object.
|
||||
*
|
||||
* @param {string} input The hexadecimally encoded string.
|
||||
*
|
||||
* @return {CipherParams} The cipher params object.
|
||||
*
|
||||
* @static
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var cipherParams = CryptoJS.format.Hex.parse(hexString);
|
||||
*/
|
||||
parse: function (input) {
|
||||
var ciphertext = Hex.parse(input);
|
||||
return CipherParams.create({ ciphertext: ciphertext });
|
||||
}
|
||||
};
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var BlockCipher = C_lib.BlockCipher;
|
||||
var C_algo = C.algo;
|
||||
|
||||
// Lookup tables
|
||||
var SBOX = [];
|
||||
var INV_SBOX = [];
|
||||
var SUB_MIX_0 = [];
|
||||
var SUB_MIX_1 = [];
|
||||
var SUB_MIX_2 = [];
|
||||
var SUB_MIX_3 = [];
|
||||
var INV_SUB_MIX_0 = [];
|
||||
var INV_SUB_MIX_1 = [];
|
||||
var INV_SUB_MIX_2 = [];
|
||||
var INV_SUB_MIX_3 = [];
|
||||
|
||||
// Compute lookup tables
|
||||
(function () {
|
||||
// Compute double table
|
||||
var d = [];
|
||||
for (var i = 0; i < 256; i++) {
|
||||
if (i < 128) {
|
||||
d[i] = i << 1;
|
||||
} else {
|
||||
d[i] = (i << 1) ^ 0x11b;
|
||||
}
|
||||
}
|
||||
|
||||
// Walk GF(2^8)
|
||||
var x = 0;
|
||||
var xi = 0;
|
||||
for (var i = 0; i < 256; i++) {
|
||||
// Compute sbox
|
||||
var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
|
||||
sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
|
||||
SBOX[x] = sx;
|
||||
INV_SBOX[sx] = x;
|
||||
|
||||
// Compute multiplication
|
||||
var x2 = d[x];
|
||||
var x4 = d[x2];
|
||||
var x8 = d[x4];
|
||||
|
||||
// Compute sub bytes, mix columns tables
|
||||
var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
|
||||
SUB_MIX_0[x] = (t << 24) | (t >>> 8);
|
||||
SUB_MIX_1[x] = (t << 16) | (t >>> 16);
|
||||
SUB_MIX_2[x] = (t << 8) | (t >>> 24);
|
||||
SUB_MIX_3[x] = t;
|
||||
|
||||
// Compute inv sub bytes, inv mix columns tables
|
||||
var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
|
||||
INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
|
||||
INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
|
||||
INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
|
||||
INV_SUB_MIX_3[sx] = t;
|
||||
|
||||
// Compute next counter
|
||||
if (!x) {
|
||||
x = xi = 1;
|
||||
} else {
|
||||
x = x2 ^ d[d[d[x8 ^ x2]]];
|
||||
xi ^= d[d[xi]];
|
||||
}
|
||||
}
|
||||
}());
|
||||
|
||||
// Precomputed Rcon lookup
|
||||
var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
|
||||
|
||||
/**
|
||||
* AES block cipher algorithm.
|
||||
*/
|
||||
var AES = C_algo.AES = BlockCipher.extend({
|
||||
_doReset: function () {
|
||||
var t;
|
||||
|
||||
// Skip reset of nRounds has been set before and key did not change
|
||||
if (this._nRounds && this._keyPriorReset === this._key) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Shortcuts
|
||||
var key = this._keyPriorReset = this._key;
|
||||
var keyWords = key.words;
|
||||
var keySize = key.sigBytes / 4;
|
||||
|
||||
// Compute number of rounds
|
||||
var nRounds = this._nRounds = keySize + 6;
|
||||
|
||||
// Compute number of key schedule rows
|
||||
var ksRows = (nRounds + 1) * 4;
|
||||
|
||||
// Compute key schedule
|
||||
var keySchedule = this._keySchedule = [];
|
||||
for (var ksRow = 0; ksRow < ksRows; ksRow++) {
|
||||
if (ksRow < keySize) {
|
||||
keySchedule[ksRow] = keyWords[ksRow];
|
||||
} else {
|
||||
t = keySchedule[ksRow - 1];
|
||||
|
||||
if (!(ksRow % keySize)) {
|
||||
// Rot word
|
||||
t = (t << 8) | (t >>> 24);
|
||||
|
||||
// Sub word
|
||||
t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
|
||||
|
||||
// Mix Rcon
|
||||
t ^= RCON[(ksRow / keySize) | 0] << 24;
|
||||
} else if (keySize > 6 && ksRow % keySize == 4) {
|
||||
// Sub word
|
||||
t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
|
||||
}
|
||||
|
||||
keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
|
||||
}
|
||||
}
|
||||
|
||||
// Compute inv key schedule
|
||||
var invKeySchedule = this._invKeySchedule = [];
|
||||
for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
|
||||
var ksRow = ksRows - invKsRow;
|
||||
|
||||
if (invKsRow % 4) {
|
||||
var t = keySchedule[ksRow];
|
||||
} else {
|
||||
var t = keySchedule[ksRow - 4];
|
||||
}
|
||||
|
||||
if (invKsRow < 4 || ksRow <= 4) {
|
||||
invKeySchedule[invKsRow] = t;
|
||||
} else {
|
||||
invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
|
||||
INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
encryptBlock: function (M, offset) {
|
||||
this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
|
||||
},
|
||||
|
||||
decryptBlock: function (M, offset) {
|
||||
// Swap 2nd and 4th rows
|
||||
var t = M[offset + 1];
|
||||
M[offset + 1] = M[offset + 3];
|
||||
M[offset + 3] = t;
|
||||
|
||||
this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
|
||||
|
||||
// Inv swap 2nd and 4th rows
|
||||
var t = M[offset + 1];
|
||||
M[offset + 1] = M[offset + 3];
|
||||
M[offset + 3] = t;
|
||||
},
|
||||
|
||||
_doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
|
||||
// Shortcut
|
||||
var nRounds = this._nRounds;
|
||||
|
||||
// Get input, add round key
|
||||
var s0 = M[offset] ^ keySchedule[0];
|
||||
var s1 = M[offset + 1] ^ keySchedule[1];
|
||||
var s2 = M[offset + 2] ^ keySchedule[2];
|
||||
var s3 = M[offset + 3] ^ keySchedule[3];
|
||||
|
||||
// Key schedule row counter
|
||||
var ksRow = 4;
|
||||
|
||||
// Rounds
|
||||
for (var round = 1; round < nRounds; round++) {
|
||||
// Shift rows, sub bytes, mix columns, add round key
|
||||
var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
|
||||
var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
|
||||
var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
|
||||
var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
|
||||
|
||||
// Update state
|
||||
s0 = t0;
|
||||
s1 = t1;
|
||||
s2 = t2;
|
||||
s3 = t3;
|
||||
}
|
||||
|
||||
// Shift rows, sub bytes, add round key
|
||||
var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
|
||||
var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
|
||||
var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
|
||||
var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
|
||||
|
||||
// Set output
|
||||
M[offset] = t0;
|
||||
M[offset + 1] = t1;
|
||||
M[offset + 2] = t2;
|
||||
M[offset + 3] = t3;
|
||||
},
|
||||
|
||||
keySize: 256/32
|
||||
});
|
||||
|
||||
/**
|
||||
* Shortcut functions to the cipher's object interface.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
|
||||
* var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
|
||||
*/
|
||||
C.AES = BlockCipher._createHelper(AES);
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var WordArray = C_lib.WordArray;
|
||||
var BlockCipher = C_lib.BlockCipher;
|
||||
var C_algo = C.algo;
|
||||
|
||||
// Permuted Choice 1 constants
|
||||
var PC1 = [
|
||||
57, 49, 41, 33, 25, 17, 9, 1,
|
||||
58, 50, 42, 34, 26, 18, 10, 2,
|
||||
59, 51, 43, 35, 27, 19, 11, 3,
|
||||
60, 52, 44, 36, 63, 55, 47, 39,
|
||||
31, 23, 15, 7, 62, 54, 46, 38,
|
||||
30, 22, 14, 6, 61, 53, 45, 37,
|
||||
29, 21, 13, 5, 28, 20, 12, 4
|
||||
];
|
||||
|
||||
// Permuted Choice 2 constants
|
||||
var PC2 = [
|
||||
14, 17, 11, 24, 1, 5,
|
||||
3, 28, 15, 6, 21, 10,
|
||||
23, 19, 12, 4, 26, 8,
|
||||
16, 7, 27, 20, 13, 2,
|
||||
41, 52, 31, 37, 47, 55,
|
||||
30, 40, 51, 45, 33, 48,
|
||||
44, 49, 39, 56, 34, 53,
|
||||
46, 42, 50, 36, 29, 32
|
||||
];
|
||||
|
||||
// Cumulative bit shift constants
|
||||
var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28];
|
||||
|
||||
// SBOXes and round permutation constants
|
||||
var SBOX_P = [
|
||||
{
|
||||
0x0: 0x808200,
|
||||
0x10000000: 0x8000,
|
||||
0x20000000: 0x808002,
|
||||
0x30000000: 0x2,
|
||||
0x40000000: 0x200,
|
||||
0x50000000: 0x808202,
|
||||
0x60000000: 0x800202,
|
||||
0x70000000: 0x800000,
|
||||
0x80000000: 0x202,
|
||||
0x90000000: 0x800200,
|
||||
0xa0000000: 0x8200,
|
||||
0xb0000000: 0x808000,
|
||||
0xc0000000: 0x8002,
|
||||
0xd0000000: 0x800002,
|
||||
0xe0000000: 0x0,
|
||||
0xf0000000: 0x8202,
|
||||
0x8000000: 0x0,
|
||||
0x18000000: 0x808202,
|
||||
0x28000000: 0x8202,
|
||||
0x38000000: 0x8000,
|
||||
0x48000000: 0x808200,
|
||||
0x58000000: 0x200,
|
||||
0x68000000: 0x808002,
|
||||
0x78000000: 0x2,
|
||||
0x88000000: 0x800200,
|
||||
0x98000000: 0x8200,
|
||||
0xa8000000: 0x808000,
|
||||
0xb8000000: 0x800202,
|
||||
0xc8000000: 0x800002,
|
||||
0xd8000000: 0x8002,
|
||||
0xe8000000: 0x202,
|
||||
0xf8000000: 0x800000,
|
||||
0x1: 0x8000,
|
||||
0x10000001: 0x2,
|
||||
0x20000001: 0x808200,
|
||||
0x30000001: 0x800000,
|
||||
0x40000001: 0x808002,
|
||||
0x50000001: 0x8200,
|
||||
0x60000001: 0x200,
|
||||
0x70000001: 0x800202,
|
||||
0x80000001: 0x808202,
|
||||
0x90000001: 0x808000,
|
||||
0xa0000001: 0x800002,
|
||||
0xb0000001: 0x8202,
|
||||
0xc0000001: 0x202,
|
||||
0xd0000001: 0x800200,
|
||||
0xe0000001: 0x8002,
|
||||
0xf0000001: 0x0,
|
||||
0x8000001: 0x808202,
|
||||
0x18000001: 0x808000,
|
||||
0x28000001: 0x800000,
|
||||
0x38000001: 0x200,
|
||||
0x48000001: 0x8000,
|
||||
0x58000001: 0x800002,
|
||||
0x68000001: 0x2,
|
||||
0x78000001: 0x8202,
|
||||
0x88000001: 0x8002,
|
||||
0x98000001: 0x800202,
|
||||
0xa8000001: 0x202,
|
||||
0xb8000001: 0x808200,
|
||||
0xc8000001: 0x800200,
|
||||
0xd8000001: 0x0,
|
||||
0xe8000001: 0x8200,
|
||||
0xf8000001: 0x808002
|
||||
},
|
||||
{
|
||||
0x0: 0x40084010,
|
||||
0x1000000: 0x4000,
|
||||
0x2000000: 0x80000,
|
||||
0x3000000: 0x40080010,
|
||||
0x4000000: 0x40000010,
|
||||
0x5000000: 0x40084000,
|
||||
0x6000000: 0x40004000,
|
||||
0x7000000: 0x10,
|
||||
0x8000000: 0x84000,
|
||||
0x9000000: 0x40004010,
|
||||
0xa000000: 0x40000000,
|
||||
0xb000000: 0x84010,
|
||||
0xc000000: 0x80010,
|
||||
0xd000000: 0x0,
|
||||
0xe000000: 0x4010,
|
||||
0xf000000: 0x40080000,
|
||||
0x800000: 0x40004000,
|
||||
0x1800000: 0x84010,
|
||||
0x2800000: 0x10,
|
||||
0x3800000: 0x40004010,
|
||||
0x4800000: 0x40084010,
|
||||
0x5800000: 0x40000000,
|
||||
0x6800000: 0x80000,
|
||||
0x7800000: 0x40080010,
|
||||
0x8800000: 0x80010,
|
||||
0x9800000: 0x0,
|
||||
0xa800000: 0x4000,
|
||||
0xb800000: 0x40080000,
|
||||
0xc800000: 0x40000010,
|
||||
0xd800000: 0x84000,
|
||||
0xe800000: 0x40084000,
|
||||
0xf800000: 0x4010,
|
||||
0x10000000: 0x0,
|
||||
0x11000000: 0x40080010,
|
||||
0x12000000: 0x40004010,
|
||||
0x13000000: 0x40084000,
|
||||
0x14000000: 0x40080000,
|
||||
0x15000000: 0x10,
|
||||
0x16000000: 0x84010,
|
||||
0x17000000: 0x4000,
|
||||
0x18000000: 0x4010,
|
||||
0x19000000: 0x80000,
|
||||
0x1a000000: 0x80010,
|
||||
0x1b000000: 0x40000010,
|
||||
0x1c000000: 0x84000,
|
||||
0x1d000000: 0x40004000,
|
||||
0x1e000000: 0x40000000,
|
||||
0x1f000000: 0x40084010,
|
||||
0x10800000: 0x84010,
|
||||
0x11800000: 0x80000,
|
||||
0x12800000: 0x40080000,
|
||||
0x13800000: 0x4000,
|
||||
0x14800000: 0x40004000,
|
||||
0x15800000: 0x40084010,
|
||||
0x16800000: 0x10,
|
||||
0x17800000: 0x40000000,
|
||||
0x18800000: 0x40084000,
|
||||
0x19800000: 0x40000010,
|
||||
0x1a800000: 0x40004010,
|
||||
0x1b800000: 0x80010,
|
||||
0x1c800000: 0x0,
|
||||
0x1d800000: 0x4010,
|
||||
0x1e800000: 0x40080010,
|
||||
0x1f800000: 0x84000
|
||||
},
|
||||
{
|
||||
0x0: 0x104,
|
||||
0x100000: 0x0,
|
||||
0x200000: 0x4000100,
|
||||
0x300000: 0x10104,
|
||||
0x400000: 0x10004,
|
||||
0x500000: 0x4000004,
|
||||
0x600000: 0x4010104,
|
||||
0x700000: 0x4010000,
|
||||
0x800000: 0x4000000,
|
||||
0x900000: 0x4010100,
|
||||
0xa00000: 0x10100,
|
||||
0xb00000: 0x4010004,
|
||||
0xc00000: 0x4000104,
|
||||
0xd00000: 0x10000,
|
||||
0xe00000: 0x4,
|
||||
0xf00000: 0x100,
|
||||
0x80000: 0x4010100,
|
||||
0x180000: 0x4010004,
|
||||
0x280000: 0x0,
|
||||
0x380000: 0x4000100,
|
||||
0x480000: 0x4000004,
|
||||
0x580000: 0x10000,
|
||||
0x680000: 0x10004,
|
||||
0x780000: 0x104,
|
||||
0x880000: 0x4,
|
||||
0x980000: 0x100,
|
||||
0xa80000: 0x4010000,
|
||||
0xb80000: 0x10104,
|
||||
0xc80000: 0x10100,
|
||||
0xd80000: 0x4000104,
|
||||
0xe80000: 0x4010104,
|
||||
0xf80000: 0x4000000,
|
||||
0x1000000: 0x4010100,
|
||||
0x1100000: 0x10004,
|
||||
0x1200000: 0x10000,
|
||||
0x1300000: 0x4000100,
|
||||
0x1400000: 0x100,
|
||||
0x1500000: 0x4010104,
|
||||
0x1600000: 0x4000004,
|
||||
0x1700000: 0x0,
|
||||
0x1800000: 0x4000104,
|
||||
0x1900000: 0x4000000,
|
||||
0x1a00000: 0x4,
|
||||
0x1b00000: 0x10100,
|
||||
0x1c00000: 0x4010000,
|
||||
0x1d00000: 0x104,
|
||||
0x1e00000: 0x10104,
|
||||
0x1f00000: 0x4010004,
|
||||
0x1080000: 0x4000000,
|
||||
0x1180000: 0x104,
|
||||
0x1280000: 0x4010100,
|
||||
0x1380000: 0x0,
|
||||
0x1480000: 0x10004,
|
||||
0x1580000: 0x4000100,
|
||||
0x1680000: 0x100,
|
||||
0x1780000: 0x4010004,
|
||||
0x1880000: 0x10000,
|
||||
0x1980000: 0x4010104,
|
||||
0x1a80000: 0x10104,
|
||||
0x1b80000: 0x4000004,
|
||||
0x1c80000: 0x4000104,
|
||||
0x1d80000: 0x4010000,
|
||||
0x1e80000: 0x4,
|
||||
0x1f80000: 0x10100
|
||||
},
|
||||
{
|
||||
0x0: 0x80401000,
|
||||
0x10000: 0x80001040,
|
||||
0x20000: 0x401040,
|
||||
0x30000: 0x80400000,
|
||||
0x40000: 0x0,
|
||||
0x50000: 0x401000,
|
||||
0x60000: 0x80000040,
|
||||
0x70000: 0x400040,
|
||||
0x80000: 0x80000000,
|
||||
0x90000: 0x400000,
|
||||
0xa0000: 0x40,
|
||||
0xb0000: 0x80001000,
|
||||
0xc0000: 0x80400040,
|
||||
0xd0000: 0x1040,
|
||||
0xe0000: 0x1000,
|
||||
0xf0000: 0x80401040,
|
||||
0x8000: 0x80001040,
|
||||
0x18000: 0x40,
|
||||
0x28000: 0x80400040,
|
||||
0x38000: 0x80001000,
|
||||
0x48000: 0x401000,
|
||||
0x58000: 0x80401040,
|
||||
0x68000: 0x0,
|
||||
0x78000: 0x80400000,
|
||||
0x88000: 0x1000,
|
||||
0x98000: 0x80401000,
|
||||
0xa8000: 0x400000,
|
||||
0xb8000: 0x1040,
|
||||
0xc8000: 0x80000000,
|
||||
0xd8000: 0x400040,
|
||||
0xe8000: 0x401040,
|
||||
0xf8000: 0x80000040,
|
||||
0x100000: 0x400040,
|
||||
0x110000: 0x401000,
|
||||
0x120000: 0x80000040,
|
||||
0x130000: 0x0,
|
||||
0x140000: 0x1040,
|
||||
0x150000: 0x80400040,
|
||||
0x160000: 0x80401000,
|
||||
0x170000: 0x80001040,
|
||||
0x180000: 0x80401040,
|
||||
0x190000: 0x80000000,
|
||||
0x1a0000: 0x80400000,
|
||||
0x1b0000: 0x401040,
|
||||
0x1c0000: 0x80001000,
|
||||
0x1d0000: 0x400000,
|
||||
0x1e0000: 0x40,
|
||||
0x1f0000: 0x1000,
|
||||
0x108000: 0x80400000,
|
||||
0x118000: 0x80401040,
|
||||
0x128000: 0x0,
|
||||
0x138000: 0x401000,
|
||||
0x148000: 0x400040,
|
||||
0x158000: 0x80000000,
|
||||
0x168000: 0x80001040,
|
||||
0x178000: 0x40,
|
||||
0x188000: 0x80000040,
|
||||
0x198000: 0x1000,
|
||||
0x1a8000: 0x80001000,
|
||||
0x1b8000: 0x80400040,
|
||||
0x1c8000: 0x1040,
|
||||
0x1d8000: 0x80401000,
|
||||
0x1e8000: 0x400000,
|
||||
0x1f8000: 0x401040
|
||||
},
|
||||
{
|
||||
0x0: 0x80,
|
||||
0x1000: 0x1040000,
|
||||
0x2000: 0x40000,
|
||||
0x3000: 0x20000000,
|
||||
0x4000: 0x20040080,
|
||||
0x5000: 0x1000080,
|
||||
0x6000: 0x21000080,
|
||||
0x7000: 0x40080,
|
||||
0x8000: 0x1000000,
|
||||
0x9000: 0x20040000,
|
||||
0xa000: 0x20000080,
|
||||
0xb000: 0x21040080,
|
||||
0xc000: 0x21040000,
|
||||
0xd000: 0x0,
|
||||
0xe000: 0x1040080,
|
||||
0xf000: 0x21000000,
|
||||
0x800: 0x1040080,
|
||||
0x1800: 0x21000080,
|
||||
0x2800: 0x80,
|
||||
0x3800: 0x1040000,
|
||||
0x4800: 0x40000,
|
||||
0x5800: 0x20040080,
|
||||
0x6800: 0x21040000,
|
||||
0x7800: 0x20000000,
|
||||
0x8800: 0x20040000,
|
||||
0x9800: 0x0,
|
||||
0xa800: 0x21040080,
|
||||
0xb800: 0x1000080,
|
||||
0xc800: 0x20000080,
|
||||
0xd800: 0x21000000,
|
||||
0xe800: 0x1000000,
|
||||
0xf800: 0x40080,
|
||||
0x10000: 0x40000,
|
||||
0x11000: 0x80,
|
||||
0x12000: 0x20000000,
|
||||
0x13000: 0x21000080,
|
||||
0x14000: 0x1000080,
|
||||
0x15000: 0x21040000,
|
||||
0x16000: 0x20040080,
|
||||
0x17000: 0x1000000,
|
||||
0x18000: 0x21040080,
|
||||
0x19000: 0x21000000,
|
||||
0x1a000: 0x1040000,
|
||||
0x1b000: 0x20040000,
|
||||
0x1c000: 0x40080,
|
||||
0x1d000: 0x20000080,
|
||||
0x1e000: 0x0,
|
||||
0x1f000: 0x1040080,
|
||||
0x10800: 0x21000080,
|
||||
0x11800: 0x1000000,
|
||||
0x12800: 0x1040000,
|
||||
0x13800: 0x20040080,
|
||||
0x14800: 0x20000000,
|
||||
0x15800: 0x1040080,
|
||||
0x16800: 0x80,
|
||||
0x17800: 0x21040000,
|
||||
0x18800: 0x40080,
|
||||
0x19800: 0x21040080,
|
||||
0x1a800: 0x0,
|
||||
0x1b800: 0x21000000,
|
||||
0x1c800: 0x1000080,
|
||||
0x1d800: 0x40000,
|
||||
0x1e800: 0x20040000,
|
||||
0x1f800: 0x20000080
|
||||
},
|
||||
{
|
||||
0x0: 0x10000008,
|
||||
0x100: 0x2000,
|
||||
0x200: 0x10200000,
|
||||
0x300: 0x10202008,
|
||||
0x400: 0x10002000,
|
||||
0x500: 0x200000,
|
||||
0x600: 0x200008,
|
||||
0x700: 0x10000000,
|
||||
0x800: 0x0,
|
||||
0x900: 0x10002008,
|
||||
0xa00: 0x202000,
|
||||
0xb00: 0x8,
|
||||
0xc00: 0x10200008,
|
||||
0xd00: 0x202008,
|
||||
0xe00: 0x2008,
|
||||
0xf00: 0x10202000,
|
||||
0x80: 0x10200000,
|
||||
0x180: 0x10202008,
|
||||
0x280: 0x8,
|
||||
0x380: 0x200000,
|
||||
0x480: 0x202008,
|
||||
0x580: 0x10000008,
|
||||
0x680: 0x10002000,
|
||||
0x780: 0x2008,
|
||||
0x880: 0x200008,
|
||||
0x980: 0x2000,
|
||||
0xa80: 0x10002008,
|
||||
0xb80: 0x10200008,
|
||||
0xc80: 0x0,
|
||||
0xd80: 0x10202000,
|
||||
0xe80: 0x202000,
|
||||
0xf80: 0x10000000,
|
||||
0x1000: 0x10002000,
|
||||
0x1100: 0x10200008,
|
||||
0x1200: 0x10202008,
|
||||
0x1300: 0x2008,
|
||||
0x1400: 0x200000,
|
||||
0x1500: 0x10000000,
|
||||
0x1600: 0x10000008,
|
||||
0x1700: 0x202000,
|
||||
0x1800: 0x202008,
|
||||
0x1900: 0x0,
|
||||
0x1a00: 0x8,
|
||||
0x1b00: 0x10200000,
|
||||
0x1c00: 0x2000,
|
||||
0x1d00: 0x10002008,
|
||||
0x1e00: 0x10202000,
|
||||
0x1f00: 0x200008,
|
||||
0x1080: 0x8,
|
||||
0x1180: 0x202000,
|
||||
0x1280: 0x200000,
|
||||
0x1380: 0x10000008,
|
||||
0x1480: 0x10002000,
|
||||
0x1580: 0x2008,
|
||||
0x1680: 0x10202008,
|
||||
0x1780: 0x10200000,
|
||||
0x1880: 0x10202000,
|
||||
0x1980: 0x10200008,
|
||||
0x1a80: 0x2000,
|
||||
0x1b80: 0x202008,
|
||||
0x1c80: 0x200008,
|
||||
0x1d80: 0x0,
|
||||
0x1e80: 0x10000000,
|
||||
0x1f80: 0x10002008
|
||||
},
|
||||
{
|
||||
0x0: 0x100000,
|
||||
0x10: 0x2000401,
|
||||
0x20: 0x400,
|
||||
0x30: 0x100401,
|
||||
0x40: 0x2100401,
|
||||
0x50: 0x0,
|
||||
0x60: 0x1,
|
||||
0x70: 0x2100001,
|
||||
0x80: 0x2000400,
|
||||
0x90: 0x100001,
|
||||
0xa0: 0x2000001,
|
||||
0xb0: 0x2100400,
|
||||
0xc0: 0x2100000,
|
||||
0xd0: 0x401,
|
||||
0xe0: 0x100400,
|
||||
0xf0: 0x2000000,
|
||||
0x8: 0x2100001,
|
||||
0x18: 0x0,
|
||||
0x28: 0x2000401,
|
||||
0x38: 0x2100400,
|
||||
0x48: 0x100000,
|
||||
0x58: 0x2000001,
|
||||
0x68: 0x2000000,
|
||||
0x78: 0x401,
|
||||
0x88: 0x100401,
|
||||
0x98: 0x2000400,
|
||||
0xa8: 0x2100000,
|
||||
0xb8: 0x100001,
|
||||
0xc8: 0x400,
|
||||
0xd8: 0x2100401,
|
||||
0xe8: 0x1,
|
||||
0xf8: 0x100400,
|
||||
0x100: 0x2000000,
|
||||
0x110: 0x100000,
|
||||
0x120: 0x2000401,
|
||||
0x130: 0x2100001,
|
||||
0x140: 0x100001,
|
||||
0x150: 0x2000400,
|
||||
0x160: 0x2100400,
|
||||
0x170: 0x100401,
|
||||
0x180: 0x401,
|
||||
0x190: 0x2100401,
|
||||
0x1a0: 0x100400,
|
||||
0x1b0: 0x1,
|
||||
0x1c0: 0x0,
|
||||
0x1d0: 0x2100000,
|
||||
0x1e0: 0x2000001,
|
||||
0x1f0: 0x400,
|
||||
0x108: 0x100400,
|
||||
0x118: 0x2000401,
|
||||
0x128: 0x2100001,
|
||||
0x138: 0x1,
|
||||
0x148: 0x2000000,
|
||||
0x158: 0x100000,
|
||||
0x168: 0x401,
|
||||
0x178: 0x2100400,
|
||||
0x188: 0x2000001,
|
||||
0x198: 0x2100000,
|
||||
0x1a8: 0x0,
|
||||
0x1b8: 0x2100401,
|
||||
0x1c8: 0x100401,
|
||||
0x1d8: 0x400,
|
||||
0x1e8: 0x2000400,
|
||||
0x1f8: 0x100001
|
||||
},
|
||||
{
|
||||
0x0: 0x8000820,
|
||||
0x1: 0x20000,
|
||||
0x2: 0x8000000,
|
||||
0x3: 0x20,
|
||||
0x4: 0x20020,
|
||||
0x5: 0x8020820,
|
||||
0x6: 0x8020800,
|
||||
0x7: 0x800,
|
||||
0x8: 0x8020000,
|
||||
0x9: 0x8000800,
|
||||
0xa: 0x20800,
|
||||
0xb: 0x8020020,
|
||||
0xc: 0x820,
|
||||
0xd: 0x0,
|
||||
0xe: 0x8000020,
|
||||
0xf: 0x20820,
|
||||
0x80000000: 0x800,
|
||||
0x80000001: 0x8020820,
|
||||
0x80000002: 0x8000820,
|
||||
0x80000003: 0x8000000,
|
||||
0x80000004: 0x8020000,
|
||||
0x80000005: 0x20800,
|
||||
0x80000006: 0x20820,
|
||||
0x80000007: 0x20,
|
||||
0x80000008: 0x8000020,
|
||||
0x80000009: 0x820,
|
||||
0x8000000a: 0x20020,
|
||||
0x8000000b: 0x8020800,
|
||||
0x8000000c: 0x0,
|
||||
0x8000000d: 0x8020020,
|
||||
0x8000000e: 0x8000800,
|
||||
0x8000000f: 0x20000,
|
||||
0x10: 0x20820,
|
||||
0x11: 0x8020800,
|
||||
0x12: 0x20,
|
||||
0x13: 0x800,
|
||||
0x14: 0x8000800,
|
||||
0x15: 0x8000020,
|
||||
0x16: 0x8020020,
|
||||
0x17: 0x20000,
|
||||
0x18: 0x0,
|
||||
0x19: 0x20020,
|
||||
0x1a: 0x8020000,
|
||||
0x1b: 0x8000820,
|
||||
0x1c: 0x8020820,
|
||||
0x1d: 0x20800,
|
||||
0x1e: 0x820,
|
||||
0x1f: 0x8000000,
|
||||
0x80000010: 0x20000,
|
||||
0x80000011: 0x800,
|
||||
0x80000012: 0x8020020,
|
||||
0x80000013: 0x20820,
|
||||
0x80000014: 0x20,
|
||||
0x80000015: 0x8020000,
|
||||
0x80000016: 0x8000000,
|
||||
0x80000017: 0x8000820,
|
||||
0x80000018: 0x8020820,
|
||||
0x80000019: 0x8000020,
|
||||
0x8000001a: 0x8000800,
|
||||
0x8000001b: 0x0,
|
||||
0x8000001c: 0x20800,
|
||||
0x8000001d: 0x820,
|
||||
0x8000001e: 0x20020,
|
||||
0x8000001f: 0x8020800
|
||||
}
|
||||
];
|
||||
|
||||
// Masks that select the SBOX input
|
||||
var SBOX_MASK = [
|
||||
0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000,
|
||||
0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f
|
||||
];
|
||||
|
||||
/**
|
||||
* DES block cipher algorithm.
|
||||
*/
|
||||
var DES = C_algo.DES = BlockCipher.extend({
|
||||
_doReset: function () {
|
||||
// Shortcuts
|
||||
var key = this._key;
|
||||
var keyWords = key.words;
|
||||
|
||||
// Select 56 bits according to PC1
|
||||
var keyBits = [];
|
||||
for (var i = 0; i < 56; i++) {
|
||||
var keyBitPos = PC1[i] - 1;
|
||||
keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1;
|
||||
}
|
||||
|
||||
// Assemble 16 subkeys
|
||||
var subKeys = this._subKeys = [];
|
||||
for (var nSubKey = 0; nSubKey < 16; nSubKey++) {
|
||||
// Create subkey
|
||||
var subKey = subKeys[nSubKey] = [];
|
||||
|
||||
// Shortcut
|
||||
var bitShift = BIT_SHIFTS[nSubKey];
|
||||
|
||||
// Select 48 bits according to PC2
|
||||
for (var i = 0; i < 24; i++) {
|
||||
// Select from the left 28 key bits
|
||||
subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6);
|
||||
|
||||
// Select from the right 28 key bits
|
||||
subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6);
|
||||
}
|
||||
|
||||
// Since each subkey is applied to an expanded 32-bit input,
|
||||
// the subkey can be broken into 8 values scaled to 32-bits,
|
||||
// which allows the key to be used without expansion
|
||||
subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31);
|
||||
for (var i = 1; i < 7; i++) {
|
||||
subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3);
|
||||
}
|
||||
subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27);
|
||||
}
|
||||
|
||||
// Compute inverse subkeys
|
||||
var invSubKeys = this._invSubKeys = [];
|
||||
for (var i = 0; i < 16; i++) {
|
||||
invSubKeys[i] = subKeys[15 - i];
|
||||
}
|
||||
},
|
||||
|
||||
encryptBlock: function (M, offset) {
|
||||
this._doCryptBlock(M, offset, this._subKeys);
|
||||
},
|
||||
|
||||
decryptBlock: function (M, offset) {
|
||||
this._doCryptBlock(M, offset, this._invSubKeys);
|
||||
},
|
||||
|
||||
_doCryptBlock: function (M, offset, subKeys) {
|
||||
// Get input
|
||||
this._lBlock = M[offset];
|
||||
this._rBlock = M[offset + 1];
|
||||
|
||||
// Initial permutation
|
||||
exchangeLR.call(this, 4, 0x0f0f0f0f);
|
||||
exchangeLR.call(this, 16, 0x0000ffff);
|
||||
exchangeRL.call(this, 2, 0x33333333);
|
||||
exchangeRL.call(this, 8, 0x00ff00ff);
|
||||
exchangeLR.call(this, 1, 0x55555555);
|
||||
|
||||
// Rounds
|
||||
for (var round = 0; round < 16; round++) {
|
||||
// Shortcuts
|
||||
var subKey = subKeys[round];
|
||||
var lBlock = this._lBlock;
|
||||
var rBlock = this._rBlock;
|
||||
|
||||
// Feistel function
|
||||
var f = 0;
|
||||
for (var i = 0; i < 8; i++) {
|
||||
f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0];
|
||||
}
|
||||
this._lBlock = rBlock;
|
||||
this._rBlock = lBlock ^ f;
|
||||
}
|
||||
|
||||
// Undo swap from last round
|
||||
var t = this._lBlock;
|
||||
this._lBlock = this._rBlock;
|
||||
this._rBlock = t;
|
||||
|
||||
// Final permutation
|
||||
exchangeLR.call(this, 1, 0x55555555);
|
||||
exchangeRL.call(this, 8, 0x00ff00ff);
|
||||
exchangeRL.call(this, 2, 0x33333333);
|
||||
exchangeLR.call(this, 16, 0x0000ffff);
|
||||
exchangeLR.call(this, 4, 0x0f0f0f0f);
|
||||
|
||||
// Set output
|
||||
M[offset] = this._lBlock;
|
||||
M[offset + 1] = this._rBlock;
|
||||
},
|
||||
|
||||
keySize: 64/32,
|
||||
|
||||
ivSize: 64/32,
|
||||
|
||||
blockSize: 64/32
|
||||
});
|
||||
|
||||
// Swap bits across the left and right words
|
||||
function exchangeLR(offset, mask) {
|
||||
var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask;
|
||||
this._rBlock ^= t;
|
||||
this._lBlock ^= t << offset;
|
||||
}
|
||||
|
||||
function exchangeRL(offset, mask) {
|
||||
var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask;
|
||||
this._lBlock ^= t;
|
||||
this._rBlock ^= t << offset;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut functions to the cipher's object interface.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var ciphertext = CryptoJS.DES.encrypt(message, key, cfg);
|
||||
* var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg);
|
||||
*/
|
||||
C.DES = BlockCipher._createHelper(DES);
|
||||
|
||||
/**
|
||||
* Triple-DES block cipher algorithm.
|
||||
*/
|
||||
var TripleDES = C_algo.TripleDES = BlockCipher.extend({
|
||||
_doReset: function () {
|
||||
// Shortcuts
|
||||
var key = this._key;
|
||||
var keyWords = key.words;
|
||||
// Make sure the key length is valid (64, 128 or >= 192 bit)
|
||||
if (keyWords.length !== 2 && keyWords.length !== 4 && keyWords.length < 6) {
|
||||
throw new Error('Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.');
|
||||
}
|
||||
|
||||
// Extend the key according to the keying options defined in 3DES standard
|
||||
var key1 = keyWords.slice(0, 2);
|
||||
var key2 = keyWords.length < 4 ? keyWords.slice(0, 2) : keyWords.slice(2, 4);
|
||||
var key3 = keyWords.length < 6 ? keyWords.slice(0, 2) : keyWords.slice(4, 6);
|
||||
|
||||
// Create DES instances
|
||||
this._des1 = DES.createEncryptor(WordArray.create(key1));
|
||||
this._des2 = DES.createEncryptor(WordArray.create(key2));
|
||||
this._des3 = DES.createEncryptor(WordArray.create(key3));
|
||||
},
|
||||
|
||||
encryptBlock: function (M, offset) {
|
||||
this._des1.encryptBlock(M, offset);
|
||||
this._des2.decryptBlock(M, offset);
|
||||
this._des3.encryptBlock(M, offset);
|
||||
},
|
||||
|
||||
decryptBlock: function (M, offset) {
|
||||
this._des3.decryptBlock(M, offset);
|
||||
this._des2.encryptBlock(M, offset);
|
||||
this._des1.decryptBlock(M, offset);
|
||||
},
|
||||
|
||||
keySize: 192/32,
|
||||
|
||||
ivSize: 64/32,
|
||||
|
||||
blockSize: 64/32
|
||||
});
|
||||
|
||||
/**
|
||||
* Shortcut functions to the cipher's object interface.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg);
|
||||
* var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg);
|
||||
*/
|
||||
C.TripleDES = BlockCipher._createHelper(TripleDES);
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var StreamCipher = C_lib.StreamCipher;
|
||||
var C_algo = C.algo;
|
||||
|
||||
/**
|
||||
* RC4 stream cipher algorithm.
|
||||
*/
|
||||
var RC4 = C_algo.RC4 = StreamCipher.extend({
|
||||
_doReset: function () {
|
||||
// Shortcuts
|
||||
var key = this._key;
|
||||
var keyWords = key.words;
|
||||
var keySigBytes = key.sigBytes;
|
||||
|
||||
// Init sbox
|
||||
var S = this._S = [];
|
||||
for (var i = 0; i < 256; i++) {
|
||||
S[i] = i;
|
||||
}
|
||||
|
||||
// Key setup
|
||||
for (var i = 0, j = 0; i < 256; i++) {
|
||||
var keyByteIndex = i % keySigBytes;
|
||||
var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff;
|
||||
|
||||
j = (j + S[i] + keyByte) % 256;
|
||||
|
||||
// Swap
|
||||
var t = S[i];
|
||||
S[i] = S[j];
|
||||
S[j] = t;
|
||||
}
|
||||
|
||||
// Counters
|
||||
this._i = this._j = 0;
|
||||
},
|
||||
|
||||
_doProcessBlock: function (M, offset) {
|
||||
M[offset] ^= generateKeystreamWord.call(this);
|
||||
},
|
||||
|
||||
keySize: 256/32,
|
||||
|
||||
ivSize: 0
|
||||
});
|
||||
|
||||
function generateKeystreamWord() {
|
||||
// Shortcuts
|
||||
var S = this._S;
|
||||
var i = this._i;
|
||||
var j = this._j;
|
||||
|
||||
// Generate keystream word
|
||||
var keystreamWord = 0;
|
||||
for (var n = 0; n < 4; n++) {
|
||||
i = (i + 1) % 256;
|
||||
j = (j + S[i]) % 256;
|
||||
|
||||
// Swap
|
||||
var t = S[i];
|
||||
S[i] = S[j];
|
||||
S[j] = t;
|
||||
|
||||
keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8);
|
||||
}
|
||||
|
||||
// Update counters
|
||||
this._i = i;
|
||||
this._j = j;
|
||||
|
||||
return keystreamWord;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut functions to the cipher's object interface.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg);
|
||||
* var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg);
|
||||
*/
|
||||
C.RC4 = StreamCipher._createHelper(RC4);
|
||||
|
||||
/**
|
||||
* Modified RC4 stream cipher algorithm.
|
||||
*/
|
||||
var RC4Drop = C_algo.RC4Drop = RC4.extend({
|
||||
/**
|
||||
* Configuration options.
|
||||
*
|
||||
* @property {number} drop The number of keystream words to drop. Default 192
|
||||
*/
|
||||
cfg: RC4.cfg.extend({
|
||||
drop: 192
|
||||
}),
|
||||
|
||||
_doReset: function () {
|
||||
RC4._doReset.call(this);
|
||||
|
||||
// Drop
|
||||
for (var i = this.cfg.drop; i > 0; i--) {
|
||||
generateKeystreamWord.call(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Shortcut functions to the cipher's object interface.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg);
|
||||
* var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg);
|
||||
*/
|
||||
C.RC4Drop = StreamCipher._createHelper(RC4Drop);
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var StreamCipher = C_lib.StreamCipher;
|
||||
var C_algo = C.algo;
|
||||
|
||||
// Reusable objects
|
||||
var S = [];
|
||||
var C_ = [];
|
||||
var G = [];
|
||||
|
||||
/**
|
||||
* Rabbit stream cipher algorithm
|
||||
*/
|
||||
var Rabbit = C_algo.Rabbit = StreamCipher.extend({
|
||||
_doReset: function () {
|
||||
// Shortcuts
|
||||
var K = this._key.words;
|
||||
var iv = this.cfg.iv;
|
||||
|
||||
// Swap endian
|
||||
for (var i = 0; i < 4; i++) {
|
||||
K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) |
|
||||
(((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00);
|
||||
}
|
||||
|
||||
// Generate initial state values
|
||||
var X = this._X = [
|
||||
K[0], (K[3] << 16) | (K[2] >>> 16),
|
||||
K[1], (K[0] << 16) | (K[3] >>> 16),
|
||||
K[2], (K[1] << 16) | (K[0] >>> 16),
|
||||
K[3], (K[2] << 16) | (K[1] >>> 16)
|
||||
];
|
||||
|
||||
// Generate initial counter values
|
||||
var C = this._C = [
|
||||
(K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
|
||||
(K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
|
||||
(K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
|
||||
(K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
|
||||
];
|
||||
|
||||
// Carry bit
|
||||
this._b = 0;
|
||||
|
||||
// Iterate the system four times
|
||||
for (var i = 0; i < 4; i++) {
|
||||
nextState.call(this);
|
||||
}
|
||||
|
||||
// Modify the counters
|
||||
for (var i = 0; i < 8; i++) {
|
||||
C[i] ^= X[(i + 4) & 7];
|
||||
}
|
||||
|
||||
// IV setup
|
||||
if (iv) {
|
||||
// Shortcuts
|
||||
var IV = iv.words;
|
||||
var IV_0 = IV[0];
|
||||
var IV_1 = IV[1];
|
||||
|
||||
// Generate four subvectors
|
||||
var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
|
||||
var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
|
||||
var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
|
||||
var i3 = (i2 << 16) | (i0 & 0x0000ffff);
|
||||
|
||||
// Modify counter values
|
||||
C[0] ^= i0;
|
||||
C[1] ^= i1;
|
||||
C[2] ^= i2;
|
||||
C[3] ^= i3;
|
||||
C[4] ^= i0;
|
||||
C[5] ^= i1;
|
||||
C[6] ^= i2;
|
||||
C[7] ^= i3;
|
||||
|
||||
// Iterate the system four times
|
||||
for (var i = 0; i < 4; i++) {
|
||||
nextState.call(this);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_doProcessBlock: function (M, offset) {
|
||||
// Shortcut
|
||||
var X = this._X;
|
||||
|
||||
// Iterate the system
|
||||
nextState.call(this);
|
||||
|
||||
// Generate four keystream words
|
||||
S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
|
||||
S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
|
||||
S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
|
||||
S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
|
||||
|
||||
for (var i = 0; i < 4; i++) {
|
||||
// Swap endian
|
||||
S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
|
||||
(((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
|
||||
|
||||
// Encrypt
|
||||
M[offset + i] ^= S[i];
|
||||
}
|
||||
},
|
||||
|
||||
blockSize: 128/32,
|
||||
|
||||
ivSize: 64/32
|
||||
});
|
||||
|
||||
function nextState() {
|
||||
// Shortcuts
|
||||
var X = this._X;
|
||||
var C = this._C;
|
||||
|
||||
// Save old counter values
|
||||
for (var i = 0; i < 8; i++) {
|
||||
C_[i] = C[i];
|
||||
}
|
||||
|
||||
// Calculate new counter values
|
||||
C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
|
||||
C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
|
||||
C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
|
||||
C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
|
||||
C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
|
||||
C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
|
||||
C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
|
||||
C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
|
||||
this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
|
||||
|
||||
// Calculate the g-values
|
||||
for (var i = 0; i < 8; i++) {
|
||||
var gx = X[i] + C[i];
|
||||
|
||||
// Construct high and low argument for squaring
|
||||
var ga = gx & 0xffff;
|
||||
var gb = gx >>> 16;
|
||||
|
||||
// Calculate high and low result of squaring
|
||||
var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
|
||||
var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
|
||||
|
||||
// High XOR low
|
||||
G[i] = gh ^ gl;
|
||||
}
|
||||
|
||||
// Calculate new state values
|
||||
X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
|
||||
X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
|
||||
X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
|
||||
X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
|
||||
X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
|
||||
X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
|
||||
X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
|
||||
X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut functions to the cipher's object interface.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg);
|
||||
* var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg);
|
||||
*/
|
||||
C.Rabbit = StreamCipher._createHelper(Rabbit);
|
||||
}());
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
(function () {
|
||||
// Shortcuts
|
||||
var C = CryptoJS;
|
||||
var C_lib = C.lib;
|
||||
var StreamCipher = C_lib.StreamCipher;
|
||||
var C_algo = C.algo;
|
||||
|
||||
// Reusable objects
|
||||
var S = [];
|
||||
var C_ = [];
|
||||
var G = [];
|
||||
|
||||
/**
|
||||
* Rabbit stream cipher algorithm.
|
||||
*
|
||||
* This is a legacy version that neglected to convert the key to little-endian.
|
||||
* This error doesn't affect the cipher's security,
|
||||
* but it does affect its compatibility with other implementations.
|
||||
*/
|
||||
var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({
|
||||
_doReset: function () {
|
||||
// Shortcuts
|
||||
var K = this._key.words;
|
||||
var iv = this.cfg.iv;
|
||||
|
||||
// Generate initial state values
|
||||
var X = this._X = [
|
||||
K[0], (K[3] << 16) | (K[2] >>> 16),
|
||||
K[1], (K[0] << 16) | (K[3] >>> 16),
|
||||
K[2], (K[1] << 16) | (K[0] >>> 16),
|
||||
K[3], (K[2] << 16) | (K[1] >>> 16)
|
||||
];
|
||||
|
||||
// Generate initial counter values
|
||||
var C = this._C = [
|
||||
(K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff),
|
||||
(K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff),
|
||||
(K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff),
|
||||
(K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff)
|
||||
];
|
||||
|
||||
// Carry bit
|
||||
this._b = 0;
|
||||
|
||||
// Iterate the system four times
|
||||
for (var i = 0; i < 4; i++) {
|
||||
nextState.call(this);
|
||||
}
|
||||
|
||||
// Modify the counters
|
||||
for (var i = 0; i < 8; i++) {
|
||||
C[i] ^= X[(i + 4) & 7];
|
||||
}
|
||||
|
||||
// IV setup
|
||||
if (iv) {
|
||||
// Shortcuts
|
||||
var IV = iv.words;
|
||||
var IV_0 = IV[0];
|
||||
var IV_1 = IV[1];
|
||||
|
||||
// Generate four subvectors
|
||||
var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00);
|
||||
var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00);
|
||||
var i1 = (i0 >>> 16) | (i2 & 0xffff0000);
|
||||
var i3 = (i2 << 16) | (i0 & 0x0000ffff);
|
||||
|
||||
// Modify counter values
|
||||
C[0] ^= i0;
|
||||
C[1] ^= i1;
|
||||
C[2] ^= i2;
|
||||
C[3] ^= i3;
|
||||
C[4] ^= i0;
|
||||
C[5] ^= i1;
|
||||
C[6] ^= i2;
|
||||
C[7] ^= i3;
|
||||
|
||||
// Iterate the system four times
|
||||
for (var i = 0; i < 4; i++) {
|
||||
nextState.call(this);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_doProcessBlock: function (M, offset) {
|
||||
// Shortcut
|
||||
var X = this._X;
|
||||
|
||||
// Iterate the system
|
||||
nextState.call(this);
|
||||
|
||||
// Generate four keystream words
|
||||
S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16);
|
||||
S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16);
|
||||
S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16);
|
||||
S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16);
|
||||
|
||||
for (var i = 0; i < 4; i++) {
|
||||
// Swap endian
|
||||
S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) |
|
||||
(((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00);
|
||||
|
||||
// Encrypt
|
||||
M[offset + i] ^= S[i];
|
||||
}
|
||||
},
|
||||
|
||||
blockSize: 128/32,
|
||||
|
||||
ivSize: 64/32
|
||||
});
|
||||
|
||||
function nextState() {
|
||||
// Shortcuts
|
||||
var X = this._X;
|
||||
var C = this._C;
|
||||
|
||||
// Save old counter values
|
||||
for (var i = 0; i < 8; i++) {
|
||||
C_[i] = C[i];
|
||||
}
|
||||
|
||||
// Calculate new counter values
|
||||
C[0] = (C[0] + 0x4d34d34d + this._b) | 0;
|
||||
C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0;
|
||||
C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0;
|
||||
C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0;
|
||||
C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0;
|
||||
C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0;
|
||||
C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0;
|
||||
C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0;
|
||||
this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0;
|
||||
|
||||
// Calculate the g-values
|
||||
for (var i = 0; i < 8; i++) {
|
||||
var gx = X[i] + C[i];
|
||||
|
||||
// Construct high and low argument for squaring
|
||||
var ga = gx & 0xffff;
|
||||
var gb = gx >>> 16;
|
||||
|
||||
// Calculate high and low result of squaring
|
||||
var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb;
|
||||
var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0);
|
||||
|
||||
// High XOR low
|
||||
G[i] = gh ^ gl;
|
||||
}
|
||||
|
||||
// Calculate new state values
|
||||
X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0;
|
||||
X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0;
|
||||
X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0;
|
||||
X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0;
|
||||
X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0;
|
||||
X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0;
|
||||
X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0;
|
||||
X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shortcut functions to the cipher's object interface.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
* var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg);
|
||||
* var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg);
|
||||
*/
|
||||
C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy);
|
||||
}());
|
||||
+6190
-6190
File diff suppressed because it is too large
Load Diff
+3761
@@ -0,0 +1,3761 @@
|
||||
import cheerio from 'assets://js/lib/cheerio.min.js';
|
||||
import 'assets://js/lib/crypto-js.js';
|
||||
import './jsencrypt.js';
|
||||
import './node-rsa.js';
|
||||
import './pako.min.js';
|
||||
// import JSEncrypt from './jsencrypt.js'; // 会导致壳子崩溃的
|
||||
import 模板 from './模板.js'
|
||||
import {gbkTool} from './gbk.js'
|
||||
import './json5.js'
|
||||
// 下面是尝试对jinja2库进行更换
|
||||
import './jinja.js'
|
||||
|
||||
const _jinja2 = cheerio.jinja2;
|
||||
cheerio.jinja2 = function (template, obj) {
|
||||
try {
|
||||
return jinja.render(template, obj);
|
||||
} catch (e) {
|
||||
console.log('新的jinja2库渲染失败,换回原始cheerio:' + e.message);
|
||||
return _jinja2(template, obj)
|
||||
}
|
||||
};
|
||||
// import cheerio from "https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/libs/cheerio.min.js";
|
||||
// import "https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/libs/crypto-js.js";
|
||||
// import 模板 from"https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/js/模板.js";
|
||||
// import {gbkTool} from 'https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/libs/gbk.js'
|
||||
|
||||
let vercode = typeof (pdfl) === 'function' ? 'drpy2.1' : 'drpy2';
|
||||
const VERSION = vercode + ' 3.9.51beta5 20241104';
|
||||
const UpdateInfo = [
|
||||
{
|
||||
date: '20241104',
|
||||
title: 'drpy更新,增加新特性',
|
||||
version: '3.9.51beta5 20241104',
|
||||
msg: `
|
||||
1. rule增加 搜索验证标识 属性,可以不定义,默认为 '系统安全验证|请输入验证码'
|
||||
2. rule增加 searchNoPage 属性,可以不定义,如果定义 1 将关闭该源的搜索翻页功能,超过1页直接返回空
|
||||
`
|
||||
},
|
||||
];
|
||||
|
||||
function getUpdateInfo() {
|
||||
return UpdateInfo.map((_o) => {
|
||||
_o.msg = _o.msg.trim().split('\n').map(_it => _it.trim()).join('\n')
|
||||
return _o
|
||||
})
|
||||
}
|
||||
|
||||
function init_test() {
|
||||
// console.log(typeof(JSON5));
|
||||
// let a = `{'SHOW':'10','UK':'43a7dc59-e87b-449e-8b74-ba40db28e674','albumlist':[{'DC_TARGETID':'30965086','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'17294','aartist':'','ad_subtype':'102,103,501,101,301','ad_type':'1,3,5','albumid':'30965086','artist':'小白不做凤尾','artistid':'10442011','artistpic':'http://img4.kuwo.cn/star/starheads/120/92/53/247071944.jpg','color':'[#FFE2F2C6,#FF85A476]','company':'独立发行','content_type':'0','falbum':'','fartist':'小白不做凤尾','finished':'0','hts_img':'https://img2.kuwo.cn/star/albumcover/240/51/40/547190780.jpg','id':'30965086','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/51/40/547190780.jpg','info':'来听听','isstar':'1','lang':'','musiccnt':'37','name':'我的','new':'0','payvalue':'0','pic':'120/51/40/547190780.jpg','pub':'2022-08-28','score':'0','showtime':'','spPrivilege':'0','startype':'有声小说','timing_online':'0000-00-00 00:00:00','title':'','vip':'0'},{'DC_TARGETID':'28041980','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'0','aartist':'','ad_subtype':'','ad_type':'','albumid':'28041980','artist':'玄琛','artistid':'9688248','artistpic':'http://img4.kuwo.cn/star/starheads/120/96/39/3155308302.jpg','color':'[#FFE2F2C6,#FF85A476]','company':'独立发行','content_type':'0','falbum':'','fartist':'玄琛','finished':'0','hts_img':'https://img2.kuwo.cn/star/albumcover/240/72/16/2510768590.jpg','id':'28041980','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/72/16/2510768590.jpg','info':'我来诉说我的故事,请你认真聆听,做最好的聆听者','isstar':'1','lang':'','musiccnt':'2','name':'我的','new':'0','payvalue':'0','pic':'120/72/16/2510768590.jpg','pub':'2020-08-18','score':'0','showtime':'','spPrivilege':'0','startype':'历史人文','timing_online':'0000-00-00 00:00:00','title':'','vip':'0'},{'DC_TARGETID':'17245200','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'5529096','aartist':'','ad_subtype':'','ad_type':'','albumid':'17245200','artist':'我和我的家乡','artistid':'5037564','artistpic':'http://img4.kuwo.cn/star/starheads/0/10/27/3738071257.jpg','color':'[#FFD8F3F1,#FF719794]','company':'中青在线','content_type':'0','falbum':'','fartist':'我和我的家乡','finished':'1','hts_img':'https://img2.kuwo.cn/star/albumcover/240/85/51/1350940634.jpg','id':'17245200','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/85/51/1350940634.jpg','info':'《我和我的家乡2》是融媒体音频节目《我和我的家乡》第二季。为解读中国人的乡土情结,汇聚同心追梦的力量。【歌曲篇】每期节目将推出一个主题城市,邀请一位青春正能量明星,演唱与家乡有关的原创或翻唱歌曲,曲传乡音。','isstar':'1','lang':'','musiccnt':'5','name':'我和我的家乡第二季「歌曲篇」','new':'0','payvalue':'0','pic':'120/85/51/1350940634.jpg','pub':'2020-12-25','score':'0','showtime':'','spPrivilege':'0','startype':'历史人文','timing_online':'0000-00-00 00:00:00','title':'解读中国人的乡土情结','vip':'0'},{'DC_TARGETID':'12854978','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'21482961','aartist':'','ad_subtype':'','ad_type':'','albumid':'12854978','artist':'佛学听我的','artistid':'3651480','artistpic':'http://img4.kuwo.cn/star/starheads/120/21/42/3683883829.jpg','color':'[#FFD8F3F1,#FF719794]','company':'暂无','content_type':'0','falbum':'','fartist':'佛学听我的','finished':'0','hts_img':'https://img2.kuwo.cn/star/albumcover/240/99/12/1066669641.jpg','id':'12854978','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/99/12/1066669641.jpg','info':'禅音静心:禅茶一味','isstar':'1','lang':'普通话','musiccnt':'407','name':'禅音静心:禅茶一味','new':'0','payvalue':'0','pic':'120/99/12/1066669641.jpg','pub':'2020-02-23','score':'0','showtime':'','spPrivilege':'0','startype':'历史人文','timing_online':'0000-00-00 00:00:00','title':'禅音静心:禅茶一味','vip':'0'},{'DC_TARGETID':'13884852','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'17396226','aartist':'','ad_subtype':'','ad_type':'','albumid':'13884852','artist':'佛学听我的','artistid':'3651480','artistpic':'http://img4.kuwo.cn/star/starheads/120/21/42/3683883829.jpg','color':'[#FFD8F3F1,#FF719794]','company':'暂无','content_type':'0','falbum':'','fartist':'佛学听我的','finished':'0','hts_img':'https://img2.kuwo.cn/star/albumcover/240/91/94/4253604466.jpg','id':'13884852','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/91/94/4253604466.jpg','info':'静心听佛乐','isstar':'1','lang':'普通话','musiccnt':'228','name':'静心听佛乐','new':'0','payvalue':'0','pic':'120/91/94/4253604466.jpg','pub':'2020-04-27','score':'0','showtime':'','spPrivilege':'0','startype':'历史人文','timing_online':'0000-00-00 00:00:00','title':'静心听佛乐','vip':'0'},{'DC_TARGETID':'17172751','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'553401','aartist':'','ad_subtype':'102,103,101,501','ad_type':'1,5','albumid':'17172751','artist':'我和我的家乡','artistid':'5037564','artistpic':'http://img4.kuwo.cn/star/starheads/0/10/27/3738071257.jpg','color':'[#FFD8F3F1,#FF719794]','company':'中青在线','content_type':'0','falbum':'','fartist':'我和我的家乡','finished':'1','hts_img':'https://img2.kuwo.cn/star/albumcover/240/63/45/3978411674.jpg','id':'17172751','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/63/45/3978411674.jpg','info':'《我和我的家乡2》是融媒体音频节目《我和我的家乡》第二季。为解读中国人的乡土情结,汇聚同心追梦的力量。每期节目将推出一个主题城市,邀请一位青春正能量明星,用笔者独有的乡愁情感,配以讲述者也为此乡人的身份,着力刻画该城市的魅力形象,展现一座城的普通百姓生活和经济社会发展。','isstar':'1','lang':'','musiccnt':'11','name':'我和我的家乡第二季「有声篇」','new':'0','payvalue':'0','pic':'120/63/45/3978411674.jpg','pub':'2020-12-21','score':'0','showtime':'2020-12-20','spPrivilege':'0','startype':'娱乐','timing_online':'2020-12-20 23:40:00','title':'','vip':'0'},{'DC_TARGETID':'18769609','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'69987','aartist':'','ad_subtype':'101,102,103,501','ad_type':'1,5','albumid':'18769609','artist':'你是我的荣耀','artistid':'6998984','artistpic':'http://img4.kuwo.cn/star/starheads/120/41/44/262468637.jpg','color':'[#FFD8F3F1,#FF719794]','company':'暂无','content_type':'0','falbum':'','fartist':'你是我的荣耀','finished':'0','hts_img':'https://img2.kuwo.cn/star/albumcover/240/44/72/4080853707.jpg','id':'18769609','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/44/72/4080853707.jpg','info':'《你是我的荣耀》是由王之执导,潘粤明、胡可、王彦霖、杨洋、迪丽热巴、郑合惠子主演的都市爱情剧。该剧改编自顾漫创作的同名小说,主要讲述了人气女星乔晶晶在游戏中与曾经的高中同学于途意外重逢后发生的故事。\\\\\\\\\\\\\\\\\\n;跟随《你是我的荣耀》之声,一起见证航天工程师于途与人气女星乔晶晶,携手砥砺前行成为彼此荣耀的爱情故事!\\\\\\\\\\\\\\\\\\n;\\\\\\\\\\\\\\\\\\n;\\\\\\\\\\\\\\\\\\n;\\\\\\\\\\\\\\\\\\n;\\\\\\\\\\\\\\\\\\n;','isstar':'1','lang':'普通话','musiccnt':'1','name':'你是我的荣耀','new':'0','payvalue':'0','pic':'120/44/72/4080853707.jpg','pub':'2021-03-05','score':'0','showtime':'2021-03-09','spPrivilege':'0','startype':'有声小说','timing_online':'2021-03-09 00:00:00','title':'大明星恋上航天工程师 热巴杨洋甜蜜相守','vip':'0'},{'DC_TARGETID':'23641999','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'1292491','aartist':'','ad_subtype':'102,103,501,101,301','ad_type':'1,3,5','albumid':'23641999','artist':'我的存在','artistid':'8102787','artistpic':'http://img4.kuwo.cn/star/starheads/120/31/87/632983033.jpg','color':'[#FFE2F2C6,#FF85A476]','company':'独立发行','content_type':'0','falbum':'','fartist':'我的存在','finished':'1','hts_img':'https://img2.kuwo.cn/star/albumcover/240/50/6/2193571523.jpg','id':'23641999','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/50/6/2193571523.jpg','info':'为给老驸马冲喜,长亭长公主庶孙迎娶陆家女,新娘子当天却吊死在洞房,现代女医生陆漫穿越而来。委屈的某人,我要功成名就,我的生活我作主。陆漫,还你自由,我也自由……','isstar':'1','lang':'','musiccnt':'726','name':'金玉良医(完结)','new':'0','payvalue':'0','pic':'120/50/6/2193571523.jpg','pub':'2021-10-11','score':'0','showtime':'','spPrivilege':'0','startype':'有声小说','timing_online':'0000-00-00 00:00:00','title':'现代女医生陆漫穿越到古代发生的事情','vip':'0'},{'DC_TARGETID':'28177105','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'10448','aartist':'','ad_subtype':'102,103,501,101,301','ad_type':'1,3,5','albumid':'28177105','artist':'我的青糖','artistid':'9650993','artistpic':'http://img4.kuwo.cn/star/starheads/120/40/93/1019968534.jpg','color':'[#FFE2F2C6,#FF85A476]','company':'独立发行','content_type':'0','falbum':'','fartist':'我的青糖','finished':'0','hts_img':'https://img2.kuwo.cn/star/albumcover/240/62/97/3136446870.jpg','id':'28177105','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/62/97/3136446870.jpg','info':'【字数:16万字】<br>裴子墨和丁辰是一对夫妻,妻子丁辰深爱裴子墨,但裴子墨难以忘怀初恋总是对她若即若离。婚后两年,裴子墨前女友于筝突然回国,使得他和丁辰原本就不稳定的婚姻更加雪上加霜。于筝当初背叛裴子墨,受伤后才意识到裴子墨的好,于是不择手段夺回了裴子墨。丁辰和裴子墨离婚后,裴子墨才意识到两年相处,他早已习惯有丁辰的陪伴。裴子墨决心重新赢回丁辰的心,但此时丁辰身边已经有了一位极其出色的追求者,前景不容乐观……','isstar':'1','lang':'','musiccnt':'80','name':'如果你是我的传说','new':'0','payvalue':'0','pic':'120/62/97/3136446870.jpg','pub':'2022-04-21','score':'0','showtime':'1979-10-05','spPrivilege':'0','startype':'有声小说','timing_online':'2022-05-01 19:26:48','title':'','vip':'0'},{'DC_TARGETID':'12896662','DC_TARGETTYPE':'','PAY':'0','PLAYCNT':'2412258','aartist':'','ad_subtype':'','ad_type':'','albumid':'12896662','artist':'佛学听我的','artistid':'3651480','artistpic':'http://img4.kuwo.cn/star/starheads/120/21/42/3683883829.jpg','color':'[#FFD8F3F1,#FF719794]','company':'暂无','content_type':'0','falbum':'','fartist':'佛学听我的','finished':'0','hts_img':'https://img2.kuwo.cn/star/albumcover/240/93/41/3670973086.jpg','id':'12896662','img':'http://img2.sycdn.kuwo.cn/star/albumcover/240/93/41/3670973086.jpg','info':'佛书梵唱100篇','isstar':'1','lang':'普通话','musiccnt':'50','name':'佛书梵唱100篇','new':'0','payvalue':'0','pic':'120/93/41/3670973086.jpg','pub':'2020-02-24','score':'0','showtime':'','spPrivilege':'0','startype':'历史人文','timing_online':'0000-00-00 00:00:00','title':'佛书梵唱100篇','vip':'0'}],'pn':'0','rn':'10','total':'257'}`;
|
||||
// log(JSON5.parse(a));
|
||||
// console.log(typeof(CryptoJS));
|
||||
console.log("init_test_start");
|
||||
// print(模板);
|
||||
// print(typeof(模板.getMubans));
|
||||
console.log("当前版本号:" + VERSION);
|
||||
console.log('本地代理地址:' + getProxyUrl());
|
||||
console.log(RKEY);
|
||||
// ocr_demo_test();
|
||||
// rsa_demo_test();
|
||||
|
||||
// console.log('Uint8Array:'+typeof(Uint8Array)+' '+'Uint16Array:'+typeof(Uint16Array));
|
||||
// console.log('encodeURIComponent:'+typeof(encodeURIComponent)+' '+'decodeURIComponent:'+typeof(decodeURIComponent));
|
||||
// console.log('atob:'+typeof(atob)+' '+'btoa:'+typeof(btoa));
|
||||
// log('typeof (JSEncrypt):'+typeof (JSEncrypt));
|
||||
// log('typeof (pako):'+typeof (pako));
|
||||
// let b64_str = btoa('hello hipy');
|
||||
// let str = atob(b64_str);
|
||||
// console.log(`btoa加密文本:${b64_str},atob解密文本:${str}`)
|
||||
// let gzip_str = gzip('{"a":"电影","b":"电影","c":"电影","d":"电影","e":"电影","f":"电影"}');
|
||||
// let ungzip_str = ungzip(gzip_str);
|
||||
// console.log(`gzip加密文本:${gzip_str},长度:${gzip_str.length},ungzip解密文本:${ungzip_str},长度:${ungzip_str.length}`);
|
||||
// let a = {"1":[{"key":"类型","name":"类型","value":[{"n":"全部","v":""},{"n":"Netflix","v":"NETFLIX"},{"n":"剧情","v":"剧情"},{"n":"喜剧","v":"喜剧"},{"n":"动作","v":"动作"},{"n":"爱情","v":"爱情"},{"n":"恐怖","v":"恐怖"},{"n":"惊悚","v":"惊悚"},{"n":"犯罪","v":"犯罪"},{"n":"科幻","v":"科幻"},{"n":"悬疑","v":"悬疑"},{"n":"奇幻","v":"奇幻"},{"n":"冒险","v":"冒险"},{"n":"战争","v":"战争"},{"n":"历史","v":"历史"},{"n":"古装","v":"古装"},{"n":"家庭","v":"家庭"},{"n":"传记","v":"传记"},{"n":"武侠","v":"武侠"},{"n":"歌舞","v":"歌舞"},{"n":"短片","v":"短片"},{"n":"动画","v":"动画"},{"n":"儿童","v":"儿童"},{"n":"职场","v":"职场"}]},{"key":"地区","name":"地区","value":[{"n":"全部","v":""},{"n":"大陆","v":"中国大陆"},{"n":"香港","v":"中国香港"},{"n":"台湾","v":"中国台湾"},{"n":"美国","v":"美国"},{"n":"日本","v":"日本"},{"n":"韩国","v":"韩国"},{"n":"英国","v":"英国"},{"n":"法国","v":"法国"},{"n":"德国","v":"德国"},{"n":"印度","v":"印度"},{"n":"泰国","v":"泰国"},{"n":"丹麦","v":"丹麦"},{"n":"瑞典","v":"瑞典"},{"n":"巴西","v":"巴西"},{"n":"加拿大","v":"加拿大"},{"n":"俄罗斯","v":"俄罗斯"},{"n":"意大利","v":"意大利"},{"n":"比利时","v":"比利时"},{"n":"爱尔兰","v":"爱尔兰"},{"n":"西班牙","v":"西班牙"},{"n":"澳大利亚","v":"澳大利亚"},{"n":"其他","v":"其他"}]},{"key":"语言","name":"语言","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"粤语","v":"粤语"},{"n":"英语","v":"英语"},{"n":"日语","v":"日语"},{"n":"韩语","v":"韩语"},{"n":"法语","v":"法语"},{"n":"其他","v":"其他"}]},{"key":"年份","name":"年份","value":[{"n":"全部","v":""},{"n":"2024","v":"2024"},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"10年代","v":"2010_2019"},{"n":"00年代","v":"2000_2009"},{"n":"90年代","v":"1990_1999"},{"n":"80年代","v":"1980_1989"},{"n":"更早","v":"0_1979"}]},{"key":"排序","name":"排序","value":[{"n":"综合","v":""},{"n":"最新","v":"2"},{"n":"最热","v":"3"},{"n":"评分","v":"4"}]}],"2":[{"key":"类型","name":"类型","value":[{"n":"全部","v":""},{"n":"Netflix","v":"Netflix"},{"n":"剧情","v":"剧情"},{"n":"爱情","v":"爱情"},{"n":"喜剧","v":"喜剧"},{"n":"犯罪","v":"犯罪"},{"n":"悬疑","v":"悬疑"},{"n":"古装","v":"古装"},{"n":"动作","v":"动作"},{"n":"家庭","v":"家庭"},{"n":"惊悚","v":"惊悚"},{"n":"奇幻","v":"奇幻"},{"n":"美剧","v":"美剧"},{"n":"科幻","v":"科幻"},{"n":"历史","v":"历史"},{"n":"战争","v":"战争"},{"n":"韩剧","v":"韩剧"},{"n":"武侠","v":"武侠"},{"n":"言情","v":"言情"},{"n":"恐怖","v":"恐怖"},{"n":"冒险","v":"冒险"},{"n":"都市","v":"都市"},{"n":"职场","v":"职场"}]},{"key":"地区","name":"地区","value":[{"n":"地区","v":""},{"n":"大陆","v":"中国大陆"},{"n":"香港","v":"中国香港"},{"n":"韩国","v":"韩国"},{"n":"美国","v":"美国"},{"n":"日本","v":"日本"},{"n":"法国","v":"法国"},{"n":"英国","v":"英国"},{"n":"德国","v":"德国"},{"n":"台湾","v":"中国台湾"},{"n":"泰国","v":"泰国"},{"n":"印度","v":"印度"},{"n":"其他","v":"其他"}]},{"key":"语言","name":"语言","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"粤语","v":"粤语"},{"n":"英语","v":"英语"},{"n":"日语","v":"日语"},{"n":"韩语","v":"韩语"},{"n":"法语","v":"法语"},{"n":"其他","v":"其他"}]},{"key":"年份","name":"年份","value":[{"n":"全部","v":""},{"n":"2024","v":"2024"},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"10年代","v":"2010_2019"},{"n":"00年代","v":"2000_2009"},{"n":"90年代","v":"1990_1999"},{"n":"80年代","v":"1980_1989"},{"n":"更早","v":"0_1979"}]},{"key":"排序","name":"排序","value":[{"n":"综合","v":""},{"n":"最新","v":"2"},{"n":"最热","v":"3"},{"n":"评分","v":"4"}]}],"3":[{"key":"类型","name":"类型","value":[{"n":"全部","v":""},{"n":"Netflix","v":"Netflix"},{"n":"动态漫画","v":"动态漫画"},{"n":"剧情","v":"剧情"},{"n":"动画","v":"动画"},{"n":"喜剧","v":"喜剧"},{"n":"冒险","v":"冒险"},{"n":"动作","v":"动作"},{"n":"奇幻","v":"奇幻"},{"n":"科幻","v":"科幻"},{"n":"儿童","v":"儿童"},{"n":"搞笑","v":"搞笑"},{"n":"爱情","v":"爱情"},{"n":"家庭","v":"家庭"},{"n":"短片","v":"短片"},{"n":"热血","v":"热血"},{"n":"益智","v":"益智"},{"n":"悬疑","v":"悬疑"},{"n":"经典","v":"经典"},{"n":"校园","v":"校园"},{"n":"Anime","v":"Anime"},{"n":"运动","v":"运动"},{"n":"亲子","v":"亲子"},{"n":"青春","v":"青春"},{"n":"恋爱","v":"恋爱"},{"n":"武侠","v":"武侠"},{"n":"惊悚","v":"惊悚"}]},{"key":"地区","name":"地区","value":[{"n":"全部","v":""},{"n":"日本","v":"日本"},{"n":"大陆","v":"中国大陆"},{"n":"台湾","v":"中国台湾"},{"n":"美国","v":"美国"},{"n":"香港","v":"中国香港"},{"n":"韩国","v":"韩国"},{"n":"英国","v":"英国"},{"n":"法国","v":"法国"},{"n":"德国","v":"德国"},{"n":"印度","v":"印度"},{"n":"泰国","v":"泰国"},{"n":"丹麦","v":"丹麦"},{"n":"瑞典","v":"瑞典"},{"n":"巴西","v":"巴西"},{"n":"加拿大","v":"加拿大"},{"n":"俄罗斯","v":"俄罗斯"},{"n":"意大利","v":"意大利"},{"n":"比利时","v":"比利时"},{"n":"爱尔兰","v":"爱尔兰"},{"n":"西班牙","v":"西班牙"},{"n":"澳大利亚","v":"澳大利亚"},{"n":"其他","v":"其他"}]},{"key":"语言","name":"语言","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"粤语","v":"粤语"},{"n":"英语","v":"英语"},{"n":"日语","v":"日语"},{"n":"韩语","v":"韩语"},{"n":"法语","v":"法语"},{"n":"其他","v":"其他"}]},{"key":"年份","name":"年份","value":[{"n":"全部","v":""},{"n":"2024","v":"2024"},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"10年代","v":"2010_2019"},{"n":"00年代","v":"2000_2009"},{"n":"90年代","v":"1990_1999"},{"n":"80年代","v":"1980_1989"},{"n":"更早","v":"0_1979"}]},{"key":"排序","name":"排序","value":[{"n":"综合","v":""},{"n":"最新","v":"2"},{"n":"最热","v":"3"},{"n":"评分","v":"4"}]}],"4":[{"key":"类型","name":"类型","value":[{"n":"全部","v":""},{"n":"纪录","v":"纪录"},{"n":"真人秀","v":"真人秀"},{"n":"记录","v":"记录"},{"n":"脱口秀","v":"脱口秀"},{"n":"剧情","v":"剧情"},{"n":"历史","v":"历史"},{"n":"喜剧","v":"喜剧"},{"n":"传记","v":"传记"},{"n":"相声","v":"相声"},{"n":"节目","v":"节目"},{"n":"歌舞","v":"歌舞"},{"n":"冒险","v":"冒险"},{"n":"运动","v":"运动"},{"n":"Season","v":"Season"},{"n":"犯罪","v":"犯罪"},{"n":"短片","v":"短片"},{"n":"搞笑","v":"搞笑"},{"n":"晚会","v":"晚会"}]},{"key":"地区","name":"地区","value":[{"n":"全部","v":""},{"n":"大陆","v":"中国大陆"},{"n":"香港","v":"中国香港"},{"n":"台湾","v":"中国台湾"},{"n":"美国","v":"美国"},{"n":"日本","v":"日本"},{"n":"韩国","v":"韩国"},{"n":"其他","v":"其他"}]},{"key":"语言","name":"语言","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"粤语","v":"粤语"},{"n":"英语","v":"英语"},{"n":"日语","v":"日语"},{"n":"韩语","v":"韩语"},{"n":"法语","v":"法语"},{"n":"其他","v":"其他"}]},{"key":"年份","name":"年份","value":[{"n":"全部","v":""},{"n":"2024","v":"2024"},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"10年代","v":"2010_2019"},{"n":"00年代","v":"2000_2009"},{"n":"90年代","v":"1990_1999"},{"n":"80年代","v":"1980_1989"},{"n":"更早","v":"0_1979"}]},{"key":"排序","name":"排序","value":[{"n":"综合","v":""},{"n":"最新","v":"2"},{"n":"最热","v":"3"},{"n":"评分","v":"4"}]}],"6":[{"key":"类型","name":"类型","value":[{"n":"类型","v":""},{"n":"逆袭","v":"逆袭"},{"n":"甜宠","v":"甜宠"},{"n":"虐恋","v":"虐恋"},{"n":"穿越","v":"穿越"},{"n":"重生","v":"重生"},{"n":"剧情","v":"剧情"},{"n":"科幻","v":"科幻"},{"n":"武侠","v":"武侠"},{"n":"爱情","v":"爱情"},{"n":"动作","v":"动作"},{"n":"战争","v":"战争"},{"n":"冒险","v":"冒险"},{"n":"其它","v":"其它"}]},{"key":"排序","name":"排序","value":[{"n":"综合","v":""},{"n":"最新","v":"2"},{"n":"最热","v":"3"}]}]};
|
||||
// log(gzip(JSON.stringify(a)));
|
||||
|
||||
console.log(JSON.stringify(rule));
|
||||
console.log("init_test_end");
|
||||
|
||||
|
||||
// log('typeof (JSEncrypt):'+typeof (JSEncrypt));
|
||||
// let publicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwEc7wBMtYKkxvrQNI3+ITBZwAkPkGvsv4TsAHFskKGZWz9eYl3scivhmlEfWHlEkdyb0m82CmB1qAgef+pD4cZu+Cdmm2e9lnExhLwm8cBgpkAen9QRNdjojZgxM0W+JcReH4W6pw+uFXiLRn4AIQkDftWGNLg6wlNS+39Z/RvP9zyATJLZ9AKDdHp62XMxEK1KZvWBuIg+Oa5UzgA9jy+2XyIqwhBtO8tPbUl21t2pvTzHoLUjSkPNm2LurcUk6+jQ2r6aiS2CN1NXIucPJU6mkuIQ821SjvkYPtIdRMntW4y2u4cyiqVEEQwlzWVMHh+/vfrWAQr9fgjDuYYtvPQIDAQAB';
|
||||
// let privateKey = 'MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDARzvAEy1gqTG+tA0jf4hMFnACQ+Qa+y/hOwAcWyQoZlbP15iXexyK+GaUR9YeUSR3JvSbzYKYHWoCB5/6kPhxm74J2abZ72WcTGEvCbxwGCmQB6f1BE12OiNmDEzRb4lxF4fhbqnD64VeItGfgAhCQN+1YY0uDrCU1L7f1n9G8/3PIBMktn0AoN0enrZczEQrUpm9YG4iD45rlTOAD2PL7ZfIirCEG07y09tSXbW3am9PMegtSNKQ82bYu6txSTr6NDavpqJLYI3U1ci5w8lTqaS4hDzbVKO+Rg+0h1Eye1bjLa7hzKKpUQRDCXNZUweH7+9+tYBCv1+CMO5hi289AgMBAAECggEBAIRbRJUWXmEwdq64kGbELlV6CIZ2p3mvOSlIjO34Cy7IK7AMz9xOgbpj/XDK9miOIJTouu7ZC7GcZdGZ4BUCYBMMS0fKjGFuurpZlXhkslNTPqEHtCUkXhIpOR7RDrwIlErGEOIsZC4aXQcM3tF1t7mroJLh4OY4dHMu82lv5NM4hhFMNvHzXVvrPXeTzw26gddHVG/ke0WUYOcB5j3cPp8xaVp7JV8bdxtGtkqIfBLY/dIczzJu/3F3cBpU2nNwt8uVUF/w/HKlr7j8FqqFHXWh182beU0n5AIdRyRJBrRUAEhdtsUnvJOVBDqzZa+9DJ5395F7V8KRlQptxETdhCECgYEA4x/2HM9fnVIhG6wTbEt1LhGTKYb/igMAHLqquEMfRsB44tobI8gVNwR3qJQY/nKXxcQemQV29PcdqpENCKyXUXGD8SI1UPg15rHFBI8CIqlCXfzJybdHjmzlhaA9I5lofIVh+5MW7WkvHZoRy7NeDMhHUuaiveuqC4OJ8n+dD2kCgYEA2LkmUVef3WkBBwUBRdkyoog3DMwR+/ubb0ncJVYy3ItYVJltQ4HqmrRiJc8xBAoFnG8rbiqDnmTnDR3WbuxU1G2hml09fqId+rQds2UfESswCXHU43A4f77m1XyA6PprBxpozVIcmK69N4rR9jOXflLWo3O+p2ipUbmNpId7+rUCgYBSpcbBJRT+AmzZzPwkZDD32p1ady114zGfQq3s7z/qVw+mPQezNZPCuXVxerK9pKVl6b/Ynwxyh5nb/3xms6c8k7oXfQM5u5ihof63cfKs+jqUSPCE3pTDVw0OWwjkc2Z6KW9GRHgLXEMw2mevYE3RCPArUpHV2nO+TNddzuIwQQKBgQDOZwdnUNygMfEYjlu3+jOPN8u2FGTMZ8SRKPbRWFb4VH27lKPLN2AIFuOivsEf56uQYRAry7GumMq0Y0ZmPg5Mglz2dvaqNBv5OLFQuW3tHAST+iWWtroYb+fISts7B8QG79AAO8OgZksvKrbslBYj6SEiaomZRsR7YQzVNXOOQQKBgQCovElZ50c8ZJ6m9D9fw3Nes7u9vshpyyac5tt4tZ7yfU4l5pWGrIUqCE703qZp4NAqEvlZUCJbj9kkysaj/2MfFb2b9jSvdNB+V/YW9Cwg+5TziYoOcQzN1z2u4p4goTAv0S+pTNSr3qWaTUI4TXUXQajif45Fexv+MrP5AAXQyw=='
|
||||
// // let text = '你好';
|
||||
// let text = '[{"vod_name":"兔小贝原创儿歌","vod_pic":"https://resource-cdn.tuxiaobei.com/video-album/FnQ8ieJHgsbgCKWXNBg4uoOmKgG5.jpg","vod_remarks":"共229首","vod_content":"","vod_id":"/subject/17@@兔小贝原创儿歌@@https://resource-cdn.tuxiaobei.com/video-album/FnQ8ieJHgsbgCKWXNBg4uoOmKgG5.jpg"},{"vod_name":"英文儿歌","vod_pic":"https://resource-cdn.tuxiaobei.com/video-album/Fqjpx2H_-QaYNAYn2MekRuDpeyUv.jpg","vod_remarks":"共10首","vod_content":"","vod_id":"/subject/23@@英文儿歌@@https://resource-cdn.tuxiaobei.com/video-album/Fqjpx2H_-QaYNAYn2MekRuDpeyUv.jpg"}]';
|
||||
// let str = RSA.encode(text, publicKey);
|
||||
// console.log("加密数据:" + str);
|
||||
// let str1 = 'Wa2c/868VOm0PgpGG2s2aMrDbGOlJRdZXlSGswjFgywd3nZNB7ND8kVMdNB/OsNFoQXJXSJMvPaE73BH7rs8fz54JGdYQK+qTgfQRqQZvomCjbzseSR4bm4NOrtIOOslL3WqxlzOuU0M1P1eERmkLEVU2WSyc3RGtJro3b3MOWYCNdKMoZdncfOHJndkl4wm9V3GGc3uH98hs6OxLvBWgXoW9jZQ3n0vR2FtS2KYrPGuSuKGkxlt9Kw5TD6nri142NOimz05WK55Xe04YUQ1VZd51t0wzJGXolWgfzIQaK2zzhk5Zjlm+IQJxXqEWiJ2+O6TJ+lIttvsDSaUflcDXQ==';
|
||||
// let str2 = 'R86mW9DzBw05pxBSh9ECh1stXxINmnudgZBbzU/cz1EcFgrEgdk0Zk4ruAiJZB2fP5c7d3gMmN8+Dv19IfARWSzw85xCEjUhpdcMJ0jn6ZE5H+muadND9LzjeVisojqwYxot3YVdKof7HMhPFN8QR0jfzqhjmnGFTlY1jMXzJK0MSOLNRLDar480CdKNb/cxALC8+xKIlhM9E4B31t8J4rNMUWSCAr49lbZ3jx3PxieBpTQUdDJz96AttR93Pc+c51wrxh0Ch/Mt4Rs09HGMXwIpNV+CxsGwSGRQUlyJo2k3d0WqsVzpz6S8A4VGEMTRLGI3IjEt+eWt7wM3nAXarg==';
|
||||
// let str3 = 'D4eOsRqua+jYA5+ZOR9PLI2PExKjKfArQfv9/wGeG50bQSjWypShJPY6RQfO+rghyf0juzHIUSxqH91OxinhCFkONaF2Vod2QVyphyn9eh73dAcEFKIFFKGXoPCjbMWrr3p4d+hgVrHzrFeGqkRq8JFOvG2L5XDxVfWbV8KmUA0DKuz6QwWg7P4kesy+C7BbLALy5W/wfZchD3gnsBvx/pjFoe11VfAify9isLxg9a15jj52xr6lzQ9kge9C2JcV8yq85bFKaUpJWgobzz+BSIv3lVMU6vgcldmOrhkyiETpFGFGGF00DphGCEoK6uAyyNDh7+Jn8P17zf/DW1wV3A==';
|
||||
// let uncrypted = RSA.decode(str, privateKey);
|
||||
// log('解密数据:'+uncrypted);
|
||||
// uncrypted = RSA.decode(str1, privateKey);
|
||||
// log('解密数据1:'+uncrypted);
|
||||
// uncrypted = RSA.decode(str2, privateKey);
|
||||
// log('解密数据2:'+uncrypted);
|
||||
// uncrypted = RSA.decode(str3, privateKey);
|
||||
// log('解密数据3:'+uncrypted);
|
||||
|
||||
// log('rsax:'+typeof(rsax));
|
||||
// log('rsaX:'+typeof(rsaX));
|
||||
// let data = base64Encode('你好');
|
||||
// let publicKey = 'dzyyds';
|
||||
// console.log(typeof (RSA.encode));
|
||||
// let encryptBase64Data = RSA.encode(data,publicKey);
|
||||
// log('encryptBase64Data:'+encryptBase64Data);
|
||||
// let str = RSA.decode(data,publicKey);
|
||||
// log('str:'+str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码ocr识别的测试案例
|
||||
*/
|
||||
function ocr_demo_test() {
|
||||
// 这张图片为4113的验证码
|
||||
let img_base64 = `iVBORw0KGgoAAAANSUhEUgAAAIAAAAAoBAMAAADEX+97AAAAG1BMVEXz+/4thQTa7N6QwIFFkyNeokKozqDB3b93sWHFR+MEAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABN0lEQVRIie2TQU+DQBCFt9vScvQpxR4xrcSjJCZ67JDGXsX+AdR4B3vpsSYm/m2HXaRLmuySepR3Gdidb/btDAjRq5dT96eCMlfBuzi1QLZUoZy2yz5sOvI+9iomaPEZ6nWnEtxqIyiM1RcAy44GNDhBXUjot/VVNweV1ah68FqWRyjKIOqAcyYF6rGcmpYnHzGt3fycNoMw0d3/THFu7hFSJ/8OXO6iTM8/KSg09obAzIHLO250LgQ0txOZSfgrV4Exdw98uGycJ0ErAeExZGhOmFHV9zHO6qVSj0MpLq7xZON56o++MjlsEgfVhbQWWME+xQX7J4V6zfi9A1Ly9rP1BvEXp+BbVJ/M77n+wfOIDVp51pZ4iBxvmj9AGrtvry6emwfKnVkW+ZRKd5ZNMvob36vXP9YPDmQki8QiCFAAAAAASUVORK5CYII=`;
|
||||
// 更换api-可以通过这个代码换掉默认的ocr接口
|
||||
OcrApi.api = OCR_API;
|
||||
let code = OcrApi.classification(img_base64);
|
||||
log('测试验证码图片的ocr识别结果为:' + code);
|
||||
}
|
||||
|
||||
/**
|
||||
* rsa加解密的全方位测试案例
|
||||
*/
|
||||
function rsa_demo_test() {
|
||||
let t1 = new Date().getTime();
|
||||
let pkcs1_public = `
|
||||
-----BEGIN RSA PUBLIC KEY-----
|
||||
MEgCQQCrI0pQ/ERRpJ3Ou190XJedFq846nDYP52rOtXyDxlFK5D3p6JJu2RwsKwy
|
||||
lsQ9xY0xYPpRZUZKMEeR7e9gmRNLAgMBAAE=
|
||||
-----END RSA PUBLIC KEY-----
|
||||
`.trim();
|
||||
|
||||
let pkcs1_public_pem = `
|
||||
MEgCQQCrI0pQ/ERRpJ3Ou190XJedFq846nDYP52rOtXyDxlFK5D3p6JJu2RwsKwy
|
||||
lsQ9xY0xYPpRZUZKMEeR7e9gmRNLAgMBAAE=
|
||||
`.trim();
|
||||
|
||||
let pkcs8_public = `
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKsjSlD8RFGknc67X3Rcl50WrzjqcNg/
|
||||
nas61fIPGUUrkPenokm7ZHCwrDKWxD3FjTFg+lFlRkowR5Ht72CZE0sCAwEAAQ==
|
||||
-----END PUBLIC KEY-----`.trim();
|
||||
|
||||
let pkcs8_public_pem = `
|
||||
MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBAKsjSlD8RFGknc67X3Rcl50WrzjqcNg/
|
||||
nas61fIPGUUrkPenokm7ZHCwrDKWxD3FjTFg+lFlRkowR5Ht72CZE0sCAwEAAQ==
|
||||
`.trim();
|
||||
|
||||
let pkcs1_private = `
|
||||
-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIBOAIBAAJBAKsjSlD8RFGknc67X3Rcl50WrzjqcNg/nas61fIPGUUrkPenokm7
|
||||
ZHCwrDKWxD3FjTFg+lFlRkowR5Ht72CZE0sCAwEAAQI/b6OV1z65UokQaMvSeRXt
|
||||
0Yv6wiYtduQI9qpq5nzy/ytaqsbBfClNTi/HifKPKxlRouWFkc518EQI8LBxoarJ
|
||||
AiEA4DaONMplV8PQNa3TKn2F+SDEvLOCjdL0kHKdN90Ti28CIQDDZnTBaHgZwZbA
|
||||
hS7Bbf5yvwjWMhO6Y7l04/Qm7R+35QIgPuQuqXIoUSD080mp1N5WyRW++atksIF+
|
||||
5lGv9e6GP/MCICnj8y/rl6Pd7tXDN6zcSeqLrfdNsREKhB3dKOCXgW9JAiAFYtFS
|
||||
EJNBXVRTK42SNsZ2hJ/9xLwOwnH2epT8Q43s3Q==
|
||||
-----END RSA PRIVATE KEY-----
|
||||
`.trim()
|
||||
|
||||
let pkcs8_private = `
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIIBUgIBADANBgkqhkiG9w0BAQEFAASCATwwggE4AgEAAkEAqyNKUPxEUaSdzrtf
|
||||
dFyXnRavOOpw2D+dqzrV8g8ZRSuQ96eiSbtkcLCsMpbEPcWNMWD6UWVGSjBHke3v
|
||||
YJkTSwIDAQABAj9vo5XXPrlSiRBoy9J5Fe3Ri/rCJi125Aj2qmrmfPL/K1qqxsF8
|
||||
KU1OL8eJ8o8rGVGi5YWRznXwRAjwsHGhqskCIQDgNo40ymVXw9A1rdMqfYX5IMS8
|
||||
s4KN0vSQcp033ROLbwIhAMNmdMFoeBnBlsCFLsFt/nK/CNYyE7pjuXTj9CbtH7fl
|
||||
AiA+5C6pcihRIPTzSanU3lbJFb75q2SwgX7mUa/17oY/8wIgKePzL+uXo93u1cM3
|
||||
rNxJ6out902xEQqEHd0o4JeBb0kCIAVi0VIQk0FdVFMrjZI2xnaEn/3EvA7CcfZ6
|
||||
lPxDjezd
|
||||
-----END PRIVATE KEY-----
|
||||
`.trim()
|
||||
|
||||
let data = `
|
||||
NodeRsa
|
||||
这是node-rsa 现在修改集成在drpy里使用`.trim();
|
||||
|
||||
let encryptedWithPublic = NODERSA.encryptRSAWithPublicKey(data, pkcs1_public, {
|
||||
// PublicFormat: "pkcs1-public-pem",
|
||||
outputEncoding: "base64",
|
||||
options: {environment: "browser", encryptionScheme: 'pkcs1_oaep'},
|
||||
});
|
||||
console.log("公钥加密");
|
||||
console.log(encryptedWithPublic);
|
||||
|
||||
|
||||
let decryptedWithPrivate = NODERSA.decryptRSAWithPrivateKey(encryptedWithPublic, pkcs1_private, {
|
||||
// PublicFormat: "pkcs1-private",
|
||||
// outEncoding: "hex"
|
||||
options: {environment: "browser", encryptionScheme: 'pkcs1_oaep'},
|
||||
});
|
||||
console.log("私钥解密");
|
||||
console.log(decryptedWithPrivate);
|
||||
|
||||
|
||||
// https://www.btool.cn/rsa-sign
|
||||
let pkcs1_sha256_sign = NODERSA.sign("1", pkcs1_private, {
|
||||
outputEncoding: "base64",
|
||||
options: {environment: "browser", encryptionScheme: 'pkcs1', signingScheme: "pkcs1-sha256"},
|
||||
});
|
||||
console.log("pkcs1_sha256_sign");
|
||||
console.log(pkcs1_sha256_sign);
|
||||
|
||||
let pkcs1_sha256_sign_verify = NODERSA.verify("1", "Oulx2QrgeipKYBtqEDqFb2s/+ndk2cGQxO4CkhU7iBM1vyNmmvqubpsmeoUuN3waGrYZLknSEdwBkfv0tUMpFQ==", pkcs1_private, {
|
||||
options: {environment: "browser", encryptionScheme: 'pkcs1', signingScheme: "pkcs1-sha256"},
|
||||
});
|
||||
console.log("pkcs1_sha256_sign_verify");
|
||||
console.log(pkcs1_sha256_sign_verify);
|
||||
|
||||
let pkcs1_oaep_sha256 = NODERSA.encryptRSAWithPublicKey(data, `-----BEGIN RSA PUBLIC KEY-----
|
||||
MIIBCgKCAQEA5KOq1gRNyllLNWKQy8sGpZE3Q1ULLSmzZw+eaAhj9lvqn7IsT1du
|
||||
SYn08FfoOA2qMwtz+1O2l1mgzNoSVCyVpVabnTG+C9XKeZXAnJHd8aYA7l7Sxhdm
|
||||
kte+iymYZ0ZBPzijo8938iugtVvqi9UgDmnY3u/NlQDqiL5BGqSxSTd/Sgmy3zD8
|
||||
PYzEa3wD9vehQ5fZZ45vKIq8GNVh2Z8+IGO85FF1OsN7+b2yGJa/FmDDNn0+HP+m
|
||||
PfI+kYBqEVpo0Ztbc3UdxgFwGC8O1n8AQyriwHnSOtIiuBH62J/7qyC/3LEAApRb
|
||||
Dd9YszqzmODjQUddZKHmvc638VW+azc0EwIDAQAB
|
||||
-----END RSA PUBLIC KEY-----
|
||||
`, {
|
||||
outputEncoding: "base64",
|
||||
options: {
|
||||
environment: "browser", encryptionScheme: {
|
||||
scheme: "pkcs1_oaep",
|
||||
hash: "sha256",
|
||||
},
|
||||
}
|
||||
// options: { environment: "browser", encryptionScheme: 'pkcs1' },
|
||||
});
|
||||
console.log("pkcs1_oaep_sha256");
|
||||
console.log(pkcs1_oaep_sha256);
|
||||
|
||||
decryptedWithPrivate = NODERSA.decryptRSAWithPrivateKey("kSZesAAyYh2hdsQnYMdGqb6gKAzTauBKouvBzWcc4+F8RvGd0nwO6mVkUMVilPgUuNxjEauHayHiY8gI3Py45UI3+km0rSGyHrS6dHiHgCkMejXHieglYzAB0IxX3Jkm4z/66bdB/D+GFy0oct5fGCMI1UHPjEAYOsazJDa8lBFNbjiWFeb/qiZtIx3vGM7KYPAZzyRf/zPbbQ8zy9xOmRuOl5nnIxgo0Okp3KO/RIPO4GZOSBA8f2lx1UtNwwrXAMpcNavtoqHVcjJ/9lcotXYQFrn5b299pSIRf2gVm8ZJ31SK6Z8cc14nKtvgnmsgClDzIXJ1o1RcDK+knVAySg==", `-----BEGIN RSA PRIVATE KEY-----
|
||||
MIIEpAIBAAKCAQEA5KOq1gRNyllLNWKQy8sGpZE3Q1ULLSmzZw+eaAhj9lvqn7Is
|
||||
T1duSYn08FfoOA2qMwtz+1O2l1mgzNoSVCyVpVabnTG+C9XKeZXAnJHd8aYA7l7S
|
||||
xhdmkte+iymYZ0ZBPzijo8938iugtVvqi9UgDmnY3u/NlQDqiL5BGqSxSTd/Sgmy
|
||||
3zD8PYzEa3wD9vehQ5fZZ45vKIq8GNVh2Z8+IGO85FF1OsN7+b2yGJa/FmDDNn0+
|
||||
HP+mPfI+kYBqEVpo0Ztbc3UdxgFwGC8O1n8AQyriwHnSOtIiuBH62J/7qyC/3LEA
|
||||
ApRbDd9YszqzmODjQUddZKHmvc638VW+azc0EwIDAQABAoIBADZ/QGgUzInvsLp/
|
||||
zO2WbfYm39o/uhNAvk9RbLt1TIZbMFhyOpeKynHi3Swwd9xsfWX/U9zS/lGi/m31
|
||||
iKrhmaW4OA1G3vqpMcK7TBbFufYwUEaA+ZJX344euH8pIfdzyneMQ4z3Far2dS7l
|
||||
QsmjuilVV2kEFadveXewiYoVOWCu00w6bN8wy2SIHlQn+kIL6HQhWz12iKKflIKu
|
||||
eGRdzLHsKmBt6WbY1Wuhx7HU0fAKdlBDPxCHNlI+kybUYE9o5C2vJiaVM5wqJBgZ
|
||||
8Dz8kt1QbLJ910JoLXkLVQ8uC8NJKQwFtqQjTGPnEq0+wbgz6Ij599rKZkwW/xq9
|
||||
l6KoUiECgYEA6Ah42tVdkNW047f03xVYXFH96RgorHRS36mR8Y+ONUq1fwKidovC
|
||||
WjwVujt4OPf3l1W6iyn/F6cu/bsmvPrSc3HTN0B1V31QK4OjgetxQ2PSbTldH02J
|
||||
NPzkt+v+cPxXpx/P5mgt7Weefw5txU547KubGrHUV5rBKFtIx9pj16MCgYEA/EF0
|
||||
o19+D24DZAPwlDS5VbEd7FStnwY4oQ5PqbuNOSbSJLMWU0AqzXcRokp8UTyCZ0X3
|
||||
ATkS1REq97kShCuR+npTR6a6DlY7sdpPI1SMLNajgB2tkx0EOzX+PfNIbHUd4jpJ
|
||||
I0ZMAHv/OOtkzQHDaeTWBTrzsWm6/nTiykfduNECgYEA46AMD4HpPECqKAs66e5i
|
||||
tI6q7JSKskObWVdcmQEfnSAhVOwcvPb2Ptda6UuV8S0xcwDi88rLOUUFUFzc79+P
|
||||
vTkY38cYVi/VChsluDpk7ptqv0PbGu5Rf+3n4pZdEjI7OvR2W64wAAn67uIUxc7p
|
||||
yiO/ET0K9rYWb6S9jXGtKMkCgYEA2kPAqoO7zZoBMQ7/oR0lp/HC1HRIbiqx4RlC
|
||||
8Lgpb+QZPEwA6zPAVVvLVENi4d+bbcRp/xLlKpraNNJcJSSWAMbLPFoU7sbKjA87
|
||||
HnTPfRSTEA2d3Ibk3F7Rh8TzS3Ti0JZiJjVzGZAwu41iAMifzwaD8K6boUy80eNN
|
||||
QH2CaaECgYBUsLYvC/MiYg3w+LGOONuQongoVUXjGqnw2bjVa9RK7lwRdXPUqJ51
|
||||
MpVO98IkoLvGSI/0sGNP3GKNhC+eMGjJAVwFyEuOn+JsmMv9Y9uStIVi5tIHIhKw
|
||||
m7mp8il0kaftHdSxTbspG3tZ2fjIiFIZkLEOmRpd7ogWumgOajzUdA==
|
||||
-----END RSA PRIVATE KEY-----`, {
|
||||
// PublicFormat: "pkcs1-private",
|
||||
// outEncoding: "hex"
|
||||
options: {environment: "browser", encryptionScheme: 'pkcs1_oaep'},
|
||||
});
|
||||
console.log('decryptedWithPrivate');
|
||||
console.log(decryptedWithPrivate);
|
||||
|
||||
|
||||
(() => {
|
||||
let key = new NODERSA.NodeRSA({b: 1024});
|
||||
key.setOptions({encryptionScheme: 'pkcs1'})
|
||||
let text = `你好drpy node-ras`;
|
||||
let encrypted = key.encrypt(text, 'base64');
|
||||
console.log('encrypted: ', encrypted);
|
||||
const decrypted = key.decrypt(encrypted, 'utf8');
|
||||
console.log('decrypted: ', decrypted);
|
||||
})();
|
||||
let t2 = new Date().getTime();
|
||||
console.log('rsa_demo_test 测试耗时:' + (t2 - t1) + '毫秒');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 执行预处理代码
|
||||
*/
|
||||
function pre() {
|
||||
if (typeof (rule.预处理) === 'string' && rule.预处理 && rule.预处理.trim()) {
|
||||
let code = rule.预处理.trim();
|
||||
console.log("执行预处理代码:" + code);
|
||||
if (code.startsWith('js:')) {
|
||||
code = code.replace('js:', '');
|
||||
}
|
||||
try {
|
||||
// code里可以进行get 或者 post请求cookie并改变rule.headers 里的cookie
|
||||
// 直接操作 rule_fetch_params 这个变量 .headers.Cookie
|
||||
eval(code);
|
||||
} catch (e) {
|
||||
console.log(`预处理执行失败:${e.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let rule = {};
|
||||
/** 已知问题记录
|
||||
* 1.影魔的jinjia2引擎不支持 {{fl}}对象直接渲染 (有能力解决的话尽量解决下,支持对象直接渲染字符串转义,如果加了|safe就不转义)[影魔牛逼,最新的文件发现这问题已经解决了]
|
||||
* Array.prototype.append = Array.prototype.push; 这种js执行后有毛病,for in 循环列表会把属性给打印出来 (这个大毛病需要重点排除一下)
|
||||
* 2.import es6py.js但是里面的函数没有被装载进来.比如drpy规则报错setResult2 is undefiend(合并文件了可以不管了)
|
||||
* 3.无法重复导入cheerio(怎么解决drpy和parseTag里都需要导入cheerio的问题) 无法在副文件导入cheerio (现在是全部放在drpy一个文件里了,凑合解决?)
|
||||
* 4.有个错误不知道哪儿来的 executeScript: com.quickjs.JSObject$Undefined cannot be cast to java.lang.String 在 点击选集播放打印init_test_end后面打印(貌似不影响使用)
|
||||
* 5.需要实现 stringify 函数,比起JSON.strifngify函数,它会原封不动保留中文不会编码unicode
|
||||
* 6.base64Encode,base64Decode,md5函数还没有实现 (抄影魔代码实现了)
|
||||
* 7.eval(getCryptoJS());还没有实现 (可以空实现了,以后遇到能忽略)
|
||||
* done: jsp:{pdfa,pdfh,pd},json:{pdfa,pdfh,pd},jq:{pdfa,pdfh,pd}
|
||||
* 8.req函数不支持传递字符串的data参数 {'content-type':'text/plain'} 类型数据,因此无法直接调用alist的ocr接口
|
||||
* * 电脑看日志调试
|
||||
adb tcpip 5555
|
||||
adb connect 192.168.10.192
|
||||
adb devices -l
|
||||
adb logcat -c
|
||||
adb logcat | grep -i QuickJS
|
||||
adb logcat -c -b events
|
||||
adb logcat -c -b main -b events -b radio -b system
|
||||
adb logcat > 2.log DRPY:E | grep -i QuickJS
|
||||
* **/
|
||||
|
||||
|
||||
/*** 以下是内置变量和解析方法 **/
|
||||
const MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.91 Mobile Safari/537.36';
|
||||
const PC_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36';
|
||||
const UA = 'Mozilla/5.0';
|
||||
const UC_UA = 'Mozilla/5.0 (Linux; U; Android 9; zh-CN; MI 9 Build/PKQ1.181121.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.108 UCBrowser/12.5.5.1035 Mobile Safari/537.36';
|
||||
const IOS_UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1';
|
||||
const RULE_CK = 'cookie'; // 源cookie的key值
|
||||
// const KEY = typeof(key)!=='undefined'&&key?key:'drpy_' + (rule.title || rule.host); // 源的唯一标识
|
||||
const CATE_EXCLUDE = '首页|留言|APP|下载|资讯|新闻|动态';
|
||||
const TAB_EXCLUDE = '猜你|喜欢|下载|剧情|榜|评论';
|
||||
const OCR_RETRY = 3;//ocr验证重试次数
|
||||
// const OCR_API = 'http://drpy.nokia.press:8028/ocr/drpy/text';//ocr在线识别接口
|
||||
const OCR_API = 'https://api.nn.ci/ocr/b64/text';//ocr在线识别接口
|
||||
if (typeof (MY_URL) === 'undefined') {
|
||||
var MY_URL; // 全局注入变量,pd函数需要
|
||||
}
|
||||
var HOST;
|
||||
var RKEY; // 源的唯一标识
|
||||
var fetch;
|
||||
var print;
|
||||
var log;
|
||||
var rule_fetch_params;
|
||||
var fetch_params; // 每个位置单独的
|
||||
var oheaders;
|
||||
// var play_url; // 二级详情页注入变量,为了适配js模式0 (不在这里定义了,直接二级里定义了个空字符串)
|
||||
var _pdfh;
|
||||
var _pdfa;
|
||||
var _pd;
|
||||
// const DOM_CHECK_ATTR = ['url', 'src', 'href', 'data-original', 'data-src'];
|
||||
const DOM_CHECK_ATTR = /(url|src|href|-original|-src|-play|-url|style)$/;
|
||||
// 过滤特殊链接,不走urlJoin
|
||||
const SPECIAL_URL = /^(ftp|magnet|thunder|ws):/;
|
||||
const NOADD_INDEX = /:eq|:lt|:gt|:first|:last|^body$|^#/; // 不自动加eq下标索引
|
||||
const URLJOIN_ATTR = /(url|src|href|-original|-src|-play|-url|style)$|^(data-|url-|src-)/; // 需要自动urljoin的属性
|
||||
const SELECT_REGEX = /:eq|:lt|:gt|#/g;
|
||||
const SELECT_REGEX_A = /:eq|:lt|:gt/g;
|
||||
|
||||
// 增加$js工具,支持$js.toString(()=>{});
|
||||
const $js = {
|
||||
toString(func) {
|
||||
let strfun = func.toString();
|
||||
return strfun.replace(/^\(\)(\s+)?=>(\s+)?\{/, "js:").replace(/\}$/, '');
|
||||
}
|
||||
};
|
||||
|
||||
function window_b64() {
|
||||
let b64map = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
let base64DecodeChars = new Array(-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
|
||||
|
||||
function btoa(str) {
|
||||
var out, i, len;
|
||||
var c1, c2, c3;
|
||||
len = str.length;
|
||||
i = 0;
|
||||
out = "";
|
||||
while (i < len) {
|
||||
c1 = str.charCodeAt(i++) & 0xff;
|
||||
if (i == len) {
|
||||
out += b64map.charAt(c1 >> 2);
|
||||
out += b64map.charAt((c1 & 0x3) << 4);
|
||||
out += "==";
|
||||
break;
|
||||
}
|
||||
c2 = str.charCodeAt(i++);
|
||||
if (i == len) {
|
||||
out += b64map.charAt(c1 >> 2);
|
||||
out += b64map.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
|
||||
out += b64map.charAt((c2 & 0xF) << 2);
|
||||
out += "=";
|
||||
break;
|
||||
}
|
||||
c3 = str.charCodeAt(i++);
|
||||
out += b64map.charAt(c1 >> 2);
|
||||
out += b64map.charAt(((c1 & 0x3) << 4) | ((c2 & 0xF0) >> 4));
|
||||
out += b64map.charAt(((c2 & 0xF) << 2) | ((c3 & 0xC0) >> 6));
|
||||
out += b64map.charAt(c3 & 0x3F);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function atob(str) {
|
||||
var c1, c2, c3, c4;
|
||||
var i, len, out;
|
||||
len = str.length;
|
||||
i = 0;
|
||||
out = "";
|
||||
while (i < len) {
|
||||
do {
|
||||
c1 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
|
||||
} while (i < len && c1 == -1);
|
||||
if (c1 == -1) break;
|
||||
do {
|
||||
c2 = base64DecodeChars[str.charCodeAt(i++) & 0xff];
|
||||
} while (i < len && c2 == -1);
|
||||
if (c2 == -1) break;
|
||||
out += String.fromCharCode((c1 << 2) | ((c2 & 0x30) >> 4));
|
||||
do {
|
||||
c3 = str.charCodeAt(i++) & 0xff;
|
||||
if (c3 == 61) return out;
|
||||
c3 = base64DecodeChars[c3];
|
||||
} while (i < len && c3 == -1);
|
||||
if (c3 == -1) break;
|
||||
out += String.fromCharCode(((c2 & 0XF) << 4) | ((c3 & 0x3C) >> 2));
|
||||
do {
|
||||
c4 = str.charCodeAt(i++) & 0xff;
|
||||
if (c4 == 61) return out;
|
||||
c4 = base64DecodeChars[c4];
|
||||
} while (i < len && c4 == -1);
|
||||
if (c4 == -1) break;
|
||||
out += String.fromCharCode(((c3 & 0x03) << 6) | c4);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
return {
|
||||
atob,
|
||||
btoa
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
es6py扩展
|
||||
*/
|
||||
if (typeof atob !== 'function' || typeof btoa !== 'function') {
|
||||
var {atob, btoa} = window_b64();
|
||||
}
|
||||
|
||||
if (typeof Object.assign !== 'function') {
|
||||
Object.assign = function () {
|
||||
let target = arguments[0];
|
||||
for (let i = 1; i < arguments.length; i++) {
|
||||
let source = arguments[i];
|
||||
for (let key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
};
|
||||
}
|
||||
if (!String.prototype.includes) {
|
||||
String.prototype.includes = function (search, start) {
|
||||
if (typeof start !== 'number') {
|
||||
start = 0;
|
||||
}
|
||||
|
||||
if (start + search.length > this.length) {
|
||||
return false;
|
||||
} else {
|
||||
return this.indexOf(search, start) !== -1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
if (!Array.prototype.includes) {
|
||||
Object.defineProperty(Array.prototype, 'includes', {
|
||||
value: function (searchElement, fromIndex) {
|
||||
|
||||
if (this == null) {//this是空或者未定义,抛出错误
|
||||
throw new TypeError('"this" is null or not defined');
|
||||
}
|
||||
|
||||
var o = Object(this);//将this转变成对象
|
||||
var len = o.length >>> 0;//无符号右移0位,获取对象length属性,如果未定义就会变成0
|
||||
|
||||
if (len === 0) {//length为0直接返回false未找到目标值
|
||||
return false;
|
||||
}
|
||||
|
||||
var n = fromIndex | 0;//查找起始索引
|
||||
var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);//计算正确起始索引,因为有可能是负值
|
||||
|
||||
while (k < len) {//从起始索引处开始循环
|
||||
if (o[k] === searchElement) {//如果某一位置与寻找目标相等,返回true,找到了
|
||||
return true;
|
||||
}
|
||||
k++;
|
||||
}
|
||||
return false;//未找到,返回false
|
||||
},
|
||||
enumerable: false
|
||||
});
|
||||
}
|
||||
if (typeof String.prototype.startsWith !== 'function') {
|
||||
String.prototype.startsWith = function (prefix) {
|
||||
return this.slice(0, prefix.length) === prefix;
|
||||
};
|
||||
}
|
||||
if (typeof String.prototype.endsWith !== 'function') {
|
||||
String.prototype.endsWith = function (suffix) {
|
||||
return this.indexOf(suffix, this.length - suffix.length) !== -1;
|
||||
};
|
||||
}
|
||||
Object.defineProperty(Object.prototype, 'myValues', {
|
||||
value: function (obj) {
|
||||
if (obj == null) {
|
||||
throw new TypeError("Cannot convert undefined or null to object");
|
||||
}
|
||||
var res = []
|
||||
for (var k in obj) {
|
||||
if (obj.hasOwnProperty(k)) {//需判断是否是本身的属性
|
||||
res.push(obj[k]);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
},
|
||||
enumerable: false
|
||||
});
|
||||
if (typeof Object.prototype.values !== 'function') {
|
||||
Object.defineProperty(Object.prototype, 'values', {
|
||||
value: function (obj) {
|
||||
if (obj == null) {
|
||||
throw new TypeError("Cannot convert undefined or null to object");
|
||||
}
|
||||
var res = []
|
||||
for (var k in obj) {
|
||||
if (obj.hasOwnProperty(k)) {//需判断是否是本身的属性
|
||||
res.push(obj[k]);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
},
|
||||
enumerable: false
|
||||
});
|
||||
}
|
||||
if (typeof Array.prototype.join !== 'function') {
|
||||
Object.defineProperty(Array.prototype, 'join', {
|
||||
value: function (emoji) {
|
||||
// emoji = emoji||',';
|
||||
emoji = emoji || '';
|
||||
let self = this;
|
||||
let str = "";
|
||||
let i = 0;
|
||||
if (!Array.isArray(self)) {
|
||||
throw String(self) + 'is not Array'
|
||||
}
|
||||
if (self.length === 0) {
|
||||
return ''
|
||||
}
|
||||
if (self.length === 1) {
|
||||
return String(self[0])
|
||||
}
|
||||
i = 1;
|
||||
str = this[0];
|
||||
for (; i < self.length; i++) {
|
||||
str += String(emoji) + String(self[i]);
|
||||
}
|
||||
return str;
|
||||
},
|
||||
enumerable: false
|
||||
});
|
||||
}
|
||||
if (typeof Array.prototype.toReversed !== 'function') {
|
||||
Object.defineProperty(Array.prototype, 'toReversed', {
|
||||
value: function () {
|
||||
const clonedList = this.slice();
|
||||
// 倒序新数组
|
||||
const reversedList = clonedList.reverse();
|
||||
return reversedList;
|
||||
},
|
||||
enumerable: false
|
||||
});
|
||||
}
|
||||
|
||||
Object.defineProperty(Array.prototype, 'append', {
|
||||
value: Array.prototype.push,
|
||||
enumerable: false
|
||||
});
|
||||
Object.defineProperty(String.prototype, 'strip', {
|
||||
value: String.prototype.trim,
|
||||
enumerable: false
|
||||
});
|
||||
Object.defineProperty(String.prototype, 'rstrip', {
|
||||
value: function (chars) {
|
||||
let regex = new RegExp(chars + "$");
|
||||
return this.replace(regex, "");
|
||||
},
|
||||
enumerable: false
|
||||
});
|
||||
|
||||
function 是否正版(vipUrl) {
|
||||
let flag = new RegExp('qq\.com|iqiyi\.com|youku\.com|mgtv\.com|bilibili\.com|sohu\.com|ixigua\.com|pptv\.com|miguvideo\.com|le\.com|1905\.com|fun\.tv');
|
||||
return flag.test(vipUrl);
|
||||
}
|
||||
|
||||
function urlDeal(vipUrl) {
|
||||
if (!vipUrl) {
|
||||
return ''
|
||||
}
|
||||
if (!是否正版(vipUrl)) {
|
||||
return vipUrl
|
||||
}
|
||||
if (!/miguvideo/.test(vipUrl)) {
|
||||
vipUrl = vipUrl.split('#')[0].split('?')[0];
|
||||
}
|
||||
return vipUrl
|
||||
}
|
||||
|
||||
function setResult(d) {
|
||||
if (!Array.isArray(d)) {
|
||||
return []
|
||||
}
|
||||
VODS = [];
|
||||
// print(d);
|
||||
d.forEach(function (it) {
|
||||
let obj = {
|
||||
vod_id: it.url || '',
|
||||
vod_name: it.title || '',
|
||||
vod_remarks: it.desc || '',
|
||||
vod_content: it.content || '',
|
||||
vod_pic: it.pic_url || it.img || '',
|
||||
};
|
||||
let keys = Object.keys(it);
|
||||
if (keys.includes('tname')) {
|
||||
obj.type_name = it.tname || '';
|
||||
}
|
||||
if (keys.includes('tid')) {
|
||||
obj.type_id = it.tid || '';
|
||||
}
|
||||
if (keys.includes('year')) {
|
||||
obj.vod_year = it.year || '';
|
||||
}
|
||||
if (keys.includes('actor')) {
|
||||
obj.vod_actor = it.actor || '';
|
||||
}
|
||||
if (keys.includes('director')) {
|
||||
obj.vod_director = it.director || '';
|
||||
}
|
||||
if (keys.includes('area')) {
|
||||
obj.vod_area = it.area || '';
|
||||
}
|
||||
VODS.push(obj);
|
||||
});
|
||||
return VODS
|
||||
}
|
||||
|
||||
function setResult2(res) {
|
||||
VODS = res.list || [];
|
||||
return VODS
|
||||
}
|
||||
|
||||
function setHomeResult(res) {
|
||||
if (!res || typeof (res) !== 'object') {
|
||||
return []
|
||||
}
|
||||
return setResult(res.list);
|
||||
}
|
||||
|
||||
// 猫了个咪
|
||||
function rc(js) {
|
||||
if (js === 'maomi_aes.js') {
|
||||
var a = CryptoJS.enc.Utf8.parse("625222f9149e961d");
|
||||
var t = CryptoJS.enc.Utf8.parse("5efdtf6060e2o330");
|
||||
return {
|
||||
De: function (word) {
|
||||
word = CryptoJS.enc.Hex.parse(word)
|
||||
return CryptoJS.AES.decrypt(CryptoJS.enc.Base64.stringify(word), a, {
|
||||
iv: t,
|
||||
mode: CryptoJS.mode.CBC,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
}).toString(CryptoJS.enc.Utf8)
|
||||
},
|
||||
En: function (word) {
|
||||
// print(a);
|
||||
// print(word);
|
||||
var Encrypted = CryptoJS.AES.encrypt(word, a, {
|
||||
iv: t,
|
||||
mode: CryptoJS.mode.CBC,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
});
|
||||
return Encrypted.ciphertext.toString();
|
||||
}
|
||||
};
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
// 千万不要用for in 推荐 forEach (for in 会打乱顺序)
|
||||
//猫函数
|
||||
function maoss(jxurl, ref, key) {
|
||||
fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
|
||||
eval(getCryptoJS());
|
||||
try {
|
||||
var getVideoInfo = function (text) {
|
||||
return CryptoJS.AES.decrypt(text, key, {iv: iv, padding: CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8);
|
||||
};
|
||||
var token_key = key == undefined ? 'dvyYRQlnPRCMdQSe' : key;
|
||||
if (ref) {
|
||||
var html = request(jxurl, {
|
||||
headers: {
|
||||
'Referer': ref
|
||||
}
|
||||
});
|
||||
} else {
|
||||
var html = request(jxurl);
|
||||
}
|
||||
// print(html);
|
||||
if (html.indexOf('&btwaf=') != -1) {
|
||||
html = request(jxurl + '&btwaf' + html.match(/&btwaf(.*?)"/)[1], {
|
||||
headers: {
|
||||
'Referer': ref
|
||||
}
|
||||
})
|
||||
}
|
||||
var token_iv = html.split('_token = "')[1].split('"')[0];
|
||||
var key = CryptoJS.enc.Utf8.parse(token_key);
|
||||
var iv = CryptoJS.enc.Utf8.parse(token_iv);
|
||||
// log("iv:"+iv);
|
||||
// log(html);
|
||||
// print(key);
|
||||
// print(iv);
|
||||
eval(html.match(/var config = {[\s\S]*?}/)[0] + '');
|
||||
// config.url = config.url.replace(/,/g,'');
|
||||
// print(config.url);
|
||||
if (!config.url.startsWith('http')) {
|
||||
//config.url = decodeURIComponent(AES(config.url, key, iv));
|
||||
config.url = CryptoJS.AES.decrypt(config.url, key, {
|
||||
iv: iv,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
}).toString(CryptoJS.enc.Utf8)
|
||||
}
|
||||
return config.url;
|
||||
} catch (e) {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将base64编码进行url编译
|
||||
* @param str
|
||||
* @returns {string}
|
||||
*/
|
||||
function urlencode(str) {
|
||||
str = (str + '').toString();
|
||||
return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
|
||||
}
|
||||
|
||||
/**
|
||||
* url编码,同 encodeURI
|
||||
* @param str
|
||||
* @returns {string}
|
||||
*/
|
||||
function encodeUrl(str) {
|
||||
if (typeof (encodeURI) == 'function') {
|
||||
return encodeURI(str)
|
||||
} else {
|
||||
str = (str + '').toString();
|
||||
return encodeURIComponent(str).replace(/%2F/g, '/').replace(/%3F/g, '?').replace(/%3A/g, ':').replace(/%40/g, '@').replace(/%3D/g, '=').replace(/%3A/g, ':').replace(/%2C/g, ',').replace(/%2B/g, '+').replace(/%24/g, '$');
|
||||
}
|
||||
}
|
||||
|
||||
function base64Encode(text) {
|
||||
return CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(text));
|
||||
// return text
|
||||
}
|
||||
|
||||
function base64Decode(text) {
|
||||
return CryptoJS.enc.Utf8.stringify(CryptoJS.enc.Base64.parse(text));
|
||||
// return text
|
||||
}
|
||||
|
||||
function md5(text) {
|
||||
return CryptoJS.MD5(text).toString();
|
||||
}
|
||||
|
||||
function uint8ArrayToBase64(uint8Array) {
|
||||
let binaryString = String.fromCharCode.apply(null, Array.from(uint8Array));
|
||||
return btoa(binaryString);
|
||||
}
|
||||
|
||||
function Utf8ArrayToStr(array) {
|
||||
var out, i, len, c;
|
||||
var char2, char3;
|
||||
out = "";
|
||||
len = array.length;
|
||||
i = 0;
|
||||
while (i < len) {
|
||||
c = array[i++];
|
||||
switch (c >> 4) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
case 7:
|
||||
out += String.fromCharCode(c);
|
||||
break;
|
||||
case 12:
|
||||
case 13:
|
||||
char2 = array[i++];
|
||||
out += String.fromCharCode(((c & 0x1f) << 6) | (char2 & 0x3f));
|
||||
break;
|
||||
case 14:
|
||||
char2 = array[i++];
|
||||
char3 = array[i++];
|
||||
out += String.fromCharCode(
|
||||
((c & 0x0f) << 12) | ((char2 & 0x3f) << 6) | ((char3 & 0x3f) << 0)
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* gzip压缩base64|压缩率80%+
|
||||
* @param str
|
||||
* @returns {string}
|
||||
*/
|
||||
function gzip(str) {
|
||||
let arr = pako.gzip(str, {
|
||||
// to: 'string'
|
||||
});
|
||||
return uint8ArrayToBase64(arr)
|
||||
}
|
||||
|
||||
/**
|
||||
* gzip解压base64数据
|
||||
* @param b64Data
|
||||
* @returns {string}
|
||||
*/
|
||||
function ungzip(b64Data) {
|
||||
let strData = atob(b64Data);
|
||||
const charData = strData.split('').map(function (x) {
|
||||
return x.charCodeAt(0);
|
||||
});
|
||||
const binData = new Uint8Array(charData);
|
||||
const data = pako.inflate(binData);
|
||||
return Utf8ArrayToStr(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串按指定编码
|
||||
* @param input
|
||||
* @param encoding
|
||||
* @returns {*}
|
||||
*/
|
||||
function encodeStr(input, encoding) {
|
||||
encoding = encoding || 'gbk';
|
||||
if (encoding.startsWith('gb')) {
|
||||
const strTool = gbkTool();
|
||||
input = strTool.encode(input);
|
||||
}
|
||||
return input
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串指定解码
|
||||
* @param input
|
||||
* @param encoding
|
||||
* @returns {*}
|
||||
*/
|
||||
function decodeStr(input, encoding) {
|
||||
encoding = encoding || 'gbk';
|
||||
if (encoding.startsWith('gb')) {
|
||||
const strTool = gbkTool();
|
||||
input = strTool.decode(input);
|
||||
}
|
||||
return input
|
||||
}
|
||||
|
||||
function getCryptoJS() {
|
||||
// return request('https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/libs/crypto-hiker.js');
|
||||
return 'console.log("CryptoJS已装载");'
|
||||
}
|
||||
|
||||
// 封装的RSA加解密类
|
||||
const RSA = {
|
||||
decode: function (data, key, option) {
|
||||
option = option || {};
|
||||
if (typeof (JSEncrypt) === 'function') {
|
||||
let chunkSize = option.chunkSize || 117; // 默认分段长度为117
|
||||
let privateKey = this.getPrivateKey(key); // 获取私钥
|
||||
const decryptor = new JSEncrypt(); //创建解密对象实例
|
||||
decryptor.setPrivateKey(privateKey); //设置秘钥
|
||||
let uncrypted = '';
|
||||
// uncrypted = decryptor.decrypt(data);
|
||||
uncrypted = decryptor.decryptUnicodeLong(data);
|
||||
return uncrypted;
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
},
|
||||
encode: function (data, key, option) {
|
||||
option = option || {};
|
||||
if (typeof (JSEncrypt) === 'function') {
|
||||
let chunkSize = option.chunkSize || 117; // 默认分段长度为117
|
||||
let publicKey = this.getPublicKey(key); // 获取公钥
|
||||
const encryptor = new JSEncrypt();
|
||||
encryptor.setPublicKey(publicKey); // 设置公钥
|
||||
let encrypted = ''; // 加密结果
|
||||
// const textLen = data.length; // 待加密文本长度
|
||||
// let offset = 0; // 分段偏移量
|
||||
// // 分段加密
|
||||
// while (offset < textLen) {
|
||||
// let chunk = data.slice(offset, chunkSize); // 提取分段数据
|
||||
// let enc = encryptor.encrypt(chunk); // 加密分段数据
|
||||
// encrypted += enc; // 连接加密结果
|
||||
// offset += chunkSize; // 更新偏移量
|
||||
// }
|
||||
encrypted = encryptor.encryptUnicodeLong(data);
|
||||
return encrypted
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
},
|
||||
fixKey(key, prefix, endfix) {
|
||||
if (!key.includes(prefix)) {
|
||||
key = prefix + key;
|
||||
}
|
||||
if (!key.includes(endfix)) {
|
||||
key += endfix
|
||||
}
|
||||
return key
|
||||
},
|
||||
getPrivateKey(key) {
|
||||
let prefix = '-----BEGIN RSA PRIVATE KEY-----';
|
||||
let endfix = '-----END RSA PRIVATE KEY-----';
|
||||
return this.fixKey(key, prefix, endfix);
|
||||
},
|
||||
getPublicKey(key) {
|
||||
let prefix = '-----BEGIN PUBLIC KEY-----';
|
||||
let endfix = '-----END PUBLIC KEY-----';
|
||||
return this.fixKey(key, prefix, endfix);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取壳子返回的代理地址
|
||||
* @returns {string|*}
|
||||
*/
|
||||
function getProxyUrl() {
|
||||
if (typeof (getProxy) === 'function') {//判断壳子里有getProxy函数就执行取返回结果。否则取默认的本地
|
||||
return getProxy(true)
|
||||
} else {
|
||||
return 'http://127.0.0.1:9978/proxy?do=js'
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据正则处理原始m3u8里的广告ts片段,自动修复相对链接
|
||||
* @param m3u8_text m3u8原始文本,里面是最末级的只含ts片段的。不支持嵌套m3u8链接
|
||||
* @param m3u8_url m3u8原始地址
|
||||
* @param ad_remove 正则表达式如: reg:/video/adjump(.*?)ts
|
||||
* @returns {string|DocumentFragment|*|string}
|
||||
*/
|
||||
function fixAdM3u8(m3u8_text, m3u8_url, ad_remove) {
|
||||
if ((!m3u8_text && !m3u8_url) || (!m3u8_text && m3u8_url && !m3u8_url.startsWith('http'))) {
|
||||
return ''
|
||||
}
|
||||
if (!m3u8_text) {
|
||||
log('m3u8_url:' + m3u8_url);
|
||||
m3u8_text = request(m3u8_url);
|
||||
}
|
||||
log('len(m3u8_text):' + m3u8_text.length);
|
||||
if (!ad_remove) {
|
||||
return m3u8_text
|
||||
}
|
||||
if (ad_remove.startsWith('reg:')) {
|
||||
ad_remove = ad_remove.slice(4)
|
||||
} else if (ad_remove.startsWith('js:')) {
|
||||
ad_remove = ad_remove.slice(3)
|
||||
}
|
||||
let m3u8_start = m3u8_text.slice(0, m3u8_text.indexOf('#EXTINF')).trim();
|
||||
let m3u8_body = m3u8_text.slice(m3u8_text.indexOf('#EXTINF'), m3u8_text.indexOf('#EXT-X-ENDLIST')).trim();
|
||||
let m3u8_end = m3u8_text.slice(m3u8_text.indexOf('#EXT-X-ENDLIST')).trim();
|
||||
let murls = [];
|
||||
let m3_body_list = m3u8_body.split('\n');
|
||||
let m3_len = m3_body_list.length;
|
||||
let i = 0;
|
||||
while (i < m3_len) {
|
||||
let mi = m3_body_list[i];
|
||||
let mi_1 = m3_body_list[i + 1];
|
||||
if (mi.startsWith('#EXTINF')) {
|
||||
murls.push([mi, mi_1].join('&'));
|
||||
i += 2
|
||||
} else if (mi.startsWith('#EXT-X-DISCONTINUITY')) {
|
||||
let mi_2 = m3_body_list[i + 2];
|
||||
murls.push([mi, mi_1, mi_2].join('&'));
|
||||
i += 3
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let new_m3u8_body = [];
|
||||
for (let murl of murls) {
|
||||
if (ad_remove && new RegExp(ad_remove).test(murl)) {
|
||||
|
||||
} else {
|
||||
let murl_list = murl.split('&');
|
||||
if (!murl_list[murl_list.length - 1].startsWith('http') && m3u8_url.startsWith('http')) {
|
||||
murl_list[murl_list.length - 1] = urljoin(m3u8_url, murl_list[murl_list.length - 1]);
|
||||
}
|
||||
murl_list.forEach((it) => {
|
||||
new_m3u8_body.push(it);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
new_m3u8_body = new_m3u8_body.join('\n').trim();
|
||||
m3u8_text = [m3u8_start, new_m3u8_body, m3u8_end].join('\n').trim();
|
||||
return m3u8_text
|
||||
}
|
||||
|
||||
/**
|
||||
* 智能对比去除广告。支持嵌套m3u8。只需要传入播放地址
|
||||
* @param m3u8_url m3u8播放地址
|
||||
* @param headers 自定义访问m3u8的请求头,可以不传
|
||||
* @returns {string}
|
||||
*/
|
||||
function fixAdM3u8Ai(m3u8_url, headers) {
|
||||
let ts = new Date().getTime();
|
||||
let option = headers ? {headers: headers} : {};
|
||||
|
||||
function b(s1, s2) {
|
||||
let i = 0;
|
||||
while (i < s1.length) {
|
||||
if (s1[i] !== s2[i]) {
|
||||
break
|
||||
}
|
||||
i++
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
function reverseString(str) {
|
||||
return str.split('').reverse().join('');
|
||||
}
|
||||
|
||||
//log('播放的地址:' + m3u8_url);
|
||||
let m3u8 = request(m3u8_url, option);
|
||||
//log('m3u8处理前:' + m3u8);
|
||||
m3u8 = m3u8.trim().split('\n').map(it => it.startsWith('#') ? it : urljoin(m3u8_url, it)).join('\n');
|
||||
//log('m3u8处理后:============:' + m3u8);
|
||||
// 获取嵌套m3u8地址
|
||||
m3u8 = m3u8.replace(/\n\n/ig, '\n');//删除多余的换行符
|
||||
let last_url = m3u8.split('\n').slice(-1)[0];
|
||||
if (last_url.length < 5) {
|
||||
last_url = m3u8.split('\n').slice(-2)[0];
|
||||
}
|
||||
|
||||
if (last_url.includes('.m3u8') && last_url !== m3u8_url) {
|
||||
m3u8_url = urljoin2(m3u8_url, last_url);
|
||||
log('嵌套的m3u8_url:' + m3u8_url);
|
||||
m3u8 = request(m3u8_url, option);
|
||||
}
|
||||
//log('----处理有广告的地址----');
|
||||
let s = m3u8.trim().split('\n').filter(it => it.trim()).join('\n');
|
||||
let ss = s.split('\n')
|
||||
//找出第一条播放地址
|
||||
//let firststr = ss.find(x => !x.startsWith('#'));
|
||||
let firststr = '';
|
||||
let maxl = 0;//最大相同字符
|
||||
let kk = 0;
|
||||
let kkk = 2;
|
||||
let secondstr = '';
|
||||
for (let i = 0; i < ss.length; i++) {
|
||||
let s = ss[i];
|
||||
if (!s.startsWith("#")) {
|
||||
if (kk == 0) firststr = s;
|
||||
if (kk == 1) maxl = b(firststr, s);
|
||||
if (kk > 1) {
|
||||
if (maxl > b(firststr, s)) {
|
||||
if (secondstr.length < 5) secondstr = s;
|
||||
kkk = kkk + 2;
|
||||
} else {
|
||||
maxl = b(firststr, s);
|
||||
kkk++;
|
||||
}
|
||||
}
|
||||
kk++;
|
||||
if (kk >= 20) break;
|
||||
}
|
||||
}
|
||||
if (kkk > 30) firststr = secondstr;
|
||||
let firststrlen = firststr.length;
|
||||
//log('字符串长度:' + firststrlen);
|
||||
let ml = Math.round(ss.length / 2).toString().length;//取数据的长度的位数
|
||||
//log('数据条数的长度:' + ml);
|
||||
//找出最后一条播放地址
|
||||
let maxc = 0;
|
||||
let laststr = ss.toReversed().find((x) => {
|
||||
if (!x.startsWith('#')) {
|
||||
let k = b(reverseString(firststr), reverseString(x));
|
||||
maxl = b(firststr, x);
|
||||
maxc++;
|
||||
if (firststrlen - maxl <= ml + k || maxc > 10) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
});
|
||||
log('最后一条切片:' + laststr);
|
||||
//log('最小相同字符长度:' + maxl);
|
||||
let ad_urls = [];
|
||||
for (let i = 0; i < ss.length; i++) {
|
||||
let s = ss[i];
|
||||
if (!s.startsWith('#')) {
|
||||
if (b(firststr, s) < maxl) {
|
||||
ad_urls.push(s); // 广告地址加入列表
|
||||
ss.splice(i - 1, 2);
|
||||
i = i - 2;
|
||||
} else {
|
||||
ss[i] = urljoin(m3u8_url, s);
|
||||
}
|
||||
} else {
|
||||
ss[i] = s.replace(/URI=\"(.*)\"/, 'URI=\"' + urljoin(m3u8_url, '$1') + '\"');
|
||||
}
|
||||
}
|
||||
log('处理的m3u8地址:' + m3u8_url);
|
||||
log('----广告地址----');
|
||||
log(ad_urls);
|
||||
m3u8 = ss.join('\n');
|
||||
//log('处理完成');
|
||||
log('处理耗时:' + (new Date().getTime() - ts).toString());
|
||||
return m3u8
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 强制正序算法
|
||||
* @param lists 待正序列表
|
||||
* @param key 正序键
|
||||
* @param option 单个元素处理函数
|
||||
* @returns {*}
|
||||
*/
|
||||
function forceOrder(lists, key, option) {
|
||||
let start = Math.floor(lists.length / 2);
|
||||
let end = Math.min(lists.length - 1, start + 1);
|
||||
if (start >= end) {
|
||||
return lists;
|
||||
}
|
||||
let first = lists[start];
|
||||
let second = lists[end];
|
||||
if (key) {
|
||||
try {
|
||||
first = first[key];
|
||||
second = second[key];
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
if (option && typeof (option) === 'function') {
|
||||
try {
|
||||
first = option(first);
|
||||
second = option(second);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
first += '';
|
||||
second += '';
|
||||
// console.log(first,second);
|
||||
if (first.match(/(\d+)/) && second.match(/(\d+)/)) {
|
||||
let num1 = Number(first.match(/(\d+)/)[1]);
|
||||
let num2 = Number(second.match(/(\d+)/)[1]);
|
||||
if (num1 > num2) {
|
||||
lists.reverse();
|
||||
}
|
||||
}
|
||||
return lists
|
||||
}
|
||||
|
||||
let VODS = [];// 一级或者搜索需要的数据列表
|
||||
let VOD = {};// 二级的单个数据
|
||||
let TABS = [];// 二级的自定义线路列表 如: TABS=['道长在线','道长在线2']
|
||||
let LISTS = [];// 二级的自定义选集播放列表 如: LISTS=[['第1集$http://1.mp4','第2集$http://2.mp4'],['第3集$http://1.mp4','第4集$http://2.mp4']]
|
||||
|
||||
/**
|
||||
* 获取链接的query请求转为js的object字典对象
|
||||
* @param url
|
||||
* @returns {{}}
|
||||
*/
|
||||
function getQuery(url) {
|
||||
try {
|
||||
if (url.indexOf('?') > -1) {
|
||||
url = url.slice(url.indexOf('?') + 1);
|
||||
}
|
||||
let arr = url.split("#")[0].split("&");
|
||||
const resObj = {};
|
||||
arr.forEach(item => {
|
||||
let arr1 = item.split("=");
|
||||
let key = arr1[0];
|
||||
let value = arr1.slice(1).join('=');
|
||||
resObj[key] = value;
|
||||
});
|
||||
return resObj;
|
||||
} catch (err) {
|
||||
log(`getQuery发生错误:${e.message}`)
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* url拼接
|
||||
* @param fromPath 初始当前页面url
|
||||
* @param nowPath 相对当前页面url
|
||||
* @returns {*}
|
||||
*/
|
||||
function urljoin(fromPath, nowPath) {
|
||||
fromPath = fromPath || '';
|
||||
nowPath = nowPath || '';
|
||||
return joinUrl(fromPath, nowPath);
|
||||
// try {
|
||||
// // import Uri from './uri.min.js';
|
||||
// // var Uri = require('./uri.min.js');
|
||||
// // eval(request('https://cdn.bootcdn.net/ajax/libs/URI.js/1.19.11/URI.min.js'));
|
||||
// // let new_uri = URI(nowPath, fromPath);
|
||||
|
||||
// let new_uri = Uri(nowPath, fromPath);
|
||||
// new_uri = new_uri.toString();
|
||||
// // console.log(new_uri);
|
||||
// // return fromPath + nowPath
|
||||
// return new_uri
|
||||
// }
|
||||
// catch (e) {
|
||||
// console.log('urljoin发生错误:'+e.message);
|
||||
// if(nowPath.startsWith('http')){
|
||||
// return nowPath
|
||||
// }if(nowPath.startsWith('/')){
|
||||
// return getHome(fromPath)+nowPath
|
||||
// }
|
||||
// return fromPath+nowPath
|
||||
// }
|
||||
}
|
||||
|
||||
var urljoin2 = urljoin;
|
||||
|
||||
// 内置 pdfh,pdfa,pd
|
||||
const defaultParser = {
|
||||
pdfh: pdfh,
|
||||
pdfa: pdfa,
|
||||
pd: pd,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* pdfh原版优化,能取style属性里的图片链接
|
||||
* @param html 源码
|
||||
* @param parse 解析表达式
|
||||
* @returns {string|*}
|
||||
*/
|
||||
function pdfh2(html, parse) {
|
||||
let html2 = html;
|
||||
try {
|
||||
if (typeof (html) !== 'string') {
|
||||
html2 = html.rr(html.ele).toString();
|
||||
}
|
||||
} catch (e) {
|
||||
print(`html对象转文本发生了错误:${e.message}`);
|
||||
}
|
||||
let result = defaultParser.pdfh(html2, parse);
|
||||
let option = parse.includes('&&') ? parse.split('&&').slice(-1)[0] : parse.split(' ').slice(-1)[0];
|
||||
if (/style/.test(option.toLowerCase()) && /url\(/.test(result)) {
|
||||
try {
|
||||
result = result.match(/url\((.*?)\)/)[1];
|
||||
// 2023/07/28新增 style取内部链接自动去除首尾单双引号
|
||||
result = result.replace(/^['|"](.*)['|"]$/, "$1");
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* pdfa原版优化,可以转换jq的html对象
|
||||
* @param html
|
||||
* @param parse
|
||||
* @returns {*}
|
||||
*/
|
||||
function pdfa2(html, parse) {
|
||||
let html2 = html;
|
||||
try {
|
||||
if (typeof (html) !== 'string') {
|
||||
html2 = html.rr(html.ele).toString();
|
||||
}
|
||||
} catch (e) {
|
||||
print(`html对象转文本发生了错误:${e.message}`);
|
||||
}
|
||||
return defaultParser.pdfa(html2, parse);
|
||||
}
|
||||
|
||||
/**
|
||||
* pd原版方法重写-增加自动urljoin
|
||||
* @param html
|
||||
* @param parse
|
||||
* @param uri
|
||||
* @returns {*}
|
||||
*/
|
||||
function pd2(html, parse, uri) {
|
||||
let ret = pdfh2(html, parse);
|
||||
if (typeof (uri) === 'undefined' || !uri) {
|
||||
uri = '';
|
||||
}
|
||||
if (DOM_CHECK_ATTR.test(parse) && !SPECIAL_URL.test(ret)) {
|
||||
if (/http/.test(ret)) {
|
||||
ret = ret.slice(ret.indexOf('http'));
|
||||
} else {
|
||||
ret = urljoin(MY_URL, ret)
|
||||
}
|
||||
}
|
||||
// MY_URL = getItem('MY_URL',MY_URL);
|
||||
// console.log(`规则${RKEY}打印MY_URL:${MY_URL},uri:${uri}`);
|
||||
return ret
|
||||
}
|
||||
|
||||
const parseTags = {
|
||||
jsp: {
|
||||
pdfh: pdfh2,
|
||||
pdfa: pdfa2,
|
||||
pd: pd2,
|
||||
},
|
||||
json: {
|
||||
pdfh(html, parse) {
|
||||
if (!parse || !parse.trim()) {
|
||||
return '';
|
||||
}
|
||||
if (typeof (html) === 'string') {
|
||||
// print('jsonpath:pdfh字符串转dict');
|
||||
html = JSON.parse(html);
|
||||
}
|
||||
parse = parse.trim();
|
||||
if (!parse.startsWith('$.')) {
|
||||
parse = '$.' + parse;
|
||||
}
|
||||
parse = parse.split('||');
|
||||
for (let ps of parse) {
|
||||
let ret = cheerio.jp(ps, html);
|
||||
if (Array.isArray(ret)) {
|
||||
ret = ret[0] || '';
|
||||
} else {
|
||||
ret = ret || ''
|
||||
}
|
||||
if (ret && typeof (ret) !== 'string') {
|
||||
ret = ret.toString();
|
||||
}
|
||||
if (ret) {
|
||||
return ret
|
||||
}
|
||||
}
|
||||
return '';
|
||||
},
|
||||
pdfa(html, parse) {
|
||||
if (!parse || !parse.trim()) {
|
||||
return '';
|
||||
}
|
||||
if (typeof (html) === 'string') {
|
||||
// print('jsonpath:pdfa字符串转dict');
|
||||
html = JSON.parse(html);
|
||||
}
|
||||
parse = parse.trim()
|
||||
if (!parse.startsWith('$.')) {
|
||||
parse = '$.' + parse;
|
||||
}
|
||||
let ret = cheerio.jp(parse, html);
|
||||
if (Array.isArray(ret) && Array.isArray(ret[0]) && ret.length === 1) {
|
||||
return ret[0] || []
|
||||
}
|
||||
return ret || []
|
||||
},
|
||||
pd(html, parse) {
|
||||
let ret = parseTags.json.pdfh(html, parse);
|
||||
if (ret) {
|
||||
return urljoin(MY_URL, ret);
|
||||
}
|
||||
return ret
|
||||
},
|
||||
},
|
||||
jq: {
|
||||
pdfh(html, parse) {
|
||||
if (!html || !parse || !parse.trim()) {
|
||||
return ''
|
||||
}
|
||||
parse = parse.trim();
|
||||
let result = defaultParser.pdfh(html, parse);
|
||||
// print(`pdfh解析${parse}=>${result}`);
|
||||
return result;
|
||||
},
|
||||
pdfa(html, parse) {
|
||||
if (!html || !parse || !parse.trim()) {
|
||||
return [];
|
||||
}
|
||||
parse = parse.trim();
|
||||
let result = defaultParser.pdfa(html, parse);
|
||||
// print(result);
|
||||
print(`pdfa解析${parse}=>${result.length}`);
|
||||
return result;
|
||||
},
|
||||
pd(html, parse, base_url) {
|
||||
if (!html || !parse || !parse.trim()) {
|
||||
return ''
|
||||
}
|
||||
parse = parse.trim();
|
||||
base_url = base_url || MY_URL;
|
||||
return defaultParser.pd(html, parse, base_url);
|
||||
},
|
||||
},
|
||||
getParse(p0) {//非js开头的情况自动获取解析标签
|
||||
if (p0.startsWith('jsp:')) {
|
||||
return this.jsp
|
||||
} else if (p0.startsWith('json:')) {
|
||||
return this.json
|
||||
} else if (p0.startsWith('jq:')) {
|
||||
return this.jq
|
||||
} else {
|
||||
return this.jq
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const stringify = JSON.stringify;
|
||||
const jsp = parseTags.jsp;
|
||||
const jq = parseTags.jq;
|
||||
|
||||
/*** 后台需要实现的java方法并注入到js中 ***/
|
||||
|
||||
/**
|
||||
* 读取本地文件->应用程序目录
|
||||
* @param filePath
|
||||
* @returns {string}
|
||||
*/
|
||||
function readFile(filePath) {
|
||||
filePath = filePath || './uri.min.js';
|
||||
var fd = os.open(filePath);
|
||||
var buffer = new ArrayBuffer(1024);
|
||||
var len = os.read(fd, buffer, 0, 1024);
|
||||
console.log(len);
|
||||
let text = String.fromCharCode.apply(null, new Uint8Array(buffer));
|
||||
console.log(text);
|
||||
return text
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理返回的json数据
|
||||
* @param html
|
||||
* @returns {*}
|
||||
*/
|
||||
function dealJson(html) {
|
||||
try {
|
||||
// html = html.match(/[\w|\W|\s|\S]*?(\{[\w|\W|\s|\S]*\})/).group[1];
|
||||
html = html.trim();
|
||||
if (!((html.startsWith('{') && html.endsWith('}')) || (html.startsWith('[') && html.endsWith(']')))) {
|
||||
html = '{' + html.match(/.*?\{(.*)\}/m)[1] + '}';
|
||||
}
|
||||
} catch (e) {
|
||||
}
|
||||
try {
|
||||
html = JSON.parse(html);
|
||||
} catch (e) {
|
||||
}
|
||||
// console.log(typeof(html));
|
||||
return html;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码识别逻辑,需要java实现(js没有bytes类型,无法调用后端的传递图片二进制获取验证码文本的接口)
|
||||
* @type {{api: string, classification: (function(*=): string)}}
|
||||
*/
|
||||
var OcrApi = {
|
||||
api: OCR_API,
|
||||
classification: function (img) { // img是byte类型,这里不方便搞啊
|
||||
let code = '';
|
||||
try {
|
||||
// let html = request(this.api,{data:{img:img},headers:{'User-Agent':PC_UA},'method':'POST'},true);
|
||||
// html = JSON.parse(html);
|
||||
// code = html.url||'';
|
||||
log('通过drpy_ocr验证码接口过验证...');
|
||||
let html = '';
|
||||
if (this.api.endsWith('drpy/text')) {
|
||||
html = request(this.api, {data: {img: img}, headers: {'User-Agent': PC_UA}, 'method': 'POST'}, true);
|
||||
} else {
|
||||
html = post(this.api, {body: img});
|
||||
}
|
||||
code = html || '';
|
||||
} catch (e) {
|
||||
log(`OCR识别验证码发生错误:${e.message}`)
|
||||
}
|
||||
return code
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* 验证码识别,暂未实现
|
||||
* @param url 验证码图片链接
|
||||
* @returns {string} 验证成功后的cookie
|
||||
*/
|
||||
function verifyCode(url) {
|
||||
let cnt = 0;
|
||||
let host = getHome(url);
|
||||
let cookie = '';
|
||||
while (cnt < OCR_RETRY) {
|
||||
try {
|
||||
// let obj = {headers:headers,timeout:timeout};
|
||||
let yzm_url = `${host}/index.php/verify/index.html`;
|
||||
console.log(`验证码链接:${yzm_url}`);
|
||||
let hhtml = request(yzm_url, {withHeaders: true, toBase64: true}, true);
|
||||
let json = JSON.parse(hhtml);
|
||||
if (!cookie) {
|
||||
// print(json);
|
||||
let setCk = Object.keys(json).find(it => it.toLowerCase() === 'set-cookie');
|
||||
// cookie = json['set-cookie']?json['set-cookie'].split(';')[0]:'';
|
||||
cookie = setCk ? json[setCk].split(';')[0] : '';
|
||||
}
|
||||
// console.log(hhtml);
|
||||
console.log('cookie:' + cookie);
|
||||
let img = json.body;
|
||||
// console.log(img);
|
||||
let code = OcrApi.classification(img);
|
||||
console.log(`第${cnt + 1}次验证码识别结果:${code}`);
|
||||
let submit_url = `${host}/index.php/ajax/verify_check?type=search&verify=${code}`;
|
||||
console.log(submit_url);
|
||||
let html = request(submit_url, {headers: {Cookie: cookie}, 'method': 'POST'});
|
||||
// console.log(html);
|
||||
html = JSON.parse(html);
|
||||
if (html.msg === 'ok') {
|
||||
console.log(`第${cnt + 1}次验证码提交成功`);
|
||||
return cookie // 需要返回cookie
|
||||
} else if (html.msg !== 'ok' && cnt + 1 >= OCR_RETRY) {
|
||||
cookie = ''; // 需要清空返回cookie
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(`第${cnt + 1}次验证码提交失败:${e.message}`);
|
||||
if (cnt + 1 >= OCR_RETRY) {
|
||||
cookie = '';
|
||||
}
|
||||
}
|
||||
cnt += 1
|
||||
}
|
||||
return cookie
|
||||
}
|
||||
|
||||
/**
|
||||
* 存在数据库配置表里, key字段对应值value,没有就新增,有就更新,调用此方法会清除key对应的内存缓存
|
||||
* @param k 键
|
||||
* @param v 值
|
||||
*/
|
||||
function setItem(k, v) {
|
||||
local.set(RKEY, k, v);
|
||||
console.log(`规则${RKEY}设置${k} => ${v}`)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库配置表对应的key字段的value,没有这个key就返回value默认传参.需要有缓存,第一次获取后会存在内存里
|
||||
* @param k 键
|
||||
* @param v 值
|
||||
* @returns {*}
|
||||
*/
|
||||
function getItem(k, v) {
|
||||
return local.get(RKEY, k) || v;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除数据库key对应的一条数据,并清除此key对应的内存缓存
|
||||
* @param k
|
||||
*/
|
||||
function clearItem(k) {
|
||||
local.delete(RKEY, k);
|
||||
}
|
||||
|
||||
/*** js自封装的方法 ***/
|
||||
|
||||
/**
|
||||
* 获取链接的host(带http协议的完整链接)
|
||||
* @param url 任意一个正常完整的Url,自动提取根
|
||||
* @returns {string}
|
||||
*/
|
||||
function getHome(url) {
|
||||
if (!url) {
|
||||
return ''
|
||||
}
|
||||
let tmp = url.split('//');
|
||||
url = tmp[0] + '//' + tmp[1].split('/')[0];
|
||||
try {
|
||||
url = decodeURIComponent(url);
|
||||
} catch (e) {
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
||||
/**
|
||||
* get参数编译链接,类似python params字典自动拼接
|
||||
* @param url 访问链接
|
||||
* @param obj 参数字典
|
||||
* @returns {*}
|
||||
*/
|
||||
function buildUrl(url, obj) {
|
||||
obj = obj || {};
|
||||
if (url.indexOf('?') < 0) {
|
||||
url += '?'
|
||||
}
|
||||
let param_list = [];
|
||||
let keys = Object.keys(obj);
|
||||
keys.forEach(it => {
|
||||
param_list.push(it + '=' + obj[it])
|
||||
});
|
||||
let prs = param_list.join('&');
|
||||
if (keys.length > 0 && !url.endsWith('?')) {
|
||||
url += '&'
|
||||
}
|
||||
url += prs;
|
||||
return url
|
||||
}
|
||||
|
||||
/**
|
||||
* 远程依赖执行函数
|
||||
* @param url 远程js地址
|
||||
*/
|
||||
function $require(url) {
|
||||
eval(request(url));
|
||||
}
|
||||
|
||||
/**
|
||||
* 将obj所有key变小写
|
||||
* @param obj
|
||||
*/
|
||||
function keysToLowerCase(obj) {
|
||||
return Object.keys(obj).reduce((result, key) => {
|
||||
const newKey = key.toLowerCase();
|
||||
result[newKey] = obj[key]; // 如果值也是对象,可以递归调用本函数
|
||||
return result;
|
||||
}, {});
|
||||
}
|
||||
|
||||
//字符串To对象
|
||||
function parseQueryString(query) {
|
||||
const params = {};
|
||||
query.split('&').forEach(function (part) {
|
||||
// 使用正则表达式匹配键和值,直到遇到第一个等号为止
|
||||
const regex = /^(.*?)=(.*)/;
|
||||
const match = part.match(regex);
|
||||
if (match) {
|
||||
const key = decodeURIComponent(match[1]);
|
||||
const value = decodeURIComponent(match[2]);
|
||||
params[key] = value;
|
||||
}
|
||||
});
|
||||
return params;
|
||||
}
|
||||
|
||||
//URL需要转码字符串
|
||||
function encodeIfContainsSpecialChars(value) {
|
||||
// 定义在URL中需要编码的特殊字符
|
||||
const specialChars = ":/?#[]@!$'()*+,;=%";
|
||||
// 检查值中是否包含特殊字符
|
||||
if (specialChars.split('').some(char => value.includes(char))) {
|
||||
// 如果包含,则使用encodeURIComponent进行编码
|
||||
return encodeURIComponent(value);
|
||||
}
|
||||
// 如果不包含特殊字符,返回原值
|
||||
return value;
|
||||
}
|
||||
|
||||
//对象To字符串
|
||||
function objectToQueryString(obj) {
|
||||
const encoded = [];
|
||||
for (let key in obj) {
|
||||
if (obj.hasOwnProperty(key)) {
|
||||
encoded.push(encodeURIComponent(key) + '=' + encodeIfContainsSpecialChars(obj[key]));
|
||||
}
|
||||
}
|
||||
return encoded.join('&');
|
||||
}
|
||||
|
||||
/**
|
||||
* 海阔网页请求函数完整封装
|
||||
* @param url 请求链接
|
||||
* @param obj 请求对象 {headers:{},method:'',timeout:5000,body:'',withHeaders:false}
|
||||
* @param ocr_flag 标识此flag是用于请求ocr识别的,自动过滤content-type指定编码
|
||||
* @returns {string|string|DocumentFragment|*}
|
||||
*/
|
||||
function request(url, obj, ocr_flag) {
|
||||
ocr_flag = ocr_flag || false;
|
||||
if (typeof (obj) === 'undefined' || !obj || obj === {}) {
|
||||
if (!fetch_params || !fetch_params.headers) {
|
||||
let headers = {
|
||||
'User-Agent': MOBILE_UA,
|
||||
};
|
||||
if (rule.headers) {
|
||||
Object.assign(headers, rule.headers);
|
||||
}
|
||||
if (!fetch_params) {
|
||||
fetch_params = {};
|
||||
}
|
||||
fetch_params.headers = headers;
|
||||
}
|
||||
if (!fetch_params.headers.Referer) {
|
||||
fetch_params.headers.Referer = getHome(url)
|
||||
}
|
||||
obj = fetch_params;
|
||||
} else {
|
||||
let headers = obj.headers || {};
|
||||
let keys = Object.keys(headers).map(it => it.toLowerCase());
|
||||
if (!keys.includes('user-agent')) {
|
||||
headers['User-Agent'] = MOBILE_UA;
|
||||
// fetch_params 里存在ua则优先,否则才默认手机UA
|
||||
if (typeof (fetch_params) === 'object' && fetch_params && fetch_params.headers) {
|
||||
let fetch_headers = keysToLowerCase(fetch_params.headers);
|
||||
if (fetch_headers['user-agent']) {
|
||||
headers['User-Agent'] = fetch_headers['user-agent'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!keys.includes('referer')) {
|
||||
headers['Referer'] = getHome(url);
|
||||
}
|
||||
obj.headers = headers;
|
||||
}
|
||||
if (rule.encoding && rule.encoding !== 'utf-8' && !ocr_flag) {
|
||||
if (!obj.headers.hasOwnProperty('Content-Type') && !obj.headers.hasOwnProperty('content-type')) { // 手动指定了就不管
|
||||
obj.headers["Content-Type"] = 'text/html; charset=' + rule.encoding;
|
||||
}
|
||||
}
|
||||
if (typeof (obj.body) != 'undefined' && obj.body && typeof (obj.body) === 'string') {
|
||||
// let data = {};
|
||||
// obj.body.split('&').forEach(it=>{
|
||||
// data[it.split('=')[0]] = it.split('=')[1]
|
||||
// });
|
||||
// obj.data = data;
|
||||
// delete obj.body
|
||||
|
||||
// 传body加 "Content-Type":"application/x-www-form-urlencoded;" 即可post form
|
||||
if (!obj.headers.hasOwnProperty('Content-Type') && !obj.headers.hasOwnProperty('content-type')) { // 手动指定了就不管
|
||||
obj.headers["Content-Type"] = 'application/x-www-form-urlencoded; charset=' + rule.encoding;
|
||||
}
|
||||
} else if (typeof (obj.body) != 'undefined' && obj.body && typeof (obj.body) === 'object') {
|
||||
obj.data = obj.body;
|
||||
delete obj.body
|
||||
}
|
||||
if (!url) {
|
||||
return obj.withHeaders ? '{}' : ''
|
||||
}
|
||||
if (obj.toBase64) { // 返回base64,用于请求图片
|
||||
obj.buffer = 2;
|
||||
delete obj.toBase64
|
||||
}
|
||||
if (obj.redirect === false) {
|
||||
obj.redirect = 0;
|
||||
}
|
||||
if (obj.headers.hasOwnProperty('Content-Type') || obj.headers.hasOwnProperty('content-type')) {
|
||||
let _contentType = obj.headers["Content-Type"] || obj.headers["content-type"] || "";
|
||||
if (_contentType.includes("application/x-www-form-urlencoded")) {
|
||||
log("custom body is application/x-www-form-urlencoded");
|
||||
//console.log(JSON.stringify(obj));
|
||||
if (typeof obj.body == "string") {
|
||||
let temp_obj = parseQueryString(obj.body);
|
||||
//obj.body = objectToQueryString(temp_obj);
|
||||
console.log(JSON.stringify(temp_obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log(JSON.stringify(obj.headers));
|
||||
// console.log('request:'+url+' obj:'+JSON.stringify(obj));
|
||||
console.log('request:' + url + `|method:${obj.method || 'GET'}|body:${obj.body || ''}`);
|
||||
let res = req(url, obj);
|
||||
let html = res.content || '';
|
||||
// console.log(html);
|
||||
if (obj.withHeaders) {
|
||||
let htmlWithHeaders = res.headers;
|
||||
htmlWithHeaders.body = html;
|
||||
return JSON.stringify(htmlWithHeaders);
|
||||
} else {
|
||||
return html
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 快捷post请求
|
||||
* @param url 地址
|
||||
* @param obj 对象
|
||||
* @returns {string|DocumentFragment|*}
|
||||
*/
|
||||
function post(url, obj) {
|
||||
obj = obj || {};
|
||||
obj.method = 'POST';
|
||||
return request(url, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 快捷获取特殊地址cookie|一般用作搜索过验证
|
||||
* 用法 let {cookie,html} = reqCookie(url);
|
||||
* @param url 能返回cookie的地址
|
||||
* @param obj 常规请求参数
|
||||
* @param all_cookie 返回全部cookie.默认false只返回第一个,一般是PhpSessionId
|
||||
* @returns {{cookie: string, html: (*|string|DocumentFragment)}}
|
||||
*/
|
||||
function reqCookie(url, obj, all_cookie) {
|
||||
obj = obj || {};
|
||||
obj.withHeaders = true;
|
||||
all_cookie = all_cookie || false;
|
||||
let html = request(url, obj);
|
||||
let json = JSON.parse(html);
|
||||
let setCk = Object.keys(json).find(it => it.toLowerCase() === 'set-cookie');
|
||||
let cookie = setCk ? json[setCk] : '';
|
||||
if (Array.isArray(cookie)) {
|
||||
cookie = cookie.join(';')
|
||||
}
|
||||
if (!all_cookie) {
|
||||
cookie = cookie.split(';')[0];
|
||||
}
|
||||
html = json.body;
|
||||
return {
|
||||
cookie,
|
||||
html
|
||||
}
|
||||
}
|
||||
|
||||
fetch = request;
|
||||
print = function (data) {
|
||||
data = data || '';
|
||||
if (typeof (data) == 'object' && Object.keys(data).length > 0) {
|
||||
try {
|
||||
data = JSON.stringify(data);
|
||||
console.log(data);
|
||||
} catch (e) {
|
||||
// console.log('print:'+e.message);
|
||||
console.log(typeof (data) + ':' + data.length);
|
||||
return
|
||||
}
|
||||
} else if (typeof (data) == 'object' && Object.keys(data).length < 1) {
|
||||
console.log('null object');
|
||||
} else {
|
||||
console.log(data);
|
||||
}
|
||||
}
|
||||
log = print;
|
||||
|
||||
/**
|
||||
* 检查宝塔验证并自动跳过获取正确源码
|
||||
* @param html 之前获取的html
|
||||
* @param url 之前的来源url
|
||||
* @param obj 来源obj
|
||||
* @returns {string|DocumentFragment|*}
|
||||
*/
|
||||
function checkHtml(html, url, obj) {
|
||||
if (/\?btwaf=/.test(html)) {
|
||||
let btwaf = html.match(/btwaf(.*?)"/)[1];
|
||||
url = url.split('#')[0] + '?btwaf' + btwaf;
|
||||
print('宝塔验证访问链接:' + url);
|
||||
html = request(url, obj);
|
||||
}
|
||||
return html
|
||||
}
|
||||
|
||||
/**
|
||||
* 带一次宝塔验证的源码获取
|
||||
* @param url 请求链接
|
||||
* @param obj 请求参数
|
||||
* @returns {string|DocumentFragment}
|
||||
*/
|
||||
function getCode(url, obj) {
|
||||
let html = request(url, obj);
|
||||
html = checkHtml(html, url, obj);
|
||||
return html
|
||||
}
|
||||
|
||||
/**
|
||||
* 源rule专用的请求方法,自动注入cookie
|
||||
* @param url 请求链接
|
||||
* @returns {string|DocumentFragment}
|
||||
*/
|
||||
function getHtml(url) {
|
||||
let obj = {};
|
||||
if (rule.headers) {
|
||||
obj.headers = rule.headers;
|
||||
}
|
||||
let cookie = getItem(RULE_CK, '');
|
||||
if (cookie) {
|
||||
// log('有cookie:'+cookie);
|
||||
if (obj.headers && !Object.keys(obj.headers).map(it => it.toLowerCase()).includes('cookie')) {
|
||||
log('历史无cookie,新增过验证后的cookie');
|
||||
obj.headers['Cookie'] = cookie;
|
||||
} else if (obj.headers && obj.headers.cookie && obj.headers.cookie !== cookie) {
|
||||
obj.headers['Cookie'] = cookie;
|
||||
log('历史有小写过期的cookie,更新过验证后的cookie');
|
||||
} else if (obj.headers && obj.headers.Cookie && obj.headers.Cookie !== cookie) {
|
||||
obj.headers['Cookie'] = cookie;
|
||||
log('历史有大写过期的cookie,更新过验证后的cookie');
|
||||
} else if (!obj.headers) {
|
||||
obj.headers = {Cookie: cookie};
|
||||
log('历史无headers,更新过验证后的含cookie的headers');
|
||||
}
|
||||
}
|
||||
let html = getCode(url, obj);
|
||||
return html
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页分类解析,筛选暂未实现
|
||||
* @param homeObj 首页传参对象
|
||||
* @returns {string}
|
||||
*/
|
||||
function homeParse(homeObj) {
|
||||
fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
|
||||
let classes = [];
|
||||
if (homeObj.class_name && homeObj.class_url) {
|
||||
let names = homeObj.class_name.split('&');
|
||||
let urls = homeObj.class_url.split('&');
|
||||
let cnt = Math.min(names.length, urls.length);
|
||||
for (let i = 0; i < cnt; i++) {
|
||||
classes.push({
|
||||
'type_id': urls[i],
|
||||
'type_name': names[i]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (homeObj.class_parse) {
|
||||
if (homeObj.class_parse.startsWith('js:')) {
|
||||
var input = homeObj.MY_URL;
|
||||
try {
|
||||
eval(homeObj.class_parse.replace('js:', ''));
|
||||
if (Array.isArray(input)) {
|
||||
classes = input;
|
||||
}
|
||||
} catch (e) {
|
||||
log(`通过js动态获取分类发生了错误:${e.message}`);
|
||||
}
|
||||
} else {
|
||||
let p = homeObj.class_parse.split(';');
|
||||
let p0 = p[0];
|
||||
let _ps = parseTags.getParse(p0);
|
||||
let is_json = p0.startsWith('json:');
|
||||
_pdfa = _ps.pdfa;
|
||||
_pdfh = _ps.pdfh;
|
||||
_pd = _ps.pd;
|
||||
MY_URL = rule.url;
|
||||
if (is_json) {
|
||||
try {
|
||||
let cms_cate_url = homeObj.MY_URL.replace('ac=detail', 'ac=list');
|
||||
let html = homeObj.home_html || getHtml(cms_cate_url);
|
||||
if (html) {
|
||||
if (cms_cate_url === homeObj.MY_URL) {
|
||||
homeHtmlCache = html;
|
||||
}
|
||||
let list = _pdfa(html, p0.replace('json:', ''));
|
||||
if (list && list.length > 0) {
|
||||
classes = list;
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
}
|
||||
} else if (p.length >= 3 && !is_json) { // 可以不写正则
|
||||
try {
|
||||
let html = homeObj.home_html || getHtml(homeObj.MY_URL);
|
||||
if (html) {
|
||||
homeHtmlCache = html;
|
||||
let list = _pdfa(html, p0);
|
||||
if (list && list.length > 0) {
|
||||
list.forEach((it, idex) => {
|
||||
try {
|
||||
let name = _pdfh(it, p[1]);
|
||||
if (homeObj.cate_exclude && (new RegExp(homeObj.cate_exclude).test(name))) {
|
||||
return;
|
||||
}
|
||||
// let url = pdfh(it, p[2]);
|
||||
let url = _pd(it, p[2]);
|
||||
if (p.length > 3 && p[3] && !homeObj.home_html) {
|
||||
let exp = new RegExp(p[3]);
|
||||
url = url.match(exp)[1];
|
||||
}
|
||||
|
||||
classes.push({
|
||||
'type_id': url.trim(),
|
||||
'type_name': name.trim()
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(`分类列表定位第${idex}个元素正常报错:${e.message}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// 排除分类
|
||||
classes = classes.filter(it => !homeObj.cate_exclude || !(new RegExp(homeObj.cate_exclude).test(it.type_name)));
|
||||
let resp = {
|
||||
'class': classes
|
||||
};
|
||||
if (homeObj.filter) {
|
||||
resp.filters = homeObj.filter;
|
||||
}
|
||||
console.log(JSON.stringify(resp));
|
||||
return JSON.stringify(resp);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 推荐和搜索单字段继承一级
|
||||
* @param p 推荐或搜索的解析分割;列表
|
||||
* @param pn 自身列表序号
|
||||
* @param pp 一级解析分割;列表
|
||||
* @param ppn 继承一级序号
|
||||
* @returns {*}
|
||||
*/
|
||||
function getPP(p, pn, pp, ppn) {
|
||||
try {
|
||||
let ps = p[pn] === '*' && pp.length > ppn ? pp[ppn] : p[pn]
|
||||
return ps
|
||||
} catch (e) {
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页推荐列表解析
|
||||
* @param homeVodObj
|
||||
* @returns {string}
|
||||
*/
|
||||
function homeVodParse(homeVodObj) {
|
||||
fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
|
||||
let d = [];
|
||||
MY_URL = homeVodObj.homeUrl;
|
||||
// setItem('MY_URL',MY_URL);
|
||||
console.log(MY_URL);
|
||||
let t1 = (new Date()).getTime();
|
||||
let p = homeVodObj.推荐;
|
||||
print('p:' + p);
|
||||
if (p === '*' && rule.一级) {
|
||||
p = rule.一级;
|
||||
homeVodObj.double = false;
|
||||
}
|
||||
if (!p || typeof (p) !== 'string') {
|
||||
return '{}'
|
||||
}
|
||||
p = p.trim();
|
||||
let pp = rule.一级 ? rule.一级.split(';') : [];
|
||||
if (p.startsWith('js:')) {
|
||||
const TYPE = 'home';
|
||||
var input = MY_URL;
|
||||
HOST = rule.host;
|
||||
eval(p.replace('js:', ''));
|
||||
d = VODS;
|
||||
} else {
|
||||
p = p.split(';');
|
||||
if (!homeVodObj.double && p.length < 5) {
|
||||
return '{}'
|
||||
} else if (homeVodObj.double && p.length < 6) {
|
||||
return '{}'
|
||||
}
|
||||
let p0 = getPP(p, 0, pp, 0)
|
||||
let _ps = parseTags.getParse(p0);
|
||||
_pdfa = _ps.pdfa;
|
||||
_pdfh = _ps.pdfh;
|
||||
_pd = _ps.pd;
|
||||
let is_json = p0.startsWith('json:');
|
||||
p0 = p0.replace(/^(jsp:|json:|jq:)/, '');
|
||||
// print(p[0]);
|
||||
let html = homeHtmlCache || getHtml(MY_URL);
|
||||
homeHtmlCache = undefined;
|
||||
if (is_json) {
|
||||
// print('是json,开始处理');
|
||||
html = dealJson(html);
|
||||
}
|
||||
try {
|
||||
console.log('double:' + homeVodObj.double);
|
||||
if (homeVodObj.double) {
|
||||
let items = _pdfa(html, p0);
|
||||
// console.log(items.length);
|
||||
let p1 = getPP(p, 1, pp, 0);
|
||||
let p2 = getPP(p, 2, pp, 1);
|
||||
let p3 = getPP(p, 3, pp, 2);
|
||||
let p4 = getPP(p, 4, pp, 3);
|
||||
let p5 = getPP(p, 5, pp, 4);
|
||||
let p6 = getPP(p, 6, pp, 5);
|
||||
for (let item of items) {
|
||||
// console.log(p[1]);
|
||||
let items2 = _pdfa(item, p1);
|
||||
// console.log(items2.length);
|
||||
for (let item2 of items2) {
|
||||
try {
|
||||
let title = _pdfh(item2, p2);
|
||||
let img = '';
|
||||
try {
|
||||
img = _pd(item2, p3);
|
||||
} catch (e) {
|
||||
}
|
||||
let desc = '';
|
||||
try {
|
||||
desc = _pdfh(item2, p4);
|
||||
} catch (e) {
|
||||
}
|
||||
let links = [];
|
||||
for (let _p5 of p5.split('+')) {
|
||||
let link = !homeVodObj.detailUrl ? _pd(item2, _p5, MY_URL) : _pdfh(item2, _p5);
|
||||
links.push(link);
|
||||
}
|
||||
let content;
|
||||
if (p.length > 6 && p[6]) {
|
||||
content = _pdfh(item2, p6);
|
||||
} else {
|
||||
content = '';
|
||||
}
|
||||
let vid = links.join('$');
|
||||
if (rule.二级 === '*') {
|
||||
vid = vid + '@@' + title + '@@' + img;
|
||||
}
|
||||
let vod = {
|
||||
vod_name: title,
|
||||
vod_pic: img,
|
||||
vod_remarks: desc,
|
||||
vod_content: content,
|
||||
vod_id: vid
|
||||
};
|
||||
// print(vod);
|
||||
d.push(vod);
|
||||
} catch (e) {
|
||||
console.log(`首页列表双层定位处理发生错误:${e.message}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
let items = _pdfa(html, p0);
|
||||
let p1 = getPP(p, 1, pp, 1);
|
||||
let p2 = getPP(p, 2, pp, 2);
|
||||
let p3 = getPP(p, 3, pp, 3);
|
||||
let p4 = getPP(p, 4, pp, 4);
|
||||
let p5 = getPP(p, 5, pp, 5);
|
||||
|
||||
for (let item of items) {
|
||||
try {
|
||||
let title = _pdfh(item, p1);
|
||||
let img = '';
|
||||
try {
|
||||
img = _pd(item, p2, MY_URL);
|
||||
} catch (e) {
|
||||
}
|
||||
let desc = '';
|
||||
try {
|
||||
desc = _pdfh(item, p3);
|
||||
} catch (e) {
|
||||
}
|
||||
let links = [];
|
||||
for (let _p5 of p4.split('+')) {
|
||||
let link = !homeVodObj.detailUrl ? _pd(item, _p5, MY_URL) : _pdfh(item, _p5);
|
||||
links.push(link);
|
||||
}
|
||||
let content;
|
||||
if (p.length > 5 && p[5]) {
|
||||
content = _pdfh(item, p5);
|
||||
} else {
|
||||
content = ''
|
||||
}
|
||||
let vid = links.join('$');
|
||||
if (rule.二级 === '*') {
|
||||
vid = vid + '@@' + title + '@@' + img;
|
||||
}
|
||||
let vod = {
|
||||
vod_name: title,
|
||||
vod_pic: img,
|
||||
vod_remarks: desc,
|
||||
vod_content: content,
|
||||
vod_id: vid
|
||||
};
|
||||
d.push(vod);
|
||||
|
||||
} catch (e) {
|
||||
console.log(`首页列表单层定位处理发生错误:${e.message}`);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
let t2 = (new Date()).getTime();
|
||||
console.log('加载首页推荐耗时:' + (t2 - t1) + '毫秒');
|
||||
// console.log(JSON.stringify(d));
|
||||
if (rule.图片替换) {
|
||||
if (rule.图片替换.startsWith('js:')) {
|
||||
d.forEach(it => {
|
||||
try {
|
||||
var input = it.vod_pic;
|
||||
eval(rule.图片替换.trim().replace('js:', ''));
|
||||
it.vod_pic = input;
|
||||
} catch (e) {
|
||||
log(`图片:${it.vod_pic}替换错误:${e.message}`);
|
||||
}
|
||||
});
|
||||
} else if (rule.图片替换.includes('=>')) {
|
||||
let replace_from = rule.图片替换.split('=>')[0];
|
||||
let replace_to = rule.图片替换.split('=>')[1];
|
||||
d.forEach(it => {
|
||||
if (it.vod_pic && it.vod_pic.startsWith('http')) {
|
||||
it.vod_pic = it.vod_pic.replace(replace_from, replace_to);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (rule.图片来源) {
|
||||
d.forEach(it => {
|
||||
if (it.vod_pic && it.vod_pic.startsWith('http')) {
|
||||
it.vod_pic = it.vod_pic + rule.图片来源;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (d.length > 0) {
|
||||
print(d.slice(0, 2));
|
||||
}
|
||||
return JSON.stringify({
|
||||
list: d
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 一级分类页数据解析
|
||||
* @param cateObj
|
||||
* @returns {string}
|
||||
*/
|
||||
function categoryParse(cateObj) {
|
||||
fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
|
||||
let p = cateObj.一级;
|
||||
if (!p || typeof (p) !== 'string') {
|
||||
return '{}'
|
||||
}
|
||||
let d = [];
|
||||
// let url = cateObj.url.replaceAll('fyclass', cateObj.tid).replaceAll('fypage', cateObj.pg);
|
||||
let url = cateObj.url.replaceAll('fyclass', cateObj.tid);
|
||||
if (cateObj.pg === 1 && url.includes('[') && url.includes(']')) {
|
||||
url = url.split('[')[1].split(']')[0];
|
||||
} else if (cateObj.pg > 1 && url.includes('[') && url.includes(']')) {
|
||||
url = url.split('[')[0];
|
||||
}
|
||||
if (rule.filter_url) {
|
||||
if (!/fyfilter/.test(url)) {
|
||||
if (!url.endsWith('&') && !rule.filter_url.startsWith('&')) {
|
||||
url += '&'
|
||||
}
|
||||
url += rule.filter_url;
|
||||
} else {
|
||||
url = url.replace('fyfilter', rule.filter_url);
|
||||
}
|
||||
// filter_url支持fyclass
|
||||
url = url.replaceAll('fyclass', cateObj.tid);
|
||||
// console.log('filter:'+cateObj.filter);
|
||||
let fl = cateObj.filter ? cateObj.extend : {};
|
||||
// 自动合并 不同分类对应的默认筛选
|
||||
if (rule.filter_def && typeof (rule.filter_def) === 'object') {
|
||||
try {
|
||||
if (Object.keys(rule.filter_def).length > 0 && rule.filter_def.hasOwnProperty(cateObj.tid)) {
|
||||
let self_fl_def = rule.filter_def[cateObj.tid];
|
||||
if (self_fl_def && typeof (self_fl_def) === 'object') {
|
||||
// 引用传递转值传递,避免污染self变量
|
||||
let fl_def = JSON.parse(JSON.stringify(self_fl_def));
|
||||
fl = Object.assign(fl_def, fl);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
print(`合并不同分类对应的默认筛选出错:${e.message}`);
|
||||
}
|
||||
}
|
||||
let new_url;
|
||||
new_url = cheerio.jinja2(url, {fl: fl, fyclass: cateObj.tid});
|
||||
// console.log('jinjia2执行后的new_url类型为:'+typeof(new_url));
|
||||
url = new_url;
|
||||
}
|
||||
if (/fypage/.test(url)) {
|
||||
if (url.includes('(') && url.includes(')')) {
|
||||
let url_rep = url.match(/.*?\((.*)\)/)[1];
|
||||
// console.log(url_rep);
|
||||
let cnt_page = url_rep.replaceAll('fypage', cateObj.pg);
|
||||
// console.log(cnt_page);
|
||||
let cnt_pg = eval(cnt_page);
|
||||
// console.log(cnt_pg);
|
||||
url = url.replaceAll(url_rep, cnt_pg).replaceAll('(', '').replaceAll(')', '');
|
||||
} else {
|
||||
url = url.replaceAll('fypage', cateObj.pg);
|
||||
}
|
||||
}
|
||||
|
||||
MY_URL = url;
|
||||
// setItem('MY_URL',MY_URL);
|
||||
console.log(MY_URL);
|
||||
p = p.trim();
|
||||
const MY_CATE = cateObj.tid;
|
||||
if (p.startsWith('js:')) {
|
||||
var MY_FL = cateObj.extend;
|
||||
const TYPE = 'cate';
|
||||
var input = MY_URL;
|
||||
const MY_PAGE = cateObj.pg;
|
||||
var desc = '';
|
||||
eval(p.trim().replace('js:', ''));
|
||||
d = VODS;
|
||||
} else {
|
||||
p = p.split(';');
|
||||
if (p.length < 5) {
|
||||
return '{}'
|
||||
}
|
||||
let _ps = parseTags.getParse(p[0]);
|
||||
_pdfa = _ps.pdfa;
|
||||
_pdfh = _ps.pdfh;
|
||||
_pd = _ps.pd;
|
||||
let is_json = p[0].startsWith('json:');
|
||||
p[0] = p[0].replace(/^(jsp:|json:|jq:)/, '');
|
||||
try {
|
||||
let html = getHtml(MY_URL);
|
||||
if (html) {
|
||||
if (is_json) {
|
||||
html = dealJson(html);
|
||||
}
|
||||
let list = _pdfa(html, p[0]);
|
||||
list.forEach(it => {
|
||||
let links = p[4].split('+').map(p4 => {
|
||||
return !rule.detailUrl ? _pd(it, p4, MY_URL) : _pdfh(it, p4);
|
||||
});
|
||||
let link = links.join('$');
|
||||
let vod_id = rule.detailUrl ? MY_CATE + '$' + link : link;
|
||||
|
||||
let vod_name = _pdfh(it, p[1]).replace(/\n|\t/g, '').trim();
|
||||
let vod_pic = _pd(it, p[2], MY_URL);
|
||||
|
||||
if (rule.二级 === '*') {
|
||||
vod_id = vod_id + '@@' + vod_name + '@@' + vod_pic;
|
||||
}
|
||||
d.push({
|
||||
'vod_id': vod_id,
|
||||
'vod_name': vod_name,
|
||||
'vod_pic': vod_pic,
|
||||
'vod_remarks': _pdfh(it, p[3]).replace(/\n|\t/g, '').trim(),
|
||||
});
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
}
|
||||
}
|
||||
if (rule.图片替换) {
|
||||
if (rule.图片替换.startsWith('js:')) {
|
||||
d.forEach(it => {
|
||||
try {
|
||||
var input = it.vod_pic;
|
||||
eval(rule.图片替换.trim().replace('js:', ''));
|
||||
it.vod_pic = input;
|
||||
} catch (e) {
|
||||
log(`图片:${it.vod_pic}替换错误:${e.message}`);
|
||||
}
|
||||
});
|
||||
} else if (rule.图片替换.includes('=>')) {
|
||||
let replace_from = rule.图片替换.split('=>')[0];
|
||||
let replace_to = rule.图片替换.split('=>')[1];
|
||||
d.forEach(it => {
|
||||
if (it.vod_pic && it.vod_pic.startsWith('http')) {
|
||||
it.vod_pic = it.vod_pic.replace(replace_from, replace_to);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (rule.图片来源) {
|
||||
d.forEach(it => {
|
||||
if (it.vod_pic && it.vod_pic.startsWith('http')) {
|
||||
it.vod_pic = it.vod_pic + rule.图片来源;
|
||||
}
|
||||
});
|
||||
}
|
||||
// print(d);
|
||||
if (d.length > 0) {
|
||||
print(d.slice(0, 2));
|
||||
}
|
||||
let pagecount = 0;
|
||||
if (rule.pagecount && typeof (rule.pagecount) === 'object' && rule.pagecount.hasOwnProperty(MY_CATE)) {
|
||||
print(`MY_CATE:${MY_CATE},pagecount:${JSON.stringify(rule.pagecount)}`);
|
||||
pagecount = parseInt(rule.pagecount[MY_CATE]);
|
||||
}
|
||||
let nodata = {
|
||||
list: [{
|
||||
vod_name: '无数据,防无限请求',
|
||||
vod_id: 'no_data',
|
||||
vod_remarks: '不要点,会崩的',
|
||||
vod_pic: 'https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/404.jpg'
|
||||
}],
|
||||
total: 1, pagecount: 1, page: 1, limit: 1
|
||||
};
|
||||
let vod = d.length < 1 ? JSON.stringify(nodata) : JSON.stringify({
|
||||
'page': parseInt(cateObj.pg),
|
||||
'pagecount': pagecount || 999,
|
||||
'limit': 20,
|
||||
'total': 999,
|
||||
'list': d,
|
||||
});
|
||||
// print(vod);
|
||||
return vod
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索列表数据解析
|
||||
* @param searchObj
|
||||
* @returns {string}
|
||||
*/
|
||||
function searchParse(searchObj) {
|
||||
fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
|
||||
let d = [];
|
||||
if (!searchObj.searchUrl) {
|
||||
return '{}'
|
||||
}
|
||||
if (rule.searchNoPage && Number(searchObj.pg) > 1) {
|
||||
// 关闭搜索分页
|
||||
return '{}'
|
||||
}
|
||||
let p = searchObj.搜索 === '*' && rule.一级 ? rule.一级 : searchObj.搜索;
|
||||
if (!p || typeof (p) !== 'string') {
|
||||
return '{}'
|
||||
}
|
||||
p = p.trim();
|
||||
let pp = rule.一级 ? rule.一级.split(';') : [];
|
||||
let url = searchObj.searchUrl.replaceAll('**', searchObj.wd);
|
||||
if (searchObj.pg === 1 && url.includes('[') && url.includes(']') && !url.includes('#')) {
|
||||
url = url.split('[')[1].split(']')[0];
|
||||
} else if (searchObj.pg > 1 && url.includes('[') && url.includes(']') && !url.includes('#')) {
|
||||
url = url.split('[')[0];
|
||||
}
|
||||
|
||||
if (/fypage/.test(url)) {
|
||||
if (url.includes('(') && url.includes(')')) {
|
||||
let url_rep = url.match(/.*?\((.*)\)/)[1];
|
||||
// console.log(url_rep);
|
||||
let cnt_page = url_rep.replaceAll('fypage', searchObj.pg);
|
||||
// console.log(cnt_page);
|
||||
let cnt_pg = eval(cnt_page);
|
||||
// console.log(cnt_pg);
|
||||
url = url.replaceAll(url_rep, cnt_pg).replaceAll('(', '').replaceAll(')', '');
|
||||
} else {
|
||||
url = url.replaceAll('fypage', searchObj.pg);
|
||||
}
|
||||
}
|
||||
|
||||
MY_URL = url;
|
||||
console.log(MY_URL);
|
||||
// log(searchObj.搜索);
|
||||
// setItem('MY_URL',MY_URL);
|
||||
if (p.startsWith('js:')) {
|
||||
const TYPE = 'search';
|
||||
const MY_PAGE = searchObj.pg;
|
||||
const KEY = searchObj.wd;
|
||||
var input = MY_URL;
|
||||
var detailUrl = rule.detailUrl || '';
|
||||
eval(p.trim().replace('js:', ''));
|
||||
d = VODS;
|
||||
} else {
|
||||
p = p.split(';');
|
||||
if (p.length < 5) {
|
||||
return '{}'
|
||||
}
|
||||
let p0 = getPP(p, 0, pp, 0);
|
||||
let _ps = parseTags.getParse(p0);
|
||||
_pdfa = _ps.pdfa;
|
||||
_pdfh = _ps.pdfh;
|
||||
_pd = _ps.pd;
|
||||
let is_json = p0.startsWith('json:');
|
||||
p0 = p0.replace(/^(jsp:|json:|jq:)/, '');
|
||||
// print('1381 p0:'+p0);
|
||||
try {
|
||||
let req_method = MY_URL.split(';').length > 1 ? MY_URL.split(';')[1].toLowerCase() : 'get';
|
||||
let html;
|
||||
if (req_method === 'post') {
|
||||
let rurls = MY_URL.split(';')[0].split('#')
|
||||
let rurl = rurls[0]
|
||||
let params = rurls.length > 1 ? rurls[1] : '';
|
||||
print(`post=》rurl:${rurl},params:${params}`);
|
||||
// let new_dict = {};
|
||||
// let new_tmp = params.split('&');
|
||||
// new_tmp.forEach(i=>{
|
||||
// new_dict[i.split('=')[0]] = i.split('=')[1];
|
||||
// });
|
||||
// html = post(rurl,{body:new_dict});
|
||||
let _fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
|
||||
let postData = {body: params};
|
||||
Object.assign(_fetch_params, postData);
|
||||
html = post(rurl, _fetch_params);
|
||||
} else if (req_method === 'postjson') {
|
||||
let rurls = MY_URL.split(';')[0].split('#')
|
||||
let rurl = rurls[0]
|
||||
let params = rurls.length > 1 ? rurls[1] : '';
|
||||
print(`postjson-》rurl:${rurl},params:${params}`);
|
||||
try {
|
||||
params = JSON.parse(params);
|
||||
} catch (e) {
|
||||
params = '{}'
|
||||
}
|
||||
let _fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
|
||||
let postData = {body: params};
|
||||
Object.assign(_fetch_params, postData);
|
||||
html = post(rurl, _fetch_params);
|
||||
} else {
|
||||
html = getHtml(MY_URL);
|
||||
}
|
||||
if (html) {
|
||||
// 解决搜索源码奇葩触发自动过验证逻辑
|
||||
let search_tag = rule.搜索验证标识 || '系统安全验证|输入验证码';
|
||||
if (new RegExp(search_tag).test(html)) {
|
||||
let cookie = verifyCode(MY_URL);
|
||||
if (cookie) {
|
||||
console.log(`本次成功过验证,cookie:${cookie}`);
|
||||
setItem(RULE_CK, cookie);
|
||||
} else {
|
||||
console.log(`本次自动过搜索验证失败,cookie:${cookie}`);
|
||||
}
|
||||
// obj.headers['Cookie'] = cookie;
|
||||
html = getHtml(MY_URL);
|
||||
}
|
||||
if (!html.includes(searchObj.wd)) {
|
||||
console.log('搜索结果源码未包含关键字,疑似搜索失败,正为您打印结果源码');
|
||||
console.log(html);
|
||||
}
|
||||
if (is_json) {
|
||||
// console.log(html);
|
||||
html = dealJson(html);
|
||||
// console.log(JSON.stringify(html));
|
||||
}
|
||||
// console.log(html);
|
||||
let list = _pdfa(html, p0);
|
||||
// print(list.length);
|
||||
// print(list);
|
||||
let p1 = getPP(p, 1, pp, 1);
|
||||
let p2 = getPP(p, 2, pp, 2);
|
||||
let p3 = getPP(p, 3, pp, 3);
|
||||
let p4 = getPP(p, 4, pp, 4);
|
||||
let p5 = getPP(p, 5, pp, 5);
|
||||
list.forEach(it => {
|
||||
let links = p4.split('+').map(_p4 => {
|
||||
return !rule.detailUrl ? _pd(it, _p4, MY_URL) : _pdfh(it, _p4)
|
||||
});
|
||||
let link = links.join('$');
|
||||
let content;
|
||||
if (p.length > 5 && p[5]) {
|
||||
content = _pdfh(it, p5);
|
||||
} else {
|
||||
content = '';
|
||||
}
|
||||
let vod_id = link;
|
||||
let vod_name = _pdfh(it, p1).replace(/\n|\t/g, '').trim();
|
||||
let vod_pic = _pd(it, p2, MY_URL);
|
||||
if (rule.二级 === '*') {
|
||||
vod_id = vod_id + '@@' + vod_name + '@@' + vod_pic;
|
||||
}
|
||||
let ob = {
|
||||
'vod_id': vod_id,
|
||||
'vod_name': vod_name,
|
||||
'vod_pic': vod_pic,
|
||||
'vod_remarks': _pdfh(it, p3).replace(/\n|\t/g, '').trim(),
|
||||
'vod_content': content.replace(/\n|\t/g, '').trim(),
|
||||
};
|
||||
d.push(ob);
|
||||
});
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
print(`搜索发生错误:${e.message}`);
|
||||
return '{}'
|
||||
}
|
||||
}
|
||||
if (rule.图片替换) {
|
||||
if (rule.图片替换.startsWith('js:')) {
|
||||
d.forEach(it => {
|
||||
try {
|
||||
var input = it.vod_pic;
|
||||
eval(rule.图片替换.trim().replace('js:', ''));
|
||||
it.vod_pic = input;
|
||||
} catch (e) {
|
||||
log(`图片:${it.vod_pic}替换错误:${e.message}`);
|
||||
}
|
||||
});
|
||||
} else if (rule.图片替换.includes('=>')) {
|
||||
let replace_from = rule.图片替换.split('=>')[0];
|
||||
let replace_to = rule.图片替换.split('=>')[1];
|
||||
d.forEach(it => {
|
||||
if (it.vod_pic && it.vod_pic.startsWith('http')) {
|
||||
it.vod_pic = it.vod_pic.replace(replace_from, replace_to);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (rule.图片来源) {
|
||||
d.forEach(it => {
|
||||
if (it.vod_pic && it.vod_pic.startsWith('http')) {
|
||||
it.vod_pic = it.vod_pic + rule.图片来源;
|
||||
}
|
||||
});
|
||||
}
|
||||
// print(d);
|
||||
return JSON.stringify({
|
||||
'page': parseInt(searchObj.pg),
|
||||
'pagecount': 10,
|
||||
'limit': 20,
|
||||
'total': 100,
|
||||
'list': d,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 二级详情页数据解析
|
||||
* @param detailObj
|
||||
* @returns {string}
|
||||
*/
|
||||
function detailParse(detailObj) {
|
||||
let t1 = (new Date()).getTime();
|
||||
fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
|
||||
let orId = detailObj.orId;
|
||||
let vod_name = '片名';
|
||||
let vod_pic = '';
|
||||
let vod_id = orId;
|
||||
if (rule.二级 === '*') {
|
||||
// vod_id = orId.split('@@')[0]; // 千万不能分割
|
||||
let extra = orId.split('@@');
|
||||
vod_name = extra.length > 1 ? extra[1] : vod_name;
|
||||
vod_pic = extra.length > 2 ? extra[2] : vod_pic;
|
||||
}
|
||||
// print(vod_pic);
|
||||
let vod = {
|
||||
vod_id: vod_id, //"id",
|
||||
vod_name: vod_name,
|
||||
vod_pic: vod_pic,
|
||||
type_name: "类型",
|
||||
vod_year: "年份",
|
||||
vod_area: "地区",
|
||||
vod_remarks: "更新信息",
|
||||
vod_actor: "主演",
|
||||
vod_director: "导演",
|
||||
vod_content: "简介"
|
||||
};
|
||||
let p = detailObj.二级;
|
||||
let url = detailObj.url;
|
||||
let detailUrl = detailObj.detailUrl;
|
||||
let fyclass = detailObj.fyclass;
|
||||
let tab_exclude = detailObj.tab_exclude;
|
||||
let html = detailObj.html || '';
|
||||
MY_URL = url;
|
||||
if (detailObj.二级访问前) {
|
||||
try {
|
||||
print(`尝试在二级访问前执行代码:${detailObj.二级访问前}`);
|
||||
eval(detailObj.二级访问前.trim().replace('js:', ''));
|
||||
} catch (e) {
|
||||
print(`二级访问前执行代码出现错误:${e.message}`)
|
||||
}
|
||||
}
|
||||
// console.log(MY_URL);
|
||||
// setItem('MY_URL',MY_URL);
|
||||
if (p === '*') {
|
||||
vod.vod_play_from = '道长在线';
|
||||
vod.vod_remarks = detailUrl;
|
||||
vod.vod_actor = '没有二级,只有一级链接直接嗅探播放';
|
||||
vod.vod_content = MY_URL;
|
||||
vod.vod_play_url = '嗅探播放$' + MY_URL.split('@@')[0];
|
||||
} else if (typeof (p) === 'string' && p.trim().startsWith('js:')) {
|
||||
const TYPE = 'detail';
|
||||
var input = MY_URL;
|
||||
var play_url = '';
|
||||
eval(p.trim().replace('js:', ''));
|
||||
vod = VOD;
|
||||
console.log(JSON.stringify(vod));
|
||||
} else if (p && typeof (p) === 'object') {
|
||||
let tt1 = (new Date()).getTime();
|
||||
if (!html) {
|
||||
html = getHtml(MY_URL);
|
||||
}
|
||||
print(`二级${MY_URL}仅获取源码耗时:${(new Date()).getTime() - tt1}毫秒`);
|
||||
let _ps;
|
||||
if (p.is_json) {
|
||||
print('二级是json');
|
||||
_ps = parseTags.json;
|
||||
html = dealJson(html);
|
||||
} else if (p.is_jsp) {
|
||||
print('二级是jsp');
|
||||
_ps = parseTags.jsp;
|
||||
} else if (p.is_jq) {
|
||||
print('二级是jq');
|
||||
_ps = parseTags.jq;
|
||||
} else {
|
||||
print('二级默认jq');
|
||||
_ps = parseTags.jq;
|
||||
// print('二级默认jsp');
|
||||
// _ps = parseTags.jsp;
|
||||
}
|
||||
let tt2 = (new Date()).getTime();
|
||||
print(`二级${MY_URL}获取并装载源码耗时:${tt2 - tt1}毫秒`);
|
||||
_pdfa = _ps.pdfa;
|
||||
_pdfh = _ps.pdfh;
|
||||
_pd = _ps.pd;
|
||||
if (p.title) {
|
||||
let p1 = p.title.split(';');
|
||||
vod.vod_name = _pdfh(html, p1[0]).replace(/\n|\t/g, '').trim();
|
||||
let type_name = p1.length > 1 ? _pdfh(html, p1[1]).replace(/\n|\t/g, '').replace(/ /g, '').trim() : '';
|
||||
vod.type_name = type_name || vod.type_name;
|
||||
}
|
||||
if (p.desc) {
|
||||
try {
|
||||
let p1 = p.desc.split(';');
|
||||
vod.vod_remarks = _pdfh(html, p1[0]).replace(/\n|\t/g, '').trim();
|
||||
vod.vod_year = p1.length > 1 ? _pdfh(html, p1[1]).replace(/\n|\t/g, '').trim() : '';
|
||||
vod.vod_area = p1.length > 2 ? _pdfh(html, p1[2]).replace(/\n|\t/g, '').trim() : '';
|
||||
// vod.vod_actor = p1.length > 3 ? _pdfh(html, p1[3]).replaceAll('\n', ' ').trim():'';
|
||||
vod.vod_actor = p1.length > 3 ? _pdfh(html, p1[3]).replace(/\n|\t/g, '').trim() : '';
|
||||
vod.vod_director = p1.length > 4 ? _pdfh(html, p1[4]).replace(/\n|\t/g, '').trim() : '';
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
}
|
||||
if (p.content) {
|
||||
try {
|
||||
let p1 = p.content.split(';');
|
||||
vod.vod_content = _pdfh(html, p1[0]).replace(/\n|\t/g, '').trim();
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
if (p.img) {
|
||||
try {
|
||||
let p1 = p.img.split(';');
|
||||
vod.vod_pic = _pd(html, p1[0], MY_URL);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
|
||||
let vod_play_from = '$$$';
|
||||
let playFrom = [];
|
||||
if (p.重定向 && p.重定向.startsWith('js:')) {
|
||||
print('开始执行重定向代码:' + p.重定向);
|
||||
html = eval(p.重定向.replace('js:', ''));
|
||||
}
|
||||
|
||||
// console.log(2);
|
||||
if (p.tabs) {
|
||||
if (p.tabs.startsWith('js:')) {
|
||||
print('开始执行tabs代码:' + p.tabs);
|
||||
var input = MY_URL;
|
||||
eval(p.tabs.replace('js:', ''));
|
||||
playFrom = TABS;
|
||||
} else {
|
||||
let p_tab = p.tabs.split(';')[0];
|
||||
// console.log(p_tab);
|
||||
let vHeader = _pdfa(html, p_tab);
|
||||
console.log(vHeader.length);
|
||||
let tab_text = p.tab_text || 'body&&Text';
|
||||
// print('tab_text:'+tab_text);
|
||||
let new_map = {};
|
||||
for (let v of vHeader) {
|
||||
let v_title = _pdfh(v, tab_text).trim();
|
||||
if (!v_title) {
|
||||
v_title = '线路空'
|
||||
}
|
||||
console.log(v_title);
|
||||
if (tab_exclude && (new RegExp(tab_exclude)).test(v_title)) {
|
||||
continue;
|
||||
}
|
||||
if (!new_map.hasOwnProperty(v_title)) {
|
||||
new_map[v_title] = 1;
|
||||
} else {
|
||||
new_map[v_title] += 1;
|
||||
}
|
||||
if (new_map[v_title] > 1) {
|
||||
v_title += Number(new_map[v_title] - 1);
|
||||
}
|
||||
playFrom.push(v_title);
|
||||
}
|
||||
}
|
||||
console.log(JSON.stringify(playFrom));
|
||||
} else {
|
||||
playFrom = ['道长在线']
|
||||
}
|
||||
vod.vod_play_from = playFrom.join(vod_play_from);
|
||||
|
||||
// console.log(3);
|
||||
let vod_play_url = '$$$';
|
||||
let vod_tab_list = [];
|
||||
if (p.lists) {
|
||||
if (p.lists.startsWith('js:')) {
|
||||
print('开始执行lists代码:' + p.lists);
|
||||
try {
|
||||
var input = MY_URL;
|
||||
var play_url = '';
|
||||
eval(p.lists.replace('js:', ''));
|
||||
for (let i in LISTS) {
|
||||
if (LISTS.hasOwnProperty(i)) {
|
||||
// print(i);
|
||||
try {
|
||||
LISTS[i] = LISTS[i].map(it => it.split('$').slice(0, 2).join('$'));
|
||||
} catch (e) {
|
||||
print(`格式化LISTS发生错误:${e.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
vod_play_url = LISTS.map(it => it.join('#')).join(vod_play_url);
|
||||
} catch (e) {
|
||||
print(`js执行lists: 发生错误:${e.message}`);
|
||||
}
|
||||
|
||||
} else {
|
||||
let list_text = p.list_text || 'body&&Text';
|
||||
let list_url = p.list_url || 'a&&href';
|
||||
let list_url_prefix = p.list_url_prefix || '';
|
||||
// print('list_text:'+list_text);
|
||||
// print('list_url:'+list_url);
|
||||
// print('list_parse:'+p.lists);
|
||||
let is_tab_js = p.tabs.trim().startsWith('js:');
|
||||
for (let i = 0; i < playFrom.length; i++) {
|
||||
let tab_name = playFrom[i];
|
||||
let tab_ext = p.tabs.split(';').length > 1 && !is_tab_js ? p.tabs.split(';')[1] : '';
|
||||
let p1 = p.lists.replaceAll('#idv', tab_name).replaceAll('#id', i);
|
||||
tab_ext = tab_ext.replaceAll('#idv', tab_name).replaceAll('#id', i);
|
||||
let tabName = tab_ext ? _pdfh(html, tab_ext) : tab_name;
|
||||
console.log(tabName);
|
||||
// print('tab_ext:'+tab_ext);
|
||||
let new_vod_list = [];
|
||||
let tt1 = (new Date()).getTime();
|
||||
// print('pdfl:'+typeof (pdfl));
|
||||
if (typeof (pdfl) === 'function') {
|
||||
new_vod_list = pdfl(html, p1, list_text, list_url, MY_URL);
|
||||
if (list_url_prefix) {
|
||||
new_vod_list = new_vod_list.map(it => it.split('$')[0] + '$' + list_url_prefix + it.split('$').slice(1).join('$'));
|
||||
}
|
||||
} else {
|
||||
let vodList = [];
|
||||
try {
|
||||
vodList = _pdfa(html, p1);
|
||||
console.log('len(vodList):' + vodList.length);
|
||||
} catch (e) {
|
||||
// console.log(e.message);
|
||||
}
|
||||
for (let i = 0; i < vodList.length; i++) {
|
||||
let it = vodList[i];
|
||||
new_vod_list.push(_pdfh(it, list_text).trim() + '$' + list_url_prefix + _pd(it, list_url, MY_URL));
|
||||
}
|
||||
}
|
||||
if (new_vod_list.length > 0) {
|
||||
new_vod_list = forceOrder(new_vod_list, '', x => x.split('$')[0]);
|
||||
console.log(`drpy影响性能代码共计列表数循环次数:${new_vod_list.length},耗时:${(new Date()).getTime() - tt1}毫秒`);
|
||||
}
|
||||
// print(new_vod_list);
|
||||
let vlist = new_vod_list.join('#');
|
||||
vod_tab_list.push(vlist);
|
||||
}
|
||||
vod_play_url = vod_tab_list.join(vod_play_url);
|
||||
}
|
||||
}
|
||||
vod.vod_play_url = vod_play_url;
|
||||
}
|
||||
if (rule.图片替换 && rule.图片替换.includes('=>')) {
|
||||
let replace_from = rule.图片替换.split('=>')[0];
|
||||
let replace_to = rule.图片替换.split('=>')[1];
|
||||
vod.vod_pic = vod.vod_pic.replace(replace_from, replace_to);
|
||||
}
|
||||
if (rule.图片来源 && vod.vod_pic && vod.vod_pic.startsWith('http')) {
|
||||
vod.vod_pic = vod.vod_pic + rule.图片来源;
|
||||
}
|
||||
if (!vod.vod_id || (vod_id.includes('$') && vod.vod_id !== vod_id)) {
|
||||
vod.vod_id = vod_id;
|
||||
}
|
||||
let t2 = (new Date()).getTime();
|
||||
console.log(`加载二级界面${MY_URL}耗时:${t2 - t1}毫秒`);
|
||||
// print(vod);
|
||||
try {
|
||||
vod = vodDeal(vod);
|
||||
} catch (e) {
|
||||
console.log(`vodDeal发生错误:${e.message}`);
|
||||
}
|
||||
// print(vod);
|
||||
return JSON.stringify({
|
||||
list: [vod]
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取二级待返回的播放线路没处理时的索引关系
|
||||
* @param vod
|
||||
* @returns {{}}
|
||||
*/
|
||||
function get_tab_index(vod) {
|
||||
let obj = {};
|
||||
vod.vod_play_from.split('$$$').forEach((it, index) => {
|
||||
obj[it] = index;
|
||||
});
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理待返回的vod数据|线路去除,排序,重命名
|
||||
* @param vod
|
||||
* @returns {*}
|
||||
*/
|
||||
function vodDeal(vod) {
|
||||
let vod_play_from = vod.vod_play_from.split('$$$');
|
||||
let vod_play_url = vod.vod_play_url.split('$$$');
|
||||
|
||||
// 移除指定线路后的列表
|
||||
let tab_removed_list = vod_play_from;
|
||||
// 排序后的线路列表
|
||||
let tab_ordered_list = vod_play_from;
|
||||
// 线路重命名后的列表
|
||||
let tab_renamed_list = vod_play_from;
|
||||
// 定义实际要返回线路
|
||||
let tab_list = vod_play_from;
|
||||
// 选集列表根据线路排序
|
||||
let play_ordered_list = vod_play_url;
|
||||
|
||||
// 判断有移除线路或者线路排序
|
||||
if ((rule.tab_remove && rule.tab_remove.length > 0) || (rule.tab_order && rule.tab_order.length > 0)) {
|
||||
// 获取原来线路的索引下标
|
||||
let tab_index_dict = get_tab_index(vod);
|
||||
|
||||
if (rule.tab_remove && rule.tab_remove.length > 0) {
|
||||
tab_removed_list = vod_play_from.filter(it => !rule.tab_remove.includes(it));
|
||||
tab_list = tab_removed_list;
|
||||
}
|
||||
|
||||
if (rule.tab_order && rule.tab_order.length > 0) {
|
||||
let tab_order = rule.tab_order;
|
||||
tab_ordered_list = tab_removed_list.sort((a, b) => {
|
||||
return (tab_order.indexOf(a) === -1 ? 9999 : tab_order.indexOf(a)) - (tab_order.indexOf(b) === -1 ? 9999 : tab_order.indexOf(b))
|
||||
});
|
||||
tab_list = tab_ordered_list;
|
||||
}
|
||||
play_ordered_list = tab_list.map(it => vod_play_url[tab_index_dict[it]]);
|
||||
}
|
||||
|
||||
if (rule.tab_rename && typeof (rule.tab_rename) === 'object' & Object.keys(rule.tab_rename).length > 0) {
|
||||
tab_renamed_list = tab_list.map(it => rule.tab_rename[it] || it);
|
||||
tab_list = tab_renamed_list;
|
||||
}
|
||||
vod.vod_play_from = tab_list.join('$$$');
|
||||
vod.vod_play_url = play_ordered_list.join('$$$');
|
||||
return vod
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否需要解析
|
||||
* @param url
|
||||
* @returns {number|number}
|
||||
*/
|
||||
function tellIsJx(url) {
|
||||
try {
|
||||
let is_vip = !/\.(m3u8|mp4|m4a)$/.test(url.split('?')[0]) && 是否正版(url);
|
||||
return is_vip ? 1 : 0
|
||||
} catch (e) {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 选集播放点击事件解析
|
||||
* @param playObj
|
||||
* @returns {string}
|
||||
*/
|
||||
function playParse(playObj) {
|
||||
fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));
|
||||
MY_URL = playObj.url;
|
||||
var MY_FLAG = playObj.flag;
|
||||
if (!/http/.test(MY_URL)) {
|
||||
try {
|
||||
MY_URL = base64Decode(MY_URL);
|
||||
} catch (e) {
|
||||
}
|
||||
}
|
||||
MY_URL = decodeURIComponent(MY_URL);
|
||||
var input = MY_URL;//注入给免嗅js
|
||||
var flag = MY_FLAG;//注入播放线路名称给免嗅js
|
||||
let common_play = {
|
||||
parse: SPECIAL_URL.test(input) || /^(push:)/.test(input) ? 0 : 1,
|
||||
url: input,
|
||||
flag: flag,
|
||||
// url:urlencode(input),
|
||||
jx: tellIsJx(input)
|
||||
};
|
||||
let lazy_play;
|
||||
if (!rule.play_parse || !rule.lazy) {
|
||||
lazy_play = common_play;
|
||||
} else if (rule.play_parse && rule.lazy && typeof (rule.lazy) === 'string') {
|
||||
try {
|
||||
let lazy_code = rule.lazy.trim();
|
||||
if (lazy_code.startsWith('js:')) {
|
||||
lazy_code = lazy_code.replace('js:', '').trim();
|
||||
}
|
||||
print('开始执行js免嗅=>' + lazy_code);
|
||||
eval(lazy_code);
|
||||
lazy_play = typeof (input) === 'object' ? input : {
|
||||
parse: SPECIAL_URL.test(input) || /^(push:)/.test(input) ? 0 : 1,
|
||||
jx: tellIsJx(input),
|
||||
url: input
|
||||
};
|
||||
} catch (e) {
|
||||
print(`js免嗅错误:${e.message}`);
|
||||
lazy_play = common_play;
|
||||
}
|
||||
} else {
|
||||
lazy_play = common_play;
|
||||
}
|
||||
// print('play_json:'+typeof(rule.play_json));
|
||||
// console.log(Array.isArray(rule.play_json));
|
||||
if (Array.isArray(rule.play_json) && rule.play_json.length > 0) { // 数组情况判断长度大于0
|
||||
let web_url = lazy_play.url;
|
||||
for (let pjson of rule.play_json) {
|
||||
if (pjson.re && (pjson.re === '*' || web_url.match(new RegExp(pjson.re)))) {
|
||||
if (pjson.json && typeof (pjson.json) === 'object') {
|
||||
let base_json = pjson.json;
|
||||
// print('开始合并:');
|
||||
// print(base_json);
|
||||
lazy_play = Object.assign(lazy_play, base_json);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (rule.play_json && !Array.isArray(rule.play_json)) { // 其他情况 非[] 判断true/false
|
||||
let base_json = {
|
||||
jx: 1,
|
||||
parse: 1,
|
||||
};
|
||||
lazy_play = Object.assign(lazy_play, base_json);
|
||||
} else if (!rule.play_json) { // 不解析传0
|
||||
let base_json = {
|
||||
jx: 0,
|
||||
parse: 1,
|
||||
};
|
||||
lazy_play = Object.assign(lazy_play, base_json);
|
||||
}
|
||||
console.log(JSON.stringify(lazy_play));
|
||||
return JSON.stringify(lazy_play);
|
||||
}
|
||||
|
||||
/**
|
||||
* 本地代理解析规则
|
||||
* @param params
|
||||
*/
|
||||
function proxyParse(proxyObj) {
|
||||
var input = proxyObj.params;
|
||||
if (proxyObj.proxy_rule) {
|
||||
log('准备执行本地代理规则:\n' + proxyObj.proxy_rule);
|
||||
try {
|
||||
eval(proxyObj.proxy_rule);
|
||||
if (input && input !== proxyObj.params && Array.isArray(input) && input.length >= 3) {
|
||||
return input
|
||||
} else {
|
||||
return [404, 'text/plain', 'Not Found']
|
||||
}
|
||||
} catch (e) {
|
||||
return [500, 'text/plain', '代理规则错误:' + e.message]
|
||||
}
|
||||
|
||||
} else {
|
||||
return [404, 'text/plain', 'Not Found']
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 辅助嗅探解析规则
|
||||
* @param isVideoObj
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function isVideoParse(isVideoObj) {
|
||||
var input = isVideoObj.url;
|
||||
if (!isVideoObj.t) { // t为假代表默认传的正则字符串
|
||||
let re_matcher = new RegExp(isVideoObj.isVideo, 'i'); // /g匹配多个,/i不区分大小写,/m匹配多行
|
||||
return re_matcher.test(input);
|
||||
} else {
|
||||
// 执行js
|
||||
try {
|
||||
eval(isVideoObj.isVideo);
|
||||
if (typeof (input) === 'boolean') {
|
||||
return input
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
} catch (e) {
|
||||
log(`执行嗅探规则发生错误:${e.message}`);
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取加密前的原始的js源文本
|
||||
* @param js_code
|
||||
*/
|
||||
function getOriginalJs(js_code) {
|
||||
let current_match = /var rule|[\u4E00-\u9FA5]+|function|let |var |const |\(|\)|"|'/;
|
||||
if (current_match.test(js_code)) {
|
||||
return js_code
|
||||
}
|
||||
let rsa_private_key = 'MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCqin/jUpqM6+fgYP/oMqj9zcdHMM0mEZXLeTyixIJWP53lzJV2N2E3OP6BBpUmq2O1a9aLnTIbADBaTulTNiOnVGoNG58umBnupnbmmF8iARbDp2mTzdMMeEgLdrfXS6Y3VvazKYALP8EhEQykQVarexR78vRq7ltY3quXx7cgI0ROfZz5Sw3UOLQJ+VoWmwIxu9AMEZLVzFDQN93hzuzs3tNyHK6xspBGB7zGbwCg+TKi0JeqPDrXxYUpAz1cQ/MO+Da0WgvkXnvrry8NQROHejdLVOAslgr6vYthH9bKbsGyNY3H+P12kcxo9RAcVveONnZbcMyxjtF5dWblaernAgMBAAECggEAGdEHlSEPFmAr5PKqKrtoi6tYDHXdyHKHC5tZy4YV+Pp+a6gxxAiUJejx1hRqBcWSPYeKne35BM9dgn5JofgjI5SKzVsuGL6bxl3ayAOu+xXRHWM9f0t8NHoM5fdd0zC3g88dX3fb01geY2QSVtcxSJpEOpNH3twgZe6naT2pgiq1S4okpkpldJPo5GYWGKMCHSLnKGyhwS76gF8bTPLoay9Jxk70uv6BDUMlA4ICENjmsYtd3oirWwLwYMEJbSFMlyJvB7hjOjR/4RpT4FPnlSsIpuRtkCYXD4jdhxGlvpXREw97UF2wwnEUnfgiZJ2FT/MWmvGGoaV/CfboLsLZuQKBgQDTNZdJrs8dbijynHZuuRwvXvwC03GDpEJO6c1tbZ1s9wjRyOZjBbQFRjDgFeWs9/T1aNBLUrgsQL9c9nzgUziXjr1Nmu52I0Mwxi13Km/q3mT+aQfdgNdu6ojsI5apQQHnN/9yMhF6sNHg63YOpH+b+1bGRCtr1XubuLlumKKscwKBgQDOtQ2lQjMtwsqJmyiyRLiUOChtvQ5XI7B2mhKCGi8kZ+WEAbNQcmThPesVzW+puER6D4Ar4hgsh9gCeuTaOzbRfZ+RLn3Aksu2WJEzfs6UrGvm6DU1INn0z/tPYRAwPX7sxoZZGxqML/z+/yQdf2DREoPdClcDa2Lmf1KpHdB+vQKBgBXFCVHz7a8n4pqXG/HvrIMJdEpKRwH9lUQS/zSPPtGzaLpOzchZFyQQBwuh1imM6Te+VPHeldMh3VeUpGxux39/m+160adlnRBS7O7CdgSsZZZ/dusS06HAFNraFDZf1/VgJTk9BeYygX+AZYu+0tReBKSs9BjKSVJUqPBIVUQXAoGBAJcZ7J6oVMcXxHxwqoAeEhtvLcaCU9BJK36XQ/5M67ceJ72mjJC6/plUbNukMAMNyyi62gO6I9exearecRpB/OGIhjNXm99Ar59dAM9228X8gGfryLFMkWcO/fNZzb6lxXmJ6b2LPY3KqpMwqRLTAU/zy+ax30eFoWdDHYa4X6e1AoGAfa8asVGOJ8GL9dlWufEeFkDEDKO9ww5GdnpN+wqLwePWqeJhWCHad7bge6SnlylJp5aZXl1+YaBTtOskC4Whq9TP2J+dNIgxsaF5EFZQJr8Xv+lY9lu0CruYOh9nTNF9x3nubxJgaSid/7yRPfAGnsJRiknB5bsrCvgsFQFjJVs=';
|
||||
let decode_content = '';
|
||||
|
||||
function aes_decrypt(data) {
|
||||
let key = CryptoJS.enc.Hex.parse("686A64686E780A0A0A0A0A0A0A0A0A0A");
|
||||
let iv = CryptoJS.enc.Hex.parse("647A797964730A0A0A0A0A0A0A0A0A0A");
|
||||
let encrypted = CryptoJS.AES.decrypt({
|
||||
ciphertext: CryptoJS.enc.Base64.parse(data)
|
||||
}, key, {
|
||||
iv: iv,
|
||||
mode: CryptoJS.mode.CBC,
|
||||
padding: CryptoJS.pad.Pkcs7
|
||||
}).toString(CryptoJS.enc.Utf8);
|
||||
return encrypted;
|
||||
}
|
||||
|
||||
let error_log = false;
|
||||
|
||||
function logger(text) {
|
||||
if (error_log) {
|
||||
log(text);
|
||||
}
|
||||
}
|
||||
|
||||
let decode_funcs = [
|
||||
(text) => {
|
||||
try {
|
||||
return ungzip(text)
|
||||
} catch (e) {
|
||||
logger('非gzip加密');
|
||||
return ''
|
||||
}
|
||||
},
|
||||
(text) => {
|
||||
try {
|
||||
return base64Decode(text)
|
||||
} catch (e) {
|
||||
logger('非b64加密');
|
||||
return ''
|
||||
}
|
||||
},
|
||||
(text) => {
|
||||
try {
|
||||
return aes_decrypt(text)
|
||||
} catch (e) {
|
||||
logger('非aes加密');
|
||||
return ''
|
||||
}
|
||||
},
|
||||
(text) => {
|
||||
try {
|
||||
return RSA.decode(text, rsa_private_key, null)
|
||||
} catch (e) {
|
||||
logger('非rsa加密');
|
||||
return ''
|
||||
}
|
||||
},
|
||||
// (text)=>{try {return NODERSA.decryptRSAWithPrivateKey(text, RSA.getPrivateKey(rsa_private_key).replace(/RSA /g,''), {options: {environment: "browser", encryptionScheme: 'pkcs1',b:'1024'}});} catch (e) {log(e.message);return ''}},
|
||||
]
|
||||
let func_index = 0
|
||||
while (!current_match.test(decode_content)) {
|
||||
decode_content = decode_funcs[func_index](js_code);
|
||||
func_index++;
|
||||
if (func_index >= decode_funcs.length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return decode_content
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行main函数
|
||||
* 示例 function main(text){return gzip(text)}
|
||||
* @param main_func_code
|
||||
* @param arg
|
||||
*/
|
||||
function runMain(main_func_code, arg) {
|
||||
let mainFunc = function () {
|
||||
return ''
|
||||
};
|
||||
try {
|
||||
eval(main_func_code + '\nmainFunc=main;');
|
||||
return mainFunc(arg);
|
||||
} catch (e) {
|
||||
log(`执行main_funct发生了错误:${e.message}`);
|
||||
return ''
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* js源预处理特定返回对象中的函数
|
||||
* @param ext
|
||||
*/
|
||||
function init(ext) {
|
||||
console.log('init');
|
||||
// init前重置rule和fetch_params
|
||||
rule = {};
|
||||
rule_fetch_params = {};
|
||||
fetch_params = null;
|
||||
try {
|
||||
// make shared jsContext happy muban不能import,不然会造成换源继承后变量被篡改
|
||||
// if (typeof (globalThis.mubanJs) === 'undefined') {
|
||||
// let mubanJs = request('https://ghproxy.net/https://raw.githubusercontent.com/hjdhnx/dr_py/main/js/模板.js', { 'User-Agent': MOBILE_UA });
|
||||
// mubanJs = mubanJs.replace('export default', '(function() {return muban;}()) // export default');
|
||||
// // console.log(mubanJs);
|
||||
// globalThis.mubanJs = mubanJs;
|
||||
// }
|
||||
// let muban = eval(globalThis.mubanJs);
|
||||
|
||||
let muban = 模板.getMubans();
|
||||
// print(typeof (muban));
|
||||
// print(muban);
|
||||
if (typeof ext == 'object') {
|
||||
rule = ext;
|
||||
} else if (typeof ext == 'string') {
|
||||
let is_file = ext.startsWith('file://');
|
||||
if (ext.startsWith('http') || is_file) {
|
||||
let query = getQuery(ext); // 获取链接传参
|
||||
if (is_file) {
|
||||
ext = ext.split('?')[0];
|
||||
}
|
||||
let js = request(ext, {'method': 'GET'});
|
||||
if (js) {
|
||||
js = getOriginalJs(js);
|
||||
// eval(js.replace('var rule', 'rule'));
|
||||
// eval("(function(){'use strict';"+js.replace('var rule', 'rule')+"})()");
|
||||
eval("(function(){" + js.replace('var rule', 'rule') + "})()");
|
||||
}
|
||||
if (query.type === 'url' && query.params) { // 指定type是链接并且传了params支持简写如 ./xx.json
|
||||
if (is_file && /^http/.test(query.params)) {
|
||||
rule.params = query.params;
|
||||
} else {
|
||||
rule.params = urljoin(ext, query.params);
|
||||
}
|
||||
} else if (query.params) { // 没指定type直接视为字符串
|
||||
rule.params = query.params;
|
||||
}
|
||||
} else {
|
||||
ext = getOriginalJs(ext);
|
||||
// eval(ext.replace('var rule', 'rule'));
|
||||
// eval("(function(){'use strict';"+ext.replace('var rule', 'rule')+"})()");
|
||||
eval("(function(){" + ext.replace('var rule', 'rule') + "})()");
|
||||
}
|
||||
} else {
|
||||
console.log(`规则加载失败,不支持的规则类型:${typeof ext}`);
|
||||
return
|
||||
}
|
||||
rule.host = (rule.host || '').rstrip('/');
|
||||
HOST = rule.host;
|
||||
if (rule.hostJs) {
|
||||
console.log(`检测到hostJs,准备执行...`);
|
||||
try {
|
||||
eval(rule.hostJs);
|
||||
rule.host = HOST.rstrip('/');
|
||||
} catch (e) {
|
||||
console.log(`执行${rule.hostJs}获取host发生错误:${e.message}`);
|
||||
}
|
||||
}
|
||||
if (rule['模板'] === '自动') {
|
||||
try {
|
||||
let host_headers = rule['headers'] || {};
|
||||
let host_html = getCode(HOST, {headers: host_headers});
|
||||
let match_muban = '';
|
||||
let muban_keys = Object.keys(muban).filter(it => !/默认|短视2|采集1/.test(it));
|
||||
for (let muban_key of muban_keys) {
|
||||
try {
|
||||
let host_data = JSON.parse(home({}, host_html, muban[muban_key].class_parse));
|
||||
if (host_data.class && host_data.class.length > 0) {
|
||||
match_muban = muban_key;
|
||||
console.log(`自动匹配模板:【${muban_key}】`);
|
||||
break;
|
||||
}
|
||||
} catch (e) {
|
||||
// @ts-ignore
|
||||
console.log(`自动匹配模板:【${muban_key}】错误:${e.message}`);
|
||||
}
|
||||
}
|
||||
if (match_muban) {
|
||||
muban['自动'] = muban[match_muban];
|
||||
if (rule['模板修改'] && rule['模板修改'].startsWith('js:')) {
|
||||
// 模板修改:$js.toString(()=>{ muban.自动.class_parse = ''});
|
||||
eval(rule['模板修改'].replace('js:', '').trim());
|
||||
}
|
||||
} else {
|
||||
delete rule['模板']
|
||||
}
|
||||
} catch (e) {
|
||||
delete rule['模板']
|
||||
}
|
||||
}
|
||||
if (rule.模板 && muban.hasOwnProperty(rule.模板)) {
|
||||
print('继承模板:' + rule.模板);
|
||||
rule = Object.assign(muban[rule.模板], rule);
|
||||
}
|
||||
/** 处理一下 rule规则关键字段没传递的情况 **/
|
||||
let rule_cate_excludes = (rule.cate_exclude || '').split('|').filter(it => it.trim());
|
||||
let rule_tab_excludes = (rule.tab_exclude || '').split('|').filter(it => it.trim());
|
||||
rule_cate_excludes = rule_cate_excludes.concat(CATE_EXCLUDE.split('|').filter(it => it.trim()));
|
||||
rule_tab_excludes = rule_tab_excludes.concat(TAB_EXCLUDE.split('|').filter(it => it.trim()));
|
||||
|
||||
rule.cate_exclude = rule_cate_excludes.join('|');
|
||||
rule.tab_exclude = rule_tab_excludes.join('|');
|
||||
|
||||
rule.类型 = rule.类型 || '影视'; // 影视|听书|漫画|小说
|
||||
rule.url = rule.url || '';
|
||||
rule.double = rule.double || false;
|
||||
rule.homeUrl = rule.homeUrl || '';
|
||||
rule.detailUrl = rule.detailUrl || '';
|
||||
rule.searchUrl = rule.searchUrl || '';
|
||||
rule.homeUrl = rule.host && rule.homeUrl ? urljoin(rule.host, rule.homeUrl) : (rule.homeUrl || rule.host);
|
||||
rule.homeUrl = cheerio.jinja2(rule.homeUrl, {rule: rule});
|
||||
rule.detailUrl = rule.host && rule.detailUrl ? urljoin(rule.host, rule.detailUrl) : rule.detailUrl;
|
||||
rule.二级访问前 = rule.二级访问前 || '';
|
||||
if (rule.url.includes('[') && rule.url.includes(']')) {
|
||||
let u1 = rule.url.split('[')[0]
|
||||
let u2 = rule.url.split('[')[1].split(']')[0]
|
||||
rule.url = rule.host && rule.url ? urljoin(rule.host, u1) + '[' + urljoin(rule.host, u2) + ']' : rule.url;
|
||||
} else {
|
||||
rule.url = rule.host && rule.url ? urljoin(rule.host, rule.url) : rule.url;
|
||||
}
|
||||
if (rule.searchUrl.includes('[') && rule.searchUrl.includes(']') && !rule.searchUrl.includes('#')) {
|
||||
let u1 = rule.searchUrl.split('[')[0]
|
||||
let u2 = rule.searchUrl.split('[')[1].split(']')[0]
|
||||
rule.searchUrl = rule.host && rule.searchUrl ? urljoin(rule.host, u1) + '[' + urljoin(rule.host, u2) + ']' : rule.searchUrl;
|
||||
} else {
|
||||
rule.searchUrl = rule.host && rule.searchUrl ? urljoin(rule.host, rule.searchUrl) : rule.searchUrl;
|
||||
}
|
||||
|
||||
rule.timeout = rule.timeout || 5000;
|
||||
rule.encoding = rule.编码 || rule.encoding || 'utf-8';
|
||||
rule.search_encoding = rule.搜索编码 || rule.search_encoding || '';
|
||||
rule.图片来源 = rule.图片来源 || '';
|
||||
rule.图片替换 = rule.图片替换 || '';
|
||||
rule.play_json = rule.hasOwnProperty('play_json') ? rule.play_json : [];
|
||||
rule.pagecount = rule.hasOwnProperty('pagecount') ? rule.pagecount : {};
|
||||
rule.proxy_rule = rule.hasOwnProperty('proxy_rule') ? rule.proxy_rule : '';
|
||||
if (!rule.hasOwnProperty('sniffer')) { // 默认关闭辅助嗅探
|
||||
rule.sniffer = false;
|
||||
}
|
||||
rule.sniffer = rule.hasOwnProperty('sniffer') ? rule.sniffer : '';
|
||||
rule.sniffer = !!(rule.sniffer && rule.sniffer !== '0' && rule.sniffer !== 'false');
|
||||
|
||||
rule.isVideo = rule.hasOwnProperty('isVideo') ? rule.isVideo : '';
|
||||
if (rule.sniffer && !rule.isVideo) { // 默认辅助嗅探自动增强嗅探规则
|
||||
rule.isVideo = 'http((?!http).){12,}?\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)\\?.*|http((?!http).){12,}\\.(m3u8|mp4|flv|avi|mkv|rm|wmv|mpg|m4a|mp3)|http((?!http).)*?video/tos*|http((?!http).)*?obj/tos*';
|
||||
}
|
||||
|
||||
rule.tab_remove = rule.hasOwnProperty('tab_remove') ? rule.tab_remove : [];
|
||||
rule.tab_order = rule.hasOwnProperty('tab_order') ? rule.tab_order : [];
|
||||
rule.tab_rename = rule.hasOwnProperty('tab_rename') ? rule.tab_rename : {};
|
||||
|
||||
if (rule.headers && typeof (rule.headers) === 'object') {
|
||||
try {
|
||||
let header_keys = Object.keys(rule.headers);
|
||||
for (let k of header_keys) {
|
||||
if (k.toLowerCase() === 'user-agent') {
|
||||
let v = rule.headers[k];
|
||||
console.log(v);
|
||||
if (['MOBILE_UA', 'PC_UA', 'UC_UA', 'IOS_UA', 'UA'].includes(v)) {
|
||||
rule.headers[k] = eval(v);
|
||||
}
|
||||
} else if (k.toLowerCase() === 'cookie') {
|
||||
let v = rule.headers[k];
|
||||
if (v && v.startsWith('http')) {
|
||||
console.log(v);
|
||||
try {
|
||||
v = fetch(v);
|
||||
console.log(v);
|
||||
rule.headers[k] = v;
|
||||
} catch (e) {
|
||||
console.log(`从${v}获取cookie发生错误:${e.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(`处理headers发生错误:${e.message}`);
|
||||
}
|
||||
} else {
|
||||
rule.headers = {}
|
||||
}
|
||||
oheaders = deepCopy(rule.headers);
|
||||
rule_fetch_params = {'headers': rule.headers, 'timeout': rule.timeout, 'encoding': rule.encoding};
|
||||
RKEY = typeof (key) !== 'undefined' && key ? key : 'drpy_' + (rule.title || rule.host);
|
||||
pre(); // 预处理
|
||||
init_test();
|
||||
} catch (e) {
|
||||
console.log(`init_test发生错误:${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
let homeHtmlCache = undefined;
|
||||
|
||||
/**
|
||||
* js源获取首页分类和筛选特定返回对象中的函数
|
||||
* @param filter 筛选条件字典对象
|
||||
* @param home_html 指定了源码。无需内部再请求
|
||||
* @param class_parse 自动匹配传入的模板的动态分类
|
||||
* @returns {string}
|
||||
*/
|
||||
function home(filter, home_html, class_parse) {
|
||||
console.log("home");
|
||||
home_html = home_html || '';
|
||||
class_parse = class_parse || '';
|
||||
if (typeof (rule.filter) === 'string' && rule.filter.trim().length > 0) {
|
||||
try {
|
||||
let filter_json = ungzip(rule.filter.trim());
|
||||
rule.filter = JSON.parse(filter_json);
|
||||
} catch (e) {
|
||||
rule.filter = {};
|
||||
}
|
||||
}
|
||||
let homeObj = {
|
||||
filter: rule.filter || false,
|
||||
MY_URL: rule.homeUrl,
|
||||
class_name: rule.class_name || '',
|
||||
class_url: rule.class_url || '',
|
||||
class_parse: class_parse || rule.class_parse || '',
|
||||
cate_exclude: rule.cate_exclude,
|
||||
home_html: home_html,
|
||||
};
|
||||
return homeParse(homeObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* js源获取首页推荐数据列表特定返回对象中的函数
|
||||
* @param params
|
||||
* @returns {string}
|
||||
*/
|
||||
function homeVod(params) {
|
||||
console.log("homeVod");
|
||||
let homeVodObj = {
|
||||
推荐: rule.推荐,
|
||||
double: rule.double,
|
||||
homeUrl: rule.homeUrl,
|
||||
detailUrl: rule.detailUrl
|
||||
};
|
||||
return homeVodParse(homeVodObj)
|
||||
// return "{}";
|
||||
}
|
||||
|
||||
/**
|
||||
* js源获取分类页一级数据列表特定返回对象中的函数
|
||||
* @param tid 分类id
|
||||
* @param pg 页数
|
||||
* @param filter 当前选中的筛选条件
|
||||
* @param extend 扩展
|
||||
* @returns {string}
|
||||
*/
|
||||
function category(tid, pg, filter, extend) {
|
||||
let cateObj = {
|
||||
url: rule.url,
|
||||
一级: rule.一级,
|
||||
tid: tid,
|
||||
pg: parseInt(pg),
|
||||
filter: filter,
|
||||
extend: extend
|
||||
};
|
||||
// console.log(JSON.stringify(extend));
|
||||
return categoryParse(cateObj)
|
||||
}
|
||||
|
||||
/**
|
||||
* js源获取二级详情页数据特定返回对象中的函数
|
||||
* @param vod_url 一级列表中的vod_id或者是带分类的自拼接 vod_id 如 fyclass$vod_id
|
||||
* @returns {string}
|
||||
*/
|
||||
function detail(vod_url) {
|
||||
let orId = vod_url;
|
||||
let fyclass = '';
|
||||
log('orId:' + orId);
|
||||
if (vod_url.indexOf('$') > -1) {
|
||||
let tmp = vod_url.split('$');
|
||||
fyclass = tmp[0];
|
||||
vod_url = tmp[1];
|
||||
}
|
||||
let detailUrl = vod_url.split('@@')[0];
|
||||
let url;
|
||||
if (!detailUrl.startsWith('http') && !detailUrl.includes('/')) {
|
||||
url = rule.detailUrl.replaceAll('fyid', detailUrl).replaceAll('fyclass', fyclass);
|
||||
} else if (detailUrl.includes('/')) {
|
||||
url = urljoin(rule.homeUrl, detailUrl);
|
||||
} else {
|
||||
url = detailUrl
|
||||
}
|
||||
let detailObj = {
|
||||
orId: orId,
|
||||
url: url,
|
||||
二级: rule.二级,
|
||||
二级访问前: rule.二级访问前,
|
||||
detailUrl: detailUrl,
|
||||
fyclass: fyclass,
|
||||
tab_exclude: rule.tab_exclude,
|
||||
}
|
||||
return detailParse(detailObj)
|
||||
}
|
||||
|
||||
/**
|
||||
* js源选集按钮播放点击事件特定返回对象中的函数
|
||||
* @param flag 线路名
|
||||
* @param id 播放按钮的链接
|
||||
* @param flags 全局配置的flags是否需要解析的标识列表
|
||||
* @returns {string}
|
||||
*/
|
||||
function play(flag, id, flags) {
|
||||
let playObj = {
|
||||
url: id,
|
||||
flag: flag,
|
||||
flags: flags
|
||||
}
|
||||
return playParse(playObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* js源搜索返回的数据列表特定返回对象中的函数
|
||||
* @param wd 搜索关键字
|
||||
* @param quick 是否来自快速搜索
|
||||
* @returns {string}
|
||||
*/
|
||||
function search(wd, quick, pg) {
|
||||
if (rule.search_encoding) {
|
||||
if (rule.search_encoding.toLowerCase() !== 'utf-8') {
|
||||
// 按搜索编码进行编码
|
||||
wd = encodeStr(wd, rule.search_encoding);
|
||||
}
|
||||
} else if (rule.encoding && rule.encoding.toLowerCase() !== 'utf-8') {
|
||||
// 按全局编码进行编码
|
||||
wd = encodeStr(wd, rule.encoding);
|
||||
}
|
||||
let searchObj = {
|
||||
searchUrl: rule.searchUrl,
|
||||
搜索: rule.搜索,
|
||||
wd: wd,
|
||||
//pg: pg,
|
||||
pg: pg || 1,
|
||||
quick: quick,
|
||||
};
|
||||
// console.log(JSON.stringify(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)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 是否启用辅助嗅探功能,启用后可以根据isVideo函数进行手动识别为视频的链接地址。默认为false
|
||||
* @returns {*|boolean|boolean}
|
||||
*/
|
||||
function sniffer() {
|
||||
let enable_sniffer = rule.sniffer || false;
|
||||
if (enable_sniffer) {
|
||||
// log('准备执行辅助嗅探代理规则:\n'+rule.isVideo);
|
||||
log('开始执行辅助嗅探代理规则...');
|
||||
}
|
||||
return enable_sniffer
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用辅助嗅探功能后根据次函数返回的值识别地址是否为视频,返回true/false
|
||||
* @param url
|
||||
*/
|
||||
function isVideo(url) {
|
||||
let t = 0;
|
||||
let is_video;
|
||||
if (rule.isVideo && rule.isVideo.trim()) {
|
||||
is_video = rule.isVideo.trim();
|
||||
}
|
||||
if (is_video.startsWith('js:')) {
|
||||
is_video = is_video.replace('js:', '');
|
||||
t = 1;
|
||||
}
|
||||
let isVideoObj = {
|
||||
url: url,
|
||||
isVideo: is_video,
|
||||
t: t,
|
||||
};
|
||||
let result = isVideoParse(isVideoObj);
|
||||
if (result) {
|
||||
log('成功执行辅助嗅探规则并检测到视频地址:\n' + rule.isVideo);
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取规则
|
||||
* @returns {{}}
|
||||
*/
|
||||
function getRule(key) {
|
||||
return key ? rule[key] || '' : rule
|
||||
}
|
||||
|
||||
/**
|
||||
* 深拷贝一个对象
|
||||
* @param _obj
|
||||
* @returns {any}
|
||||
*/
|
||||
function deepCopy(_obj) {
|
||||
return JSON.parse(JSON.stringify(_obj))
|
||||
}
|
||||
|
||||
//正则matchAll
|
||||
function matchesAll(str, pattern, flatten) {
|
||||
if (!pattern.global) {
|
||||
pattern = new RegExp(pattern.source, "g" + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : ""));
|
||||
}
|
||||
var matches = [];
|
||||
var match;
|
||||
while ((match = pattern.exec(str)) !== null) {
|
||||
matches.push(match);
|
||||
}
|
||||
return flatten ? matches.flat() : matches;
|
||||
}
|
||||
|
||||
//文本扩展
|
||||
function stringUtils() {
|
||||
Object.defineProperties(String.prototype, {
|
||||
replaceX: {
|
||||
value: function (regex, replacement) {
|
||||
let matches = matchesAll(this, regex, true);
|
||||
if (matches && matches.length > 1) {
|
||||
const hasCaptureGroup = /\$\d/.test(replacement);
|
||||
if (hasCaptureGroup) {
|
||||
return this.replace(regex, (m) => m.replace(regex, replacement));
|
||||
} else {
|
||||
return this.replace(regex, (m, p1) => m.replace(p1, replacement));
|
||||
}
|
||||
}
|
||||
return this.replace(regex, replacement);
|
||||
},
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
writable: true
|
||||
},
|
||||
parseX: {
|
||||
get: function () {
|
||||
try {
|
||||
//console.log(typeof this);
|
||||
return JSON.parse(this);
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
return this.startsWith("[") ? [] : {};
|
||||
}
|
||||
},
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//正则裁切
|
||||
function cut(text, start, end, method, All) {
|
||||
let result = "";
|
||||
let c = (t, s, e) => {
|
||||
let result = "";
|
||||
let rs = [];
|
||||
let results = [];
|
||||
try {
|
||||
let lr = new RegExp(String.raw`${s}`.toString());
|
||||
let rr = new RegExp(String.raw`${e}`.toString());
|
||||
const segments = t.split(lr);
|
||||
if (segments.length < 2) return '';
|
||||
let cutSegments = segments.slice(1).map(segment => {
|
||||
let splitSegment = segment.split(rr);
|
||||
//log(splitSegment)
|
||||
return splitSegment.length < 2 ? undefined : splitSegment[0] + e;
|
||||
}).filter(f => f);
|
||||
//log(cutSegments.at(-1))
|
||||
if (All) {
|
||||
return `[${cutSegments.join(',')}]`;
|
||||
} else {
|
||||
return cutSegments[0];
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(`Error cutting text:${e.message}`);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
result = c(text, start, end);
|
||||
stringUtils();
|
||||
if (method && typeof method === "function") {
|
||||
result = method(result);
|
||||
}
|
||||
//console.log(result);
|
||||
return result
|
||||
}
|
||||
|
||||
function DRPY() {//导出函数
|
||||
return {
|
||||
runMain: runMain,
|
||||
getRule: getRule,
|
||||
init: init,
|
||||
home: home,
|
||||
homeVod: homeVod,
|
||||
category: category,
|
||||
detail: detail,
|
||||
play: play,
|
||||
search: search,
|
||||
proxy: proxy,
|
||||
sniffer: sniffer,
|
||||
isVideo: isVideo,
|
||||
fixAdM3u8Ai: fixAdM3u8Ai,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出函数无法简写成下面的形式:
|
||||
|
||||
export default {
|
||||
...DRPY,
|
||||
DRPY
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
// 导出函数对象
|
||||
export default {
|
||||
runMain,
|
||||
getRule,
|
||||
init,
|
||||
home,
|
||||
homeVod,
|
||||
category,
|
||||
detail,
|
||||
play,
|
||||
search,
|
||||
proxy,
|
||||
sniffer,
|
||||
isVideo,
|
||||
fixAdM3u8Ai,
|
||||
DRPY,
|
||||
}
|
||||
Vendored
+76
-1
File diff suppressed because one or more lines are too long
+577
@@ -0,0 +1,577 @@
|
||||
/*!
|
||||
* Jinja Templating for JavaScript v0.1.8
|
||||
* https://github.com/sstur/jinja-js
|
||||
*
|
||||
* This is a slimmed-down Jinja2 implementation [http://jinja.pocoo.org/]
|
||||
*
|
||||
* In the interest of simplicity, it deviates from Jinja2 as follows:
|
||||
* - Line statements, cycle, super, macro tags and block nesting are not implemented
|
||||
* - auto escapes html by default (the filter is "html" not "e")
|
||||
* - Only "html" and "safe" filters are built in
|
||||
* - Filters are not valid in expressions; `foo|length > 1` is not valid
|
||||
* - Expression Tests (`if num is odd`) not implemented (`is` translates to `==` and `isnot` to `!=`)
|
||||
*
|
||||
* Notes:
|
||||
* - if property is not found, but method '_get' exists, it will be called with the property name (and cached)
|
||||
* - `{% for n in obj %}` iterates the object's keys; get the value with `{% for n in obj %}{{ obj[n] }}{% endfor %}`
|
||||
* - subscript notation `a[0]` takes literals or simple variables but not `a[item.key]`
|
||||
* - `.2` is not a valid number literal; use `0.2`
|
||||
*
|
||||
*/
|
||||
/*global require, exports, module, define */
|
||||
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.jinja = {}));
|
||||
})(this, (function (jinja) {
|
||||
"use strict";
|
||||
var STRINGS = /'(\\.|[^'])*'|"(\\.|[^"'"])*"/g;
|
||||
var IDENTS_AND_NUMS = /([$_a-z][$\w]*)|([+-]?\d+(\.\d+)?)/g;
|
||||
var NUMBER = /^[+-]?\d+(\.\d+)?$/;
|
||||
//non-primitive literals (array and object literals)
|
||||
var NON_PRIMITIVES = /\[[@#~](,[@#~])*\]|\[\]|\{([@i]:[@#~])(,[@i]:[@#~])*\}|\{\}/g;
|
||||
//bare identifiers such as variables and in object literals: {foo: 'value'}
|
||||
var IDENTIFIERS = /[$_a-z][$\w]*/ig;
|
||||
var VARIABLES = /i(\.i|\[[@#i]\])*/g;
|
||||
var ACCESSOR = /(\.i|\[[@#i]\])/g;
|
||||
var OPERATORS = /(===?|!==?|>=?|<=?|&&|\|\||[+\-\*\/%])/g;
|
||||
//extended (english) operators
|
||||
var EOPS = /(^|[^$\w])(and|or|not|is|isnot)([^$\w]|$)/g;
|
||||
var LEADING_SPACE = /^\s+/;
|
||||
var TRAILING_SPACE = /\s+$/;
|
||||
|
||||
var START_TOKEN = /\{\{\{|\{\{|\{%|\{#/;
|
||||
var TAGS = {
|
||||
'{{{': /^('(\\.|[^'])*'|"(\\.|[^"'"])*"|.)+?\}\}\}/,
|
||||
'{{': /^('(\\.|[^'])*'|"(\\.|[^"'"])*"|.)+?\}\}/,
|
||||
'{%': /^('(\\.|[^'])*'|"(\\.|[^"'"])*"|.)+?%\}/,
|
||||
'{#': /^('(\\.|[^'])*'|"(\\.|[^"'"])*"|.)+?#\}/
|
||||
};
|
||||
|
||||
var delimeters = {
|
||||
'{%': 'directive',
|
||||
'{{': 'output',
|
||||
'{#': 'comment'
|
||||
};
|
||||
|
||||
var operators = {
|
||||
and: '&&',
|
||||
or: '||',
|
||||
not: '!',
|
||||
is: '==',
|
||||
isnot: '!='
|
||||
};
|
||||
|
||||
var constants = {
|
||||
'true': true,
|
||||
'false': false,
|
||||
'null': null
|
||||
};
|
||||
|
||||
function Parser() {
|
||||
this.nest = [];
|
||||
this.compiled = [];
|
||||
this.childBlocks = 0;
|
||||
this.parentBlocks = 0;
|
||||
this.isSilent = false;
|
||||
}
|
||||
|
||||
Parser.prototype.push = function (line) {
|
||||
if (!this.isSilent) {
|
||||
this.compiled.push(line);
|
||||
}
|
||||
};
|
||||
|
||||
Parser.prototype.parse = function (src) {
|
||||
this.tokenize(src);
|
||||
return this.compiled;
|
||||
};
|
||||
|
||||
Parser.prototype.tokenize = function (src) {
|
||||
var lastEnd = 0, parser = this, trimLeading = false;
|
||||
matchAll(src, START_TOKEN, function (open, index, src) {
|
||||
//here we match the rest of the src against a regex for this tag
|
||||
var match = src.slice(index + open.length).match(TAGS[open]);
|
||||
match = (match ? match[0] : '');
|
||||
//here we sub out strings so we don't get false matches
|
||||
var simplified = match.replace(STRINGS, '@');
|
||||
//if we don't have a close tag or there is a nested open tag
|
||||
if (!match || ~simplified.indexOf(open)) {
|
||||
return index + 1;
|
||||
}
|
||||
var inner = match.slice(0, 0 - open.length);
|
||||
//check for white-space collapse syntax
|
||||
if (inner.charAt(0) === '-') var wsCollapseLeft = true;
|
||||
if (inner.slice(-1) === '-') var wsCollapseRight = true;
|
||||
inner = inner.replace(/^-|-$/g, '').trim();
|
||||
//if we're in raw mode and we are not looking at an "endraw" tag, move along
|
||||
if (parser.rawMode && (open + inner) !== '{%endraw') {
|
||||
return index + 1;
|
||||
}
|
||||
var text = src.slice(lastEnd, index);
|
||||
lastEnd = index + open.length + match.length;
|
||||
if (trimLeading) text = trimLeft(text);
|
||||
if (wsCollapseLeft) text = trimRight(text);
|
||||
if (wsCollapseRight) trimLeading = true;
|
||||
if (open === '{{{') {
|
||||
//liquid-style: make {{{x}}} => {{x|safe}}
|
||||
open = '{{';
|
||||
inner += '|safe';
|
||||
}
|
||||
parser.textHandler(text);
|
||||
parser.tokenHandler(open, inner);
|
||||
});
|
||||
var text = src.slice(lastEnd);
|
||||
if (trimLeading) text = trimLeft(text);
|
||||
this.textHandler(text);
|
||||
};
|
||||
|
||||
Parser.prototype.textHandler = function (text) {
|
||||
this.push('write(' + JSON.stringify(text) + ');');
|
||||
};
|
||||
|
||||
Parser.prototype.tokenHandler = function (open, inner) {
|
||||
var type = delimeters[open];
|
||||
if (type === 'directive') {
|
||||
this.compileTag(inner);
|
||||
} else if (type === 'output') {
|
||||
var extracted = this.extractEnt(inner, STRINGS, '@');
|
||||
//replace || operators with ~
|
||||
extracted.src = extracted.src.replace(/\|\|/g, '~').split('|');
|
||||
//put back || operators
|
||||
extracted.src = extracted.src.map(function (part) {
|
||||
return part.split('~').join('||');
|
||||
});
|
||||
var parts = this.injectEnt(extracted, '@');
|
||||
if (parts.length > 1) {
|
||||
var filters = parts.slice(1).map(this.parseFilter.bind(this));
|
||||
this.push('filter(' + this.parseExpr(parts[0]) + ',' + filters.join(',') + ');');
|
||||
} else {
|
||||
this.push('filter(' + this.parseExpr(parts[0]) + ');');
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Parser.prototype.compileTag = function (str) {
|
||||
var directive = str.split(' ')[0];
|
||||
var handler = tagHandlers[directive];
|
||||
if (!handler) {
|
||||
throw new Error('Invalid tag: ' + str);
|
||||
}
|
||||
handler.call(this, str.slice(directive.length).trim());
|
||||
};
|
||||
|
||||
Parser.prototype.parseFilter = function (src) {
|
||||
src = src.trim();
|
||||
var match = src.match(/[:(]/);
|
||||
var i = match ? match.index : -1;
|
||||
if (i < 0) return JSON.stringify([src]);
|
||||
var name = src.slice(0, i);
|
||||
var args = src.charAt(i) === ':' ? src.slice(i + 1) : src.slice(i + 1, -1);
|
||||
args = this.parseExpr(args, {terms: true});
|
||||
return '[' + JSON.stringify(name) + ',' + args + ']';
|
||||
};
|
||||
|
||||
Parser.prototype.extractEnt = function (src, regex, placeholder) {
|
||||
var subs = [], isFunc = typeof placeholder == 'function';
|
||||
src = src.replace(regex, function (str) {
|
||||
var replacement = isFunc ? placeholder(str) : placeholder;
|
||||
if (replacement) {
|
||||
subs.push(str);
|
||||
return replacement;
|
||||
}
|
||||
return str;
|
||||
});
|
||||
return {src: src, subs: subs};
|
||||
};
|
||||
|
||||
Parser.prototype.injectEnt = function (extracted, placeholder) {
|
||||
var src = extracted.src, subs = extracted.subs, isArr = Array.isArray(src);
|
||||
var arr = (isArr) ? src : [src];
|
||||
var re = new RegExp('[' + placeholder + ']', 'g'), i = 0;
|
||||
arr.forEach(function (src, index) {
|
||||
arr[index] = src.replace(re, function () {
|
||||
return subs[i++];
|
||||
});
|
||||
});
|
||||
return isArr ? arr : arr[0];
|
||||
};
|
||||
|
||||
//replace complex literals without mistaking subscript notation with array literals
|
||||
Parser.prototype.replaceComplex = function (s) {
|
||||
var parsed = this.extractEnt(s, /i(\.i|\[[@#i]\])+/g, 'v');
|
||||
parsed.src = parsed.src.replace(NON_PRIMITIVES, '~');
|
||||
return this.injectEnt(parsed, 'v');
|
||||
};
|
||||
|
||||
//parse expression containing literals (including objects/arrays) and variables (including dot and subscript notation)
|
||||
//valid expressions: `a + 1 > b.c or c == null`, `a and b[1] != c`, `(a < b) or (c < d and e)`, 'a || [1]`
|
||||
Parser.prototype.parseExpr = function (src, opts) {
|
||||
opts = opts || {};
|
||||
//extract string literals -> @
|
||||
var parsed1 = this.extractEnt(src, STRINGS, '@');
|
||||
//note: this will catch {not: 1} and a.is; could we replace temporarily and then check adjacent chars?
|
||||
parsed1.src = parsed1.src.replace(EOPS, function (s, before, op, after) {
|
||||
return (op in operators) ? before + operators[op] + after : s;
|
||||
});
|
||||
//sub out non-string literals (numbers/true/false/null) -> #
|
||||
// the distinction is necessary because @ can be object identifiers, # cannot
|
||||
var parsed2 = this.extractEnt(parsed1.src, IDENTS_AND_NUMS, function (s) {
|
||||
return (s in constants || NUMBER.test(s)) ? '#' : null;
|
||||
});
|
||||
//sub out object/variable identifiers -> i
|
||||
var parsed3 = this.extractEnt(parsed2.src, IDENTIFIERS, 'i');
|
||||
//remove white-space
|
||||
parsed3.src = parsed3.src.replace(/\s+/g, '');
|
||||
|
||||
//the rest of this is simply to boil the expression down and check validity
|
||||
var simplified = parsed3.src;
|
||||
//sub out complex literals (objects/arrays) -> ~
|
||||
// the distinction is necessary because @ and # can be subscripts but ~ cannot
|
||||
while (simplified !== (simplified = this.replaceComplex(simplified))) ;
|
||||
//now @ represents strings, # represents other primitives and ~ represents non-primitives
|
||||
//replace complex variables (those with dot/subscript accessors) -> v
|
||||
while (simplified !== (simplified = simplified.replace(/i(\.i|\[[@#i]\])+/, 'v'))) ;
|
||||
//empty subscript or complex variables in subscript, are not permitted
|
||||
simplified = simplified.replace(/[iv]\[v?\]/g, 'x');
|
||||
//sub in "i" for @ and # and ~ and v (now "i" represents all literals, variables and identifiers)
|
||||
simplified = simplified.replace(/[@#~v]/g, 'i');
|
||||
//sub out operators
|
||||
simplified = simplified.replace(OPERATORS, '%');
|
||||
//allow 'not' unary operator
|
||||
simplified = simplified.replace(/!+[i]/g, 'i');
|
||||
var terms = opts.terms ? simplified.split(',') : [simplified];
|
||||
terms.forEach(function (term) {
|
||||
//simplify logical grouping
|
||||
while (term !== (term = term.replace(/\(i(%i)*\)/g, 'i'))) ;
|
||||
if (!term.match(/^i(%i)*/)) {
|
||||
throw new Error('Invalid expression: ' + src + " " + term);
|
||||
}
|
||||
});
|
||||
parsed3.src = parsed3.src.replace(VARIABLES, this.parseVar.bind(this));
|
||||
parsed2.src = this.injectEnt(parsed3, 'i');
|
||||
parsed1.src = this.injectEnt(parsed2, '#');
|
||||
return this.injectEnt(parsed1, '@');
|
||||
};
|
||||
|
||||
Parser.prototype.parseVar = function (src) {
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
var str = args.pop(), index = args.pop();
|
||||
//quote bare object identifiers (might be a reserved word like {while: 1})
|
||||
if (src === 'i' && str.charAt(index + 1) === ':') {
|
||||
return '"i"';
|
||||
}
|
||||
var parts = ['"i"'];
|
||||
src.replace(ACCESSOR, function (part) {
|
||||
if (part === '.i') {
|
||||
parts.push('"i"');
|
||||
} else if (part === '[i]') {
|
||||
parts.push('get("i")');
|
||||
} else {
|
||||
parts.push(part.slice(1, -1));
|
||||
}
|
||||
});
|
||||
return 'get(' + parts.join(',') + ')';
|
||||
};
|
||||
|
||||
//escapes a name to be used as a javascript identifier
|
||||
Parser.prototype.escName = function (str) {
|
||||
return str.replace(/\W/g, function (s) {
|
||||
return '$' + s.charCodeAt(0).toString(16);
|
||||
});
|
||||
};
|
||||
|
||||
Parser.prototype.parseQuoted = function (str) {
|
||||
if (str.charAt(0) === "'") {
|
||||
str = str.slice(1, -1).replace(/\\.|"/, function (s) {
|
||||
if (s === "\\'") return "'";
|
||||
return s.charAt(0) === '\\' ? s : ('\\' + s);
|
||||
});
|
||||
str = '"' + str + '"';
|
||||
}
|
||||
//todo: try/catch or deal with invalid characters (linebreaks, control characters)
|
||||
return JSON.parse(str);
|
||||
};
|
||||
|
||||
|
||||
//the context 'this' inside tagHandlers is the parser instance
|
||||
var tagHandlers = {
|
||||
'if': function (expr) {
|
||||
this.push('if (' + this.parseExpr(expr) + ') {');
|
||||
this.nest.unshift('if');
|
||||
},
|
||||
'else': function () {
|
||||
if (this.nest[0] === 'for') {
|
||||
this.push('}, function() {');
|
||||
} else {
|
||||
this.push('} else {');
|
||||
}
|
||||
},
|
||||
'elseif': function (expr) {
|
||||
this.push('} else if (' + this.parseExpr(expr) + ') {');
|
||||
},
|
||||
'endif': function () {
|
||||
this.nest.shift();
|
||||
this.push('}');
|
||||
},
|
||||
'for': function (str) {
|
||||
var i = str.indexOf(' in ');
|
||||
var name = str.slice(0, i).trim();
|
||||
var expr = str.slice(i + 4).trim();
|
||||
this.push('each(' + this.parseExpr(expr) + ',' + JSON.stringify(name) + ',function() {');
|
||||
this.nest.unshift('for');
|
||||
},
|
||||
'endfor': function () {
|
||||
this.nest.shift();
|
||||
this.push('});');
|
||||
},
|
||||
'raw': function () {
|
||||
this.rawMode = true;
|
||||
},
|
||||
'endraw': function () {
|
||||
this.rawMode = false;
|
||||
},
|
||||
'set': function (stmt) {
|
||||
var i = stmt.indexOf('=');
|
||||
var name = stmt.slice(0, i).trim();
|
||||
var expr = stmt.slice(i + 1).trim();
|
||||
this.push('set(' + JSON.stringify(name) + ',' + this.parseExpr(expr) + ');');
|
||||
},
|
||||
'block': function (name) {
|
||||
if (this.isParent) {
|
||||
++this.parentBlocks;
|
||||
var blockName = 'block_' + (this.escName(name) || this.parentBlocks);
|
||||
this.push('block(typeof ' + blockName + ' == "function" ? ' + blockName + ' : function() {');
|
||||
} else if (this.hasParent) {
|
||||
this.isSilent = false;
|
||||
++this.childBlocks;
|
||||
blockName = 'block_' + (this.escName(name) || this.childBlocks);
|
||||
this.push('function ' + blockName + '() {');
|
||||
}
|
||||
this.nest.unshift('block');
|
||||
},
|
||||
'endblock': function () {
|
||||
this.nest.shift();
|
||||
if (this.isParent) {
|
||||
this.push('});');
|
||||
} else if (this.hasParent) {
|
||||
this.push('}');
|
||||
this.isSilent = true;
|
||||
}
|
||||
},
|
||||
'extends': function (name) {
|
||||
name = this.parseQuoted(name);
|
||||
var parentSrc = this.readTemplateFile(name);
|
||||
this.isParent = true;
|
||||
this.tokenize(parentSrc);
|
||||
this.isParent = false;
|
||||
this.hasParent = true;
|
||||
//silence output until we enter a child block
|
||||
this.isSilent = true;
|
||||
},
|
||||
'include': function (name) {
|
||||
name = this.parseQuoted(name);
|
||||
var incSrc = this.readTemplateFile(name);
|
||||
this.isInclude = true;
|
||||
this.tokenize(incSrc);
|
||||
this.isInclude = false;
|
||||
}
|
||||
};
|
||||
|
||||
//liquid style
|
||||
tagHandlers.assign = tagHandlers.set;
|
||||
//python/django style
|
||||
tagHandlers.elif = tagHandlers.elseif;
|
||||
|
||||
var getRuntime = function runtime(data, opts) {
|
||||
var defaults = {autoEscape: 'toJson'};
|
||||
var _toString = Object.prototype.toString;
|
||||
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
||||
var getKeys = Object.keys || function (obj) {
|
||||
var keys = [];
|
||||
for (var n in obj) if (_hasOwnProperty.call(obj, n)) keys.push(n);
|
||||
return keys;
|
||||
};
|
||||
var isArray = Array.isArray || function (obj) {
|
||||
return _toString.call(obj) === '[object Array]';
|
||||
};
|
||||
var create = Object.create || function (obj) {
|
||||
function F() {
|
||||
}
|
||||
|
||||
F.prototype = obj;
|
||||
return new F();
|
||||
};
|
||||
var toString = function (val) {
|
||||
if (val == null) return '';
|
||||
return (typeof val.toString == 'function') ? val.toString() : _toString.call(val);
|
||||
};
|
||||
var extend = function (dest, src) {
|
||||
var keys = getKeys(src);
|
||||
for (var i = 0, len = keys.length; i < len; i++) {
|
||||
var key = keys[i];
|
||||
dest[key] = src[key];
|
||||
}
|
||||
return dest;
|
||||
};
|
||||
//get a value, lexically, starting in current context; a.b -> get("a","b")
|
||||
var get = function () {
|
||||
var val, n = arguments[0], c = stack.length;
|
||||
while (c--) {
|
||||
val = stack[c][n];
|
||||
if (typeof val != 'undefined') break;
|
||||
}
|
||||
for (var i = 1, len = arguments.length; i < len; i++) {
|
||||
if (val == null) continue;
|
||||
n = arguments[i];
|
||||
val = (_hasOwnProperty.call(val, n)) ? val[n] : (typeof val._get == 'function' ? (val[n] = val._get(n)) : null);
|
||||
}
|
||||
return (val == null) ? '' : val;
|
||||
};
|
||||
var set = function (n, val) {
|
||||
stack[stack.length - 1][n] = val;
|
||||
};
|
||||
var push = function (ctx) {
|
||||
stack.push(ctx || {});
|
||||
};
|
||||
var pop = function () {
|
||||
stack.pop();
|
||||
};
|
||||
var write = function (str) {
|
||||
output.push(str);
|
||||
};
|
||||
var filter = function (val) {
|
||||
for (var i = 1, len = arguments.length; i < len; i++) {
|
||||
var arr = arguments[i], name = arr[0], filter = filters[name];
|
||||
if (filter) {
|
||||
arr[0] = val;
|
||||
//now arr looks like [val, arg1, arg2]
|
||||
val = filter.apply(data, arr);
|
||||
} else {
|
||||
throw new Error('Invalid filter: ' + name);
|
||||
}
|
||||
}
|
||||
if (opts.autoEscape && name !== opts.autoEscape && name !== 'safe') {
|
||||
//auto escape if not explicitly safe or already escaped
|
||||
val = filters[opts.autoEscape].call(data, val);
|
||||
}
|
||||
output.push(val);
|
||||
};
|
||||
var each = function (obj, loopvar, fn1, fn2) {
|
||||
if (obj == null) return;
|
||||
var arr = isArray(obj) ? obj : getKeys(obj), len = arr.length;
|
||||
var ctx = {loop: {length: len, first: arr[0], last: arr[len - 1]}};
|
||||
push(ctx);
|
||||
for (var i = 0; i < len; i++) {
|
||||
extend(ctx.loop, {index: i + 1, index0: i});
|
||||
fn1(ctx[loopvar] = arr[i]);
|
||||
}
|
||||
if (len === 0 && fn2) fn2();
|
||||
pop();
|
||||
};
|
||||
var block = function (fn) {
|
||||
push();
|
||||
fn();
|
||||
pop();
|
||||
};
|
||||
var render = function () {
|
||||
return output.join('');
|
||||
};
|
||||
data = data || {};
|
||||
opts = extend(defaults, opts || {});
|
||||
var filters = extend({
|
||||
html: function (val) {
|
||||
return toString(val)
|
||||
.split('&').join('&')
|
||||
.split('<').join('<')
|
||||
.split('>').join('>')
|
||||
.split('"').join('"');
|
||||
},
|
||||
safe: function (val) {
|
||||
return val;
|
||||
},
|
||||
toJson: function (val) {
|
||||
if (typeof val === 'object') {
|
||||
return JSON.stringify(val);
|
||||
}
|
||||
return toString(val);
|
||||
}
|
||||
}, opts.filters || {});
|
||||
var stack = [create(data || {})], output = [];
|
||||
return {
|
||||
get: get,
|
||||
set: set,
|
||||
push: push,
|
||||
pop: pop,
|
||||
write: write,
|
||||
filter: filter,
|
||||
each: each,
|
||||
block: block,
|
||||
render: render
|
||||
};
|
||||
};
|
||||
|
||||
var runtime;
|
||||
|
||||
jinja.compile = function (markup, opts) {
|
||||
opts = opts || {};
|
||||
var parser = new Parser();
|
||||
parser.readTemplateFile = this.readTemplateFile;
|
||||
var code = [];
|
||||
code.push('function render($) {');
|
||||
code.push('var get = $.get, set = $.set, push = $.push, pop = $.pop, write = $.write, filter = $.filter, each = $.each, block = $.block;');
|
||||
code.push.apply(code, parser.parse(markup));
|
||||
code.push('return $.render();');
|
||||
code.push('}');
|
||||
code = code.join('\n');
|
||||
if (opts.runtime === false) {
|
||||
var fn = new Function('data', 'options', 'return (' + code + ')(runtime(data, options))');
|
||||
} else {
|
||||
runtime = runtime || (runtime = getRuntime.toString());
|
||||
fn = new Function('data', 'options', 'return (' + code + ')((' + runtime + ')(data, options))');
|
||||
}
|
||||
return {render: fn};
|
||||
};
|
||||
|
||||
jinja.render = function (markup, data, opts) {
|
||||
var tmpl = jinja.compile(markup);
|
||||
return tmpl.render(data, opts);
|
||||
};
|
||||
|
||||
jinja.templateFiles = [];
|
||||
|
||||
jinja.readTemplateFile = function (name) {
|
||||
var templateFiles = this.templateFiles || [];
|
||||
var templateFile = templateFiles[name];
|
||||
if (templateFile == null) {
|
||||
throw new Error('Template file not found: ' + name);
|
||||
}
|
||||
return templateFile;
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* Helpers
|
||||
*/
|
||||
|
||||
function trimLeft(str) {
|
||||
return str.replace(LEADING_SPACE, '');
|
||||
}
|
||||
|
||||
function trimRight(str) {
|
||||
return str.replace(TRAILING_SPACE, '');
|
||||
}
|
||||
|
||||
function matchAll(str, reg, fn) {
|
||||
//copy as global
|
||||
reg = new RegExp(reg.source, 'g' + (reg.ignoreCase ? 'i' : '') + (reg.multiline ? 'm' : ''));
|
||||
var match;
|
||||
while ((match = reg.exec(str))) {
|
||||
var result = fn(match[0], match.index, str);
|
||||
if (typeof result == 'number') {
|
||||
reg.lastIndex = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}));
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define(["exports"],factory):(global=typeof globalThis!=="undefined"?globalThis:global||self,factory(global.jinja={}))})(this,function(jinja){"use strict";var STRINGS=/'(\\.|[^'])*'|"(\\.|[^"'"])*"/g;var IDENTS_AND_NUMS=/([$_a-z][$\w]*)|([+-]?\d+(\.\d+)?)/g;var NUMBER=/^[+-]?\d+(\.\d+)?$/;var NON_PRIMITIVES=/\[[@#~](,[@#~])*\]|\[\]|\{([@i]:[@#~])(,[@i]:[@#~])*\}|\{\}/g;var IDENTIFIERS=/[$_a-z][$\w]*/gi;var VARIABLES=/i(\.i|\[[@#i]\])*/g;var ACCESSOR=/(\.i|\[[@#i]\])/g;var OPERATORS=/(===?|!==?|>=?|<=?|&&|\|\||[+\-\*\/%])/g;var EOPS=/(^|[^$\w])(and|or|not|is|isnot)([^$\w]|$)/g;var LEADING_SPACE=/^\s+/;var TRAILING_SPACE=/\s+$/;var START_TOKEN=/\{\{\{|\{\{|\{%|\{#/;var TAGS={"{{{":/^('(\\.|[^'])*'|"(\\.|[^"'"])*"|.)+?\}\}\}/,"{{":/^('(\\.|[^'])*'|"(\\.|[^"'"])*"|.)+?\}\}/,"{%":/^('(\\.|[^'])*'|"(\\.|[^"'"])*"|.)+?%\}/,"{#":/^('(\\.|[^'])*'|"(\\.|[^"'"])*"|.)+?#\}/};var delimeters={"{%":"directive","{{":"output","{#":"comment"};var operators={and:"&&",or:"||",not:"!",is:"==",isnot:"!="};var constants={true:true,false:false,null:null};function Parser(){this.nest=[];this.compiled=[];this.childBlocks=0;this.parentBlocks=0;this.isSilent=false}Parser.prototype.push=function(line){if(!this.isSilent){this.compiled.push(line)}};Parser.prototype.parse=function(src){this.tokenize(src);return this.compiled};Parser.prototype.tokenize=function(src){var lastEnd=0,parser=this,trimLeading=false;matchAll(src,START_TOKEN,function(open,index,src){var match=src.slice(index+open.length).match(TAGS[open]);match=match?match[0]:"";var simplified=match.replace(STRINGS,"@");if(!match||~simplified.indexOf(open)){return index+1}var inner=match.slice(0,0-open.length);if(inner.charAt(0)==="-")var wsCollapseLeft=true;if(inner.slice(-1)==="-")var wsCollapseRight=true;inner=inner.replace(/^-|-$/g,"").trim();if(parser.rawMode&&open+inner!=="{%endraw"){return index+1}var text=src.slice(lastEnd,index);lastEnd=index+open.length+match.length;if(trimLeading)text=trimLeft(text);if(wsCollapseLeft)text=trimRight(text);if(wsCollapseRight)trimLeading=true;if(open==="{{{"){open="{{";inner+="|safe"}parser.textHandler(text);parser.tokenHandler(open,inner)});var text=src.slice(lastEnd);if(trimLeading)text=trimLeft(text);this.textHandler(text)};Parser.prototype.textHandler=function(text){this.push("write("+JSON.stringify(text)+");")};Parser.prototype.tokenHandler=function(open,inner){var type=delimeters[open];if(type==="directive"){this.compileTag(inner)}else if(type==="output"){var extracted=this.extractEnt(inner,STRINGS,"@");extracted.src=extracted.src.replace(/\|\|/g,"~").split("|");extracted.src=extracted.src.map(function(part){return part.split("~").join("||")});var parts=this.injectEnt(extracted,"@");if(parts.length>1){var filters=parts.slice(1).map(this.parseFilter.bind(this));this.push("filter("+this.parseExpr(parts[0])+","+filters.join(",")+");")}else{this.push("filter("+this.parseExpr(parts[0])+");")}}};Parser.prototype.compileTag=function(str){var directive=str.split(" ")[0];var handler=tagHandlers[directive];if(!handler){throw new Error("Invalid tag: "+str)}handler.call(this,str.slice(directive.length).trim())};Parser.prototype.parseFilter=function(src){src=src.trim();var match=src.match(/[:(]/);var i=match?match.index:-1;if(i<0)return JSON.stringify([src]);var name=src.slice(0,i);var args=src.charAt(i)===":"?src.slice(i+1):src.slice(i+1,-1);args=this.parseExpr(args,{terms:true});return"["+JSON.stringify(name)+","+args+"]"};Parser.prototype.extractEnt=function(src,regex,placeholder){var subs=[],isFunc=typeof placeholder=="function";src=src.replace(regex,function(str){var replacement=isFunc?placeholder(str):placeholder;if(replacement){subs.push(str);return replacement}return str});return{src:src,subs:subs}};Parser.prototype.injectEnt=function(extracted,placeholder){var src=extracted.src,subs=extracted.subs,isArr=Array.isArray(src);var arr=isArr?src:[src];var re=new RegExp("["+placeholder+"]","g"),i=0;arr.forEach(function(src,index){arr[index]=src.replace(re,function(){return subs[i++]})});return isArr?arr:arr[0]};Parser.prototype.replaceComplex=function(s){var parsed=this.extractEnt(s,/i(\.i|\[[@#i]\])+/g,"v");parsed.src=parsed.src.replace(NON_PRIMITIVES,"~");return this.injectEnt(parsed,"v")};Parser.prototype.parseExpr=function(src,opts){opts=opts||{};var parsed1=this.extractEnt(src,STRINGS,"@");parsed1.src=parsed1.src.replace(EOPS,function(s,before,op,after){return op in operators?before+operators[op]+after:s});var parsed2=this.extractEnt(parsed1.src,IDENTS_AND_NUMS,function(s){return s in constants||NUMBER.test(s)?"#":null});var parsed3=this.extractEnt(parsed2.src,IDENTIFIERS,"i");parsed3.src=parsed3.src.replace(/\s+/g,"");var simplified=parsed3.src;while(simplified!==(simplified=this.replaceComplex(simplified)));while(simplified!==(simplified=simplified.replace(/i(\.i|\[[@#i]\])+/,"v")));simplified=simplified.replace(/[iv]\[v?\]/g,"x");simplified=simplified.replace(/[@#~v]/g,"i");simplified=simplified.replace(OPERATORS,"%");simplified=simplified.replace(/!+[i]/g,"i");var terms=opts.terms?simplified.split(","):[simplified];terms.forEach(function(term){while(term!==(term=term.replace(/\(i(%i)*\)/g,"i")));if(!term.match(/^i(%i)*/)){throw new Error("Invalid expression: "+src+" "+term)}});parsed3.src=parsed3.src.replace(VARIABLES,this.parseVar.bind(this));parsed2.src=this.injectEnt(parsed3,"i");parsed1.src=this.injectEnt(parsed2,"#");return this.injectEnt(parsed1,"@")};Parser.prototype.parseVar=function(src){var args=Array.prototype.slice.call(arguments);var str=args.pop(),index=args.pop();if(src==="i"&&str.charAt(index+1)===":"){return'"i"'}var parts=['"i"'];src.replace(ACCESSOR,function(part){if(part===".i"){parts.push('"i"')}else if(part==="[i]"){parts.push('get("i")')}else{parts.push(part.slice(1,-1))}});return"get("+parts.join(",")+")"};Parser.prototype.escName=function(str){return str.replace(/\W/g,function(s){return"$"+s.charCodeAt(0).toString(16)})};Parser.prototype.parseQuoted=function(str){if(str.charAt(0)==="'"){str=str.slice(1,-1).replace(/\\.|"/,function(s){if(s==="\\'")return"'";return s.charAt(0)==="\\"?s:"\\"+s});str='"'+str+'"'}return JSON.parse(str)};var tagHandlers={if:function(expr){this.push("if ("+this.parseExpr(expr)+") {");this.nest.unshift("if")},else:function(){if(this.nest[0]==="for"){this.push("}, function() {")}else{this.push("} else {")}},elseif:function(expr){this.push("} else if ("+this.parseExpr(expr)+") {")},endif:function(){this.nest.shift();this.push("}")},for:function(str){var i=str.indexOf(" in ");var name=str.slice(0,i).trim();var expr=str.slice(i+4).trim();this.push("each("+this.parseExpr(expr)+","+JSON.stringify(name)+",function() {");this.nest.unshift("for")},endfor:function(){this.nest.shift();this.push("});")},raw:function(){this.rawMode=true},endraw:function(){this.rawMode=false},set:function(stmt){var i=stmt.indexOf("=");var name=stmt.slice(0,i).trim();var expr=stmt.slice(i+1).trim();this.push("set("+JSON.stringify(name)+","+this.parseExpr(expr)+");")},block:function(name){if(this.isParent){++this.parentBlocks;var blockName="block_"+(this.escName(name)||this.parentBlocks);this.push("block(typeof "+blockName+' == "function" ? '+blockName+" : function() {")}else if(this.hasParent){this.isSilent=false;++this.childBlocks;blockName="block_"+(this.escName(name)||this.childBlocks);this.push("function "+blockName+"() {")}this.nest.unshift("block")},endblock:function(){this.nest.shift();if(this.isParent){this.push("});")}else if(this.hasParent){this.push("}");this.isSilent=true}},extends:function(name){name=this.parseQuoted(name);var parentSrc=this.readTemplateFile(name);this.isParent=true;this.tokenize(parentSrc);this.isParent=false;this.hasParent=true;this.isSilent=true},include:function(name){name=this.parseQuoted(name);var incSrc=this.readTemplateFile(name);this.isInclude=true;this.tokenize(incSrc);this.isInclude=false}};tagHandlers.assign=tagHandlers.set;tagHandlers.elif=tagHandlers.elseif;var getRuntime=function runtime(data,opts){var defaults={autoEscape:"toJson"};var _toString=Object.prototype.toString;var _hasOwnProperty=Object.prototype.hasOwnProperty;var getKeys=Object.keys||function(obj){var keys=[];for(var n in obj)if(_hasOwnProperty.call(obj,n))keys.push(n);return keys};var isArray=Array.isArray||function(obj){return _toString.call(obj)==="[object Array]"};var create=Object.create||function(obj){function F(){}F.prototype=obj;return new F};var toString=function(val){if(val==null)return"";return typeof val.toString=="function"?val.toString():_toString.call(val)};var extend=function(dest,src){var keys=getKeys(src);for(var i=0,len=keys.length;i<len;i++){var key=keys[i];dest[key]=src[key]}return dest};var get=function(){var val,n=arguments[0],c=stack.length;while(c--){val=stack[c][n];if(typeof val!="undefined")break}for(var i=1,len=arguments.length;i<len;i++){if(val==null)continue;n=arguments[i];val=_hasOwnProperty.call(val,n)?val[n]:typeof val._get=="function"?val[n]=val._get(n):null}return val==null?"":val};var set=function(n,val){stack[stack.length-1][n]=val};var push=function(ctx){stack.push(ctx||{})};var pop=function(){stack.pop()};var write=function(str){output.push(str)};var filter=function(val){for(var i=1,len=arguments.length;i<len;i++){var arr=arguments[i],name=arr[0],filter=filters[name];if(filter){arr[0]=val;val=filter.apply(data,arr)}else{throw new Error("Invalid filter: "+name)}}if(opts.autoEscape&&name!==opts.autoEscape&&name!=="safe"){val=filters[opts.autoEscape].call(data,val)}output.push(val)};var each=function(obj,loopvar,fn1,fn2){if(obj==null)return;var arr=isArray(obj)?obj:getKeys(obj),len=arr.length;var ctx={loop:{length:len,first:arr[0],last:arr[len-1]}};push(ctx);for(var i=0;i<len;i++){extend(ctx.loop,{index:i+1,index0:i});fn1(ctx[loopvar]=arr[i])}if(len===0&&fn2)fn2();pop()};var block=function(fn){push();fn();pop()};var render=function(){return output.join("")};data=data||{};opts=extend(defaults,opts||{});var filters=extend({html:function(val){return toString(val).split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""")},safe:function(val){return val},toJson:function(val){if(typeof val==="object"){return JSON.stringify(val)}return toString(val)}},opts.filters||{});var stack=[create(data||{})],output=[];return{get:get,set:set,push:push,pop:pop,write:write,filter:filter,each:each,block:block,render:render}};var runtime;jinja.compile=function(markup,opts){opts=opts||{};var parser=new Parser;parser.readTemplateFile=this.readTemplateFile;var code=[];code.push("function render($) {");code.push("var get = $.get, set = $.set, push = $.push, pop = $.pop, write = $.write, filter = $.filter, each = $.each, block = $.block;");code.push.apply(code,parser.parse(markup));code.push("return $.render();");code.push("}");code=code.join("\n");if(opts.runtime===false){var fn=new Function("data","options","return ("+code+")(runtime(data, options))")}else{runtime=runtime||(runtime=getRuntime.toString());fn=new Function("data","options","return ("+code+")(("+runtime+")(data, options))")}return{render:fn}};jinja.render=function(markup,data,opts){var tmpl=jinja.compile(markup);return tmpl.render(data,opts)};jinja.templateFiles=[];jinja.readTemplateFile=function(name){var templateFiles=this.templateFiles||[];var templateFile=templateFiles[name];if(templateFile==null){throw new Error("Template file not found: "+name)}return templateFile};function trimLeft(str){return str.replace(LEADING_SPACE,"")}function trimRight(str){return str.replace(TRAILING_SPACE,"")}function matchAll(str,reg,fn){reg=new RegExp(reg.source,"g"+(reg.ignoreCase?"i":"")+(reg.multiline?"m":""));var match;while(match=reg.exec(str)){var result=fn(match[0],match.index,str);if(typeof result=="number"){reg.lastIndex=result}}}});
|
||||
File diff suppressed because one or more lines are too long
+1737
@@ -0,0 +1,1737 @@
|
||||
(function (global, factory) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
||||
typeof define === 'function' && define.amd ? define(factory) :
|
||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.JSON5 = factory());
|
||||
}(this, (function () { 'use strict';
|
||||
|
||||
function createCommonjsModule(fn, module) {
|
||||
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
||||
}
|
||||
|
||||
var _global = createCommonjsModule(function (module) {
|
||||
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
||||
var global = module.exports = typeof window != 'undefined' && window.Math == Math
|
||||
? window : typeof self != 'undefined' && self.Math == Math ? self
|
||||
// eslint-disable-next-line no-new-func
|
||||
: Function('return this')();
|
||||
if (typeof __g == 'number') { __g = global; } // eslint-disable-line no-undef
|
||||
});
|
||||
|
||||
var _core = createCommonjsModule(function (module) {
|
||||
var core = module.exports = { version: '2.6.5' };
|
||||
if (typeof __e == 'number') { __e = core; } // eslint-disable-line no-undef
|
||||
});
|
||||
var _core_1 = _core.version;
|
||||
|
||||
var _isObject = function (it) {
|
||||
return typeof it === 'object' ? it !== null : typeof it === 'function';
|
||||
};
|
||||
|
||||
var _anObject = function (it) {
|
||||
if (!_isObject(it)) { throw TypeError(it + ' is not an object!'); }
|
||||
return it;
|
||||
};
|
||||
|
||||
var _fails = function (exec) {
|
||||
try {
|
||||
return !!exec();
|
||||
} catch (e) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
// Thank's IE8 for his funny defineProperty
|
||||
var _descriptors = !_fails(function () {
|
||||
return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
|
||||
});
|
||||
|
||||
var document = _global.document;
|
||||
// typeof document.createElement is 'object' in old IE
|
||||
var is = _isObject(document) && _isObject(document.createElement);
|
||||
var _domCreate = function (it) {
|
||||
return is ? document.createElement(it) : {};
|
||||
};
|
||||
|
||||
var _ie8DomDefine = !_descriptors && !_fails(function () {
|
||||
return Object.defineProperty(_domCreate('div'), 'a', { get: function () { return 7; } }).a != 7;
|
||||
});
|
||||
|
||||
// 7.1.1 ToPrimitive(input [, PreferredType])
|
||||
|
||||
// instead of the ES6 spec version, we didn't implement @@toPrimitive case
|
||||
// and the second argument - flag - preferred type is a string
|
||||
var _toPrimitive = function (it, S) {
|
||||
if (!_isObject(it)) { return it; }
|
||||
var fn, val;
|
||||
if (S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) { return val; }
|
||||
if (typeof (fn = it.valueOf) == 'function' && !_isObject(val = fn.call(it))) { return val; }
|
||||
if (!S && typeof (fn = it.toString) == 'function' && !_isObject(val = fn.call(it))) { return val; }
|
||||
throw TypeError("Can't convert object to primitive value");
|
||||
};
|
||||
|
||||
var dP = Object.defineProperty;
|
||||
|
||||
var f = _descriptors ? Object.defineProperty : function defineProperty(O, P, Attributes) {
|
||||
_anObject(O);
|
||||
P = _toPrimitive(P, true);
|
||||
_anObject(Attributes);
|
||||
if (_ie8DomDefine) { try {
|
||||
return dP(O, P, Attributes);
|
||||
} catch (e) { /* empty */ } }
|
||||
if ('get' in Attributes || 'set' in Attributes) { throw TypeError('Accessors not supported!'); }
|
||||
if ('value' in Attributes) { O[P] = Attributes.value; }
|
||||
return O;
|
||||
};
|
||||
|
||||
var _objectDp = {
|
||||
f: f
|
||||
};
|
||||
|
||||
var _propertyDesc = function (bitmap, value) {
|
||||
return {
|
||||
enumerable: !(bitmap & 1),
|
||||
configurable: !(bitmap & 2),
|
||||
writable: !(bitmap & 4),
|
||||
value: value
|
||||
};
|
||||
};
|
||||
|
||||
var _hide = _descriptors ? function (object, key, value) {
|
||||
return _objectDp.f(object, key, _propertyDesc(1, value));
|
||||
} : function (object, key, value) {
|
||||
object[key] = value;
|
||||
return object;
|
||||
};
|
||||
|
||||
var hasOwnProperty = {}.hasOwnProperty;
|
||||
var _has = function (it, key) {
|
||||
return hasOwnProperty.call(it, key);
|
||||
};
|
||||
|
||||
var id = 0;
|
||||
var px = Math.random();
|
||||
var _uid = function (key) {
|
||||
return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + px).toString(36));
|
||||
};
|
||||
|
||||
var _library = false;
|
||||
|
||||
var _shared = createCommonjsModule(function (module) {
|
||||
var SHARED = '__core-js_shared__';
|
||||
var store = _global[SHARED] || (_global[SHARED] = {});
|
||||
|
||||
(module.exports = function (key, value) {
|
||||
return store[key] || (store[key] = value !== undefined ? value : {});
|
||||
})('versions', []).push({
|
||||
version: _core.version,
|
||||
mode: _library ? 'pure' : 'global',
|
||||
copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
|
||||
});
|
||||
});
|
||||
|
||||
var _functionToString = _shared('native-function-to-string', Function.toString);
|
||||
|
||||
var _redefine = createCommonjsModule(function (module) {
|
||||
var SRC = _uid('src');
|
||||
|
||||
var TO_STRING = 'toString';
|
||||
var TPL = ('' + _functionToString).split(TO_STRING);
|
||||
|
||||
_core.inspectSource = function (it) {
|
||||
return _functionToString.call(it);
|
||||
};
|
||||
|
||||
(module.exports = function (O, key, val, safe) {
|
||||
var isFunction = typeof val == 'function';
|
||||
if (isFunction) { _has(val, 'name') || _hide(val, 'name', key); }
|
||||
if (O[key] === val) { return; }
|
||||
if (isFunction) { _has(val, SRC) || _hide(val, SRC, O[key] ? '' + O[key] : TPL.join(String(key))); }
|
||||
if (O === _global) {
|
||||
O[key] = val;
|
||||
} else if (!safe) {
|
||||
delete O[key];
|
||||
_hide(O, key, val);
|
||||
} else if (O[key]) {
|
||||
O[key] = val;
|
||||
} else {
|
||||
_hide(O, key, val);
|
||||
}
|
||||
// add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
|
||||
})(Function.prototype, TO_STRING, function toString() {
|
||||
return typeof this == 'function' && this[SRC] || _functionToString.call(this);
|
||||
});
|
||||
});
|
||||
|
||||
var _aFunction = function (it) {
|
||||
if (typeof it != 'function') { throw TypeError(it + ' is not a function!'); }
|
||||
return it;
|
||||
};
|
||||
|
||||
// optional / simple context binding
|
||||
|
||||
var _ctx = function (fn, that, length) {
|
||||
_aFunction(fn);
|
||||
if (that === undefined) { return fn; }
|
||||
switch (length) {
|
||||
case 1: return function (a) {
|
||||
return fn.call(that, a);
|
||||
};
|
||||
case 2: return function (a, b) {
|
||||
return fn.call(that, a, b);
|
||||
};
|
||||
case 3: return function (a, b, c) {
|
||||
return fn.call(that, a, b, c);
|
||||
};
|
||||
}
|
||||
return function (/* ...args */) {
|
||||
return fn.apply(that, arguments);
|
||||
};
|
||||
};
|
||||
|
||||
var PROTOTYPE = 'prototype';
|
||||
|
||||
var $export = function (type, name, source) {
|
||||
var IS_FORCED = type & $export.F;
|
||||
var IS_GLOBAL = type & $export.G;
|
||||
var IS_STATIC = type & $export.S;
|
||||
var IS_PROTO = type & $export.P;
|
||||
var IS_BIND = type & $export.B;
|
||||
var target = IS_GLOBAL ? _global : IS_STATIC ? _global[name] || (_global[name] = {}) : (_global[name] || {})[PROTOTYPE];
|
||||
var exports = IS_GLOBAL ? _core : _core[name] || (_core[name] = {});
|
||||
var expProto = exports[PROTOTYPE] || (exports[PROTOTYPE] = {});
|
||||
var key, own, out, exp;
|
||||
if (IS_GLOBAL) { source = name; }
|
||||
for (key in source) {
|
||||
// contains in native
|
||||
own = !IS_FORCED && target && target[key] !== undefined;
|
||||
// export native or passed
|
||||
out = (own ? target : source)[key];
|
||||
// bind timers to global for call from export context
|
||||
exp = IS_BIND && own ? _ctx(out, _global) : IS_PROTO && typeof out == 'function' ? _ctx(Function.call, out) : out;
|
||||
// extend global
|
||||
if (target) { _redefine(target, key, out, type & $export.U); }
|
||||
// export
|
||||
if (exports[key] != out) { _hide(exports, key, exp); }
|
||||
if (IS_PROTO && expProto[key] != out) { expProto[key] = out; }
|
||||
}
|
||||
};
|
||||
_global.core = _core;
|
||||
// type bitmap
|
||||
$export.F = 1; // forced
|
||||
$export.G = 2; // global
|
||||
$export.S = 4; // static
|
||||
$export.P = 8; // proto
|
||||
$export.B = 16; // bind
|
||||
$export.W = 32; // wrap
|
||||
$export.U = 64; // safe
|
||||
$export.R = 128; // real proto method for `library`
|
||||
var _export = $export;
|
||||
|
||||
// 7.1.4 ToInteger
|
||||
var ceil = Math.ceil;
|
||||
var floor = Math.floor;
|
||||
var _toInteger = function (it) {
|
||||
return isNaN(it = +it) ? 0 : (it > 0 ? floor : ceil)(it);
|
||||
};
|
||||
|
||||
// 7.2.1 RequireObjectCoercible(argument)
|
||||
var _defined = function (it) {
|
||||
if (it == undefined) { throw TypeError("Can't call method on " + it); }
|
||||
return it;
|
||||
};
|
||||
|
||||
// true -> String#at
|
||||
// false -> String#codePointAt
|
||||
var _stringAt = function (TO_STRING) {
|
||||
return function (that, pos) {
|
||||
var s = String(_defined(that));
|
||||
var i = _toInteger(pos);
|
||||
var l = s.length;
|
||||
var a, b;
|
||||
if (i < 0 || i >= l) { return TO_STRING ? '' : undefined; }
|
||||
a = s.charCodeAt(i);
|
||||
return a < 0xd800 || a > 0xdbff || i + 1 === l || (b = s.charCodeAt(i + 1)) < 0xdc00 || b > 0xdfff
|
||||
? TO_STRING ? s.charAt(i) : a
|
||||
: TO_STRING ? s.slice(i, i + 2) : (a - 0xd800 << 10) + (b - 0xdc00) + 0x10000;
|
||||
};
|
||||
};
|
||||
|
||||
var $at = _stringAt(false);
|
||||
_export(_export.P, 'String', {
|
||||
// 21.1.3.3 String.prototype.codePointAt(pos)
|
||||
codePointAt: function codePointAt(pos) {
|
||||
return $at(this, pos);
|
||||
}
|
||||
});
|
||||
|
||||
var codePointAt = _core.String.codePointAt;
|
||||
|
||||
var max = Math.max;
|
||||
var min = Math.min;
|
||||
var _toAbsoluteIndex = function (index, length) {
|
||||
index = _toInteger(index);
|
||||
return index < 0 ? max(index + length, 0) : min(index, length);
|
||||
};
|
||||
|
||||
var fromCharCode = String.fromCharCode;
|
||||
var $fromCodePoint = String.fromCodePoint;
|
||||
|
||||
// length should be 1, old FF problem
|
||||
_export(_export.S + _export.F * (!!$fromCodePoint && $fromCodePoint.length != 1), 'String', {
|
||||
// 21.1.2.2 String.fromCodePoint(...codePoints)
|
||||
fromCodePoint: function fromCodePoint(x) {
|
||||
var arguments$1 = arguments;
|
||||
// eslint-disable-line no-unused-vars
|
||||
var res = [];
|
||||
var aLen = arguments.length;
|
||||
var i = 0;
|
||||
var code;
|
||||
while (aLen > i) {
|
||||
code = +arguments$1[i++];
|
||||
if (_toAbsoluteIndex(code, 0x10ffff) !== code) { throw RangeError(code + ' is not a valid code point'); }
|
||||
res.push(code < 0x10000
|
||||
? fromCharCode(code)
|
||||
: fromCharCode(((code -= 0x10000) >> 10) + 0xd800, code % 0x400 + 0xdc00)
|
||||
);
|
||||
} return res.join('');
|
||||
}
|
||||
});
|
||||
|
||||
var fromCodePoint = _core.String.fromCodePoint;
|
||||
|
||||
// This is a generated file. Do not edit.
|
||||
var Space_Separator = /[\u1680\u2000-\u200A\u202F\u205F\u3000]/;
|
||||
var ID_Start = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/;
|
||||
var ID_Continue = /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/;
|
||||
|
||||
var unicode = {
|
||||
Space_Separator: Space_Separator,
|
||||
ID_Start: ID_Start,
|
||||
ID_Continue: ID_Continue
|
||||
};
|
||||
|
||||
var util = {
|
||||
isSpaceSeparator: function isSpaceSeparator (c) {
|
||||
return typeof c === 'string' && unicode.Space_Separator.test(c)
|
||||
},
|
||||
|
||||
isIdStartChar: function isIdStartChar (c) {
|
||||
return typeof c === 'string' && (
|
||||
(c >= 'a' && c <= 'z') ||
|
||||
(c >= 'A' && c <= 'Z') ||
|
||||
(c === '$') || (c === '_') ||
|
||||
unicode.ID_Start.test(c)
|
||||
)
|
||||
},
|
||||
|
||||
isIdContinueChar: function isIdContinueChar (c) {
|
||||
return typeof c === 'string' && (
|
||||
(c >= 'a' && c <= 'z') ||
|
||||
(c >= 'A' && c <= 'Z') ||
|
||||
(c >= '0' && c <= '9') ||
|
||||
(c === '$') || (c === '_') ||
|
||||
(c === '\u200C') || (c === '\u200D') ||
|
||||
unicode.ID_Continue.test(c)
|
||||
)
|
||||
},
|
||||
|
||||
isDigit: function isDigit (c) {
|
||||
return typeof c === 'string' && /[0-9]/.test(c)
|
||||
},
|
||||
|
||||
isHexDigit: function isHexDigit (c) {
|
||||
return typeof c === 'string' && /[0-9A-Fa-f]/.test(c)
|
||||
},
|
||||
};
|
||||
|
||||
var source;
|
||||
var parseState;
|
||||
var stack;
|
||||
var pos;
|
||||
var line;
|
||||
var column;
|
||||
var token;
|
||||
var key;
|
||||
var root;
|
||||
|
||||
var parse = function parse (text, reviver) {
|
||||
source = String(text);
|
||||
parseState = 'start';
|
||||
stack = [];
|
||||
pos = 0;
|
||||
line = 1;
|
||||
column = 0;
|
||||
token = undefined;
|
||||
key = undefined;
|
||||
root = undefined;
|
||||
|
||||
do {
|
||||
token = lex();
|
||||
|
||||
// This code is unreachable.
|
||||
// if (!parseStates[parseState]) {
|
||||
// throw invalidParseState()
|
||||
// }
|
||||
|
||||
parseStates[parseState]();
|
||||
} while (token.type !== 'eof')
|
||||
|
||||
if (typeof reviver === 'function') {
|
||||
return internalize({'': root}, '', reviver)
|
||||
}
|
||||
|
||||
return root
|
||||
};
|
||||
|
||||
function internalize (holder, name, reviver) {
|
||||
var value = holder[name];
|
||||
if (value != null && typeof value === 'object') {
|
||||
if (Array.isArray(value)) {
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
var key = String(i);
|
||||
var replacement = internalize(value, key, reviver);
|
||||
if (replacement === undefined) {
|
||||
delete value[key];
|
||||
} else {
|
||||
Object.defineProperty(value, key, {
|
||||
value: replacement,
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var key$1 in value) {
|
||||
var replacement$1 = internalize(value, key$1, reviver);
|
||||
if (replacement$1 === undefined) {
|
||||
delete value[key$1];
|
||||
} else {
|
||||
Object.defineProperty(value, key$1, {
|
||||
value: replacement$1,
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return reviver.call(holder, name, value)
|
||||
}
|
||||
|
||||
var lexState;
|
||||
var buffer;
|
||||
var doubleQuote;
|
||||
var sign;
|
||||
var c;
|
||||
|
||||
function lex () {
|
||||
lexState = 'default';
|
||||
buffer = '';
|
||||
doubleQuote = false;
|
||||
sign = 1;
|
||||
|
||||
for (;;) {
|
||||
c = peek();
|
||||
|
||||
// This code is unreachable.
|
||||
// if (!lexStates[lexState]) {
|
||||
// throw invalidLexState(lexState)
|
||||
// }
|
||||
|
||||
var token = lexStates[lexState]();
|
||||
if (token) {
|
||||
return token
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function peek () {
|
||||
if (source[pos]) {
|
||||
return String.fromCodePoint(source.codePointAt(pos))
|
||||
}
|
||||
}
|
||||
|
||||
function read () {
|
||||
var c = peek();
|
||||
|
||||
if (c === '\n') {
|
||||
line++;
|
||||
column = 0;
|
||||
} else if (c) {
|
||||
column += c.length;
|
||||
} else {
|
||||
column++;
|
||||
}
|
||||
|
||||
if (c) {
|
||||
pos += c.length;
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
var lexStates = {
|
||||
default: function default$1 () {
|
||||
switch (c) {
|
||||
case '\t':
|
||||
case '\v':
|
||||
case '\f':
|
||||
case ' ':
|
||||
case '\u00A0':
|
||||
case '\uFEFF':
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\u2028':
|
||||
case '\u2029':
|
||||
read();
|
||||
return
|
||||
|
||||
case '/':
|
||||
read();
|
||||
lexState = 'comment';
|
||||
return
|
||||
|
||||
case undefined:
|
||||
read();
|
||||
return newToken('eof')
|
||||
}
|
||||
|
||||
if (util.isSpaceSeparator(c)) {
|
||||
read();
|
||||
return
|
||||
}
|
||||
|
||||
// This code is unreachable.
|
||||
// if (!lexStates[parseState]) {
|
||||
// throw invalidLexState(parseState)
|
||||
// }
|
||||
|
||||
return lexStates[parseState]()
|
||||
},
|
||||
|
||||
comment: function comment () {
|
||||
switch (c) {
|
||||
case '*':
|
||||
read();
|
||||
lexState = 'multiLineComment';
|
||||
return
|
||||
|
||||
case '/':
|
||||
read();
|
||||
lexState = 'singleLineComment';
|
||||
return
|
||||
}
|
||||
|
||||
throw invalidChar(read())
|
||||
},
|
||||
|
||||
multiLineComment: function multiLineComment () {
|
||||
switch (c) {
|
||||
case '*':
|
||||
read();
|
||||
lexState = 'multiLineCommentAsterisk';
|
||||
return
|
||||
|
||||
case undefined:
|
||||
throw invalidChar(read())
|
||||
}
|
||||
|
||||
read();
|
||||
},
|
||||
|
||||
multiLineCommentAsterisk: function multiLineCommentAsterisk () {
|
||||
switch (c) {
|
||||
case '*':
|
||||
read();
|
||||
return
|
||||
|
||||
case '/':
|
||||
read();
|
||||
lexState = 'default';
|
||||
return
|
||||
|
||||
case undefined:
|
||||
throw invalidChar(read())
|
||||
}
|
||||
|
||||
read();
|
||||
lexState = 'multiLineComment';
|
||||
},
|
||||
|
||||
singleLineComment: function singleLineComment () {
|
||||
switch (c) {
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\u2028':
|
||||
case '\u2029':
|
||||
read();
|
||||
lexState = 'default';
|
||||
return
|
||||
|
||||
case undefined:
|
||||
read();
|
||||
return newToken('eof')
|
||||
}
|
||||
|
||||
read();
|
||||
},
|
||||
|
||||
value: function value () {
|
||||
switch (c) {
|
||||
case '{':
|
||||
case '[':
|
||||
return newToken('punctuator', read())
|
||||
|
||||
case 'n':
|
||||
read();
|
||||
literal('ull');
|
||||
return newToken('null', null)
|
||||
|
||||
case 't':
|
||||
read();
|
||||
literal('rue');
|
||||
return newToken('boolean', true)
|
||||
|
||||
case 'f':
|
||||
read();
|
||||
literal('alse');
|
||||
return newToken('boolean', false)
|
||||
|
||||
case '-':
|
||||
case '+':
|
||||
if (read() === '-') {
|
||||
sign = -1;
|
||||
}
|
||||
|
||||
lexState = 'sign';
|
||||
return
|
||||
|
||||
case '.':
|
||||
buffer = read();
|
||||
lexState = 'decimalPointLeading';
|
||||
return
|
||||
|
||||
case '0':
|
||||
buffer = read();
|
||||
lexState = 'zero';
|
||||
return
|
||||
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
buffer = read();
|
||||
lexState = 'decimalInteger';
|
||||
return
|
||||
|
||||
case 'I':
|
||||
read();
|
||||
literal('nfinity');
|
||||
return newToken('numeric', Infinity)
|
||||
|
||||
case 'N':
|
||||
read();
|
||||
literal('aN');
|
||||
return newToken('numeric', NaN)
|
||||
|
||||
case '"':
|
||||
case "'":
|
||||
doubleQuote = (read() === '"');
|
||||
buffer = '';
|
||||
lexState = 'string';
|
||||
return
|
||||
}
|
||||
|
||||
throw invalidChar(read())
|
||||
},
|
||||
|
||||
identifierNameStartEscape: function identifierNameStartEscape () {
|
||||
if (c !== 'u') {
|
||||
throw invalidChar(read())
|
||||
}
|
||||
|
||||
read();
|
||||
var u = unicodeEscape();
|
||||
switch (u) {
|
||||
case '$':
|
||||
case '_':
|
||||
break
|
||||
|
||||
default:
|
||||
if (!util.isIdStartChar(u)) {
|
||||
throw invalidIdentifier()
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
buffer += u;
|
||||
lexState = 'identifierName';
|
||||
},
|
||||
|
||||
identifierName: function identifierName () {
|
||||
switch (c) {
|
||||
case '$':
|
||||
case '_':
|
||||
case '\u200C':
|
||||
case '\u200D':
|
||||
buffer += read();
|
||||
return
|
||||
|
||||
case '\\':
|
||||
read();
|
||||
lexState = 'identifierNameEscape';
|
||||
return
|
||||
}
|
||||
|
||||
if (util.isIdContinueChar(c)) {
|
||||
buffer += read();
|
||||
return
|
||||
}
|
||||
|
||||
return newToken('identifier', buffer)
|
||||
},
|
||||
|
||||
identifierNameEscape: function identifierNameEscape () {
|
||||
if (c !== 'u') {
|
||||
throw invalidChar(read())
|
||||
}
|
||||
|
||||
read();
|
||||
var u = unicodeEscape();
|
||||
switch (u) {
|
||||
case '$':
|
||||
case '_':
|
||||
case '\u200C':
|
||||
case '\u200D':
|
||||
break
|
||||
|
||||
default:
|
||||
if (!util.isIdContinueChar(u)) {
|
||||
throw invalidIdentifier()
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
|
||||
buffer += u;
|
||||
lexState = 'identifierName';
|
||||
},
|
||||
|
||||
sign: function sign$1 () {
|
||||
switch (c) {
|
||||
case '.':
|
||||
buffer = read();
|
||||
lexState = 'decimalPointLeading';
|
||||
return
|
||||
|
||||
case '0':
|
||||
buffer = read();
|
||||
lexState = 'zero';
|
||||
return
|
||||
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
buffer = read();
|
||||
lexState = 'decimalInteger';
|
||||
return
|
||||
|
||||
case 'I':
|
||||
read();
|
||||
literal('nfinity');
|
||||
return newToken('numeric', sign * Infinity)
|
||||
|
||||
case 'N':
|
||||
read();
|
||||
literal('aN');
|
||||
return newToken('numeric', NaN)
|
||||
}
|
||||
|
||||
throw invalidChar(read())
|
||||
},
|
||||
|
||||
zero: function zero () {
|
||||
switch (c) {
|
||||
case '.':
|
||||
buffer += read();
|
||||
lexState = 'decimalPoint';
|
||||
return
|
||||
|
||||
case 'e':
|
||||
case 'E':
|
||||
buffer += read();
|
||||
lexState = 'decimalExponent';
|
||||
return
|
||||
|
||||
case 'x':
|
||||
case 'X':
|
||||
buffer += read();
|
||||
lexState = 'hexadecimal';
|
||||
return
|
||||
}
|
||||
|
||||
return newToken('numeric', sign * 0)
|
||||
},
|
||||
|
||||
decimalInteger: function decimalInteger () {
|
||||
switch (c) {
|
||||
case '.':
|
||||
buffer += read();
|
||||
lexState = 'decimalPoint';
|
||||
return
|
||||
|
||||
case 'e':
|
||||
case 'E':
|
||||
buffer += read();
|
||||
lexState = 'decimalExponent';
|
||||
return
|
||||
}
|
||||
|
||||
if (util.isDigit(c)) {
|
||||
buffer += read();
|
||||
return
|
||||
}
|
||||
|
||||
return newToken('numeric', sign * Number(buffer))
|
||||
},
|
||||
|
||||
decimalPointLeading: function decimalPointLeading () {
|
||||
if (util.isDigit(c)) {
|
||||
buffer += read();
|
||||
lexState = 'decimalFraction';
|
||||
return
|
||||
}
|
||||
|
||||
throw invalidChar(read())
|
||||
},
|
||||
|
||||
decimalPoint: function decimalPoint () {
|
||||
switch (c) {
|
||||
case 'e':
|
||||
case 'E':
|
||||
buffer += read();
|
||||
lexState = 'decimalExponent';
|
||||
return
|
||||
}
|
||||
|
||||
if (util.isDigit(c)) {
|
||||
buffer += read();
|
||||
lexState = 'decimalFraction';
|
||||
return
|
||||
}
|
||||
|
||||
return newToken('numeric', sign * Number(buffer))
|
||||
},
|
||||
|
||||
decimalFraction: function decimalFraction () {
|
||||
switch (c) {
|
||||
case 'e':
|
||||
case 'E':
|
||||
buffer += read();
|
||||
lexState = 'decimalExponent';
|
||||
return
|
||||
}
|
||||
|
||||
if (util.isDigit(c)) {
|
||||
buffer += read();
|
||||
return
|
||||
}
|
||||
|
||||
return newToken('numeric', sign * Number(buffer))
|
||||
},
|
||||
|
||||
decimalExponent: function decimalExponent () {
|
||||
switch (c) {
|
||||
case '+':
|
||||
case '-':
|
||||
buffer += read();
|
||||
lexState = 'decimalExponentSign';
|
||||
return
|
||||
}
|
||||
|
||||
if (util.isDigit(c)) {
|
||||
buffer += read();
|
||||
lexState = 'decimalExponentInteger';
|
||||
return
|
||||
}
|
||||
|
||||
throw invalidChar(read())
|
||||
},
|
||||
|
||||
decimalExponentSign: function decimalExponentSign () {
|
||||
if (util.isDigit(c)) {
|
||||
buffer += read();
|
||||
lexState = 'decimalExponentInteger';
|
||||
return
|
||||
}
|
||||
|
||||
throw invalidChar(read())
|
||||
},
|
||||
|
||||
decimalExponentInteger: function decimalExponentInteger () {
|
||||
if (util.isDigit(c)) {
|
||||
buffer += read();
|
||||
return
|
||||
}
|
||||
|
||||
return newToken('numeric', sign * Number(buffer))
|
||||
},
|
||||
|
||||
hexadecimal: function hexadecimal () {
|
||||
if (util.isHexDigit(c)) {
|
||||
buffer += read();
|
||||
lexState = 'hexadecimalInteger';
|
||||
return
|
||||
}
|
||||
|
||||
throw invalidChar(read())
|
||||
},
|
||||
|
||||
hexadecimalInteger: function hexadecimalInteger () {
|
||||
if (util.isHexDigit(c)) {
|
||||
buffer += read();
|
||||
return
|
||||
}
|
||||
|
||||
return newToken('numeric', sign * Number(buffer))
|
||||
},
|
||||
|
||||
string: function string () {
|
||||
switch (c) {
|
||||
case '\\':
|
||||
read();
|
||||
buffer += escape();
|
||||
return
|
||||
|
||||
case '"':
|
||||
if (doubleQuote) {
|
||||
read();
|
||||
return newToken('string', buffer)
|
||||
}
|
||||
|
||||
buffer += read();
|
||||
return
|
||||
|
||||
case "'":
|
||||
if (!doubleQuote) {
|
||||
read();
|
||||
return newToken('string', buffer)
|
||||
}
|
||||
|
||||
buffer += read();
|
||||
return
|
||||
|
||||
case '\n':
|
||||
case '\r':
|
||||
throw invalidChar(read())
|
||||
|
||||
case '\u2028':
|
||||
case '\u2029':
|
||||
separatorChar(c);
|
||||
break
|
||||
|
||||
case undefined:
|
||||
throw invalidChar(read())
|
||||
}
|
||||
|
||||
buffer += read();
|
||||
},
|
||||
|
||||
start: function start () {
|
||||
switch (c) {
|
||||
case '{':
|
||||
case '[':
|
||||
return newToken('punctuator', read())
|
||||
|
||||
// This code is unreachable since the default lexState handles eof.
|
||||
// case undefined:
|
||||
// return newToken('eof')
|
||||
}
|
||||
|
||||
lexState = 'value';
|
||||
},
|
||||
|
||||
beforePropertyName: function beforePropertyName () {
|
||||
switch (c) {
|
||||
case '$':
|
||||
case '_':
|
||||
buffer = read();
|
||||
lexState = 'identifierName';
|
||||
return
|
||||
|
||||
case '\\':
|
||||
read();
|
||||
lexState = 'identifierNameStartEscape';
|
||||
return
|
||||
|
||||
case '}':
|
||||
return newToken('punctuator', read())
|
||||
|
||||
case '"':
|
||||
case "'":
|
||||
doubleQuote = (read() === '"');
|
||||
lexState = 'string';
|
||||
return
|
||||
}
|
||||
|
||||
if (util.isIdStartChar(c)) {
|
||||
buffer += read();
|
||||
lexState = 'identifierName';
|
||||
return
|
||||
}
|
||||
|
||||
throw invalidChar(read())
|
||||
},
|
||||
|
||||
afterPropertyName: function afterPropertyName () {
|
||||
if (c === ':') {
|
||||
return newToken('punctuator', read())
|
||||
}
|
||||
|
||||
throw invalidChar(read())
|
||||
},
|
||||
|
||||
beforePropertyValue: function beforePropertyValue () {
|
||||
lexState = 'value';
|
||||
},
|
||||
|
||||
afterPropertyValue: function afterPropertyValue () {
|
||||
switch (c) {
|
||||
case ',':
|
||||
case '}':
|
||||
return newToken('punctuator', read())
|
||||
}
|
||||
|
||||
throw invalidChar(read())
|
||||
},
|
||||
|
||||
beforeArrayValue: function beforeArrayValue () {
|
||||
if (c === ']') {
|
||||
return newToken('punctuator', read())
|
||||
}
|
||||
|
||||
lexState = 'value';
|
||||
},
|
||||
|
||||
afterArrayValue: function afterArrayValue () {
|
||||
switch (c) {
|
||||
case ',':
|
||||
case ']':
|
||||
return newToken('punctuator', read())
|
||||
}
|
||||
|
||||
throw invalidChar(read())
|
||||
},
|
||||
|
||||
end: function end () {
|
||||
// This code is unreachable since it's handled by the default lexState.
|
||||
// if (c === undefined) {
|
||||
// read()
|
||||
// return newToken('eof')
|
||||
// }
|
||||
|
||||
throw invalidChar(read())
|
||||
},
|
||||
};
|
||||
|
||||
function newToken (type, value) {
|
||||
return {
|
||||
type: type,
|
||||
value: value,
|
||||
line: line,
|
||||
column: column,
|
||||
}
|
||||
}
|
||||
|
||||
function literal (s) {
|
||||
for (var i = 0, list = s; i < list.length; i += 1) {
|
||||
var c = list[i];
|
||||
|
||||
var p = peek();
|
||||
|
||||
if (p !== c) {
|
||||
throw invalidChar(read())
|
||||
}
|
||||
|
||||
read();
|
||||
}
|
||||
}
|
||||
|
||||
function escape () {
|
||||
var c = peek();
|
||||
switch (c) {
|
||||
case 'b':
|
||||
read();
|
||||
return '\b'
|
||||
|
||||
case 'f':
|
||||
read();
|
||||
return '\f'
|
||||
|
||||
case 'n':
|
||||
read();
|
||||
return '\n'
|
||||
|
||||
case 'r':
|
||||
read();
|
||||
return '\r'
|
||||
|
||||
case 't':
|
||||
read();
|
||||
return '\t'
|
||||
|
||||
case 'v':
|
||||
read();
|
||||
return '\v'
|
||||
|
||||
case '0':
|
||||
read();
|
||||
if (util.isDigit(peek())) {
|
||||
throw invalidChar(read())
|
||||
}
|
||||
|
||||
return '\0'
|
||||
|
||||
case 'x':
|
||||
read();
|
||||
return hexEscape()
|
||||
|
||||
case 'u':
|
||||
read();
|
||||
return unicodeEscape()
|
||||
|
||||
case '\n':
|
||||
case '\u2028':
|
||||
case '\u2029':
|
||||
read();
|
||||
return ''
|
||||
|
||||
case '\r':
|
||||
read();
|
||||
if (peek() === '\n') {
|
||||
read();
|
||||
}
|
||||
|
||||
return ''
|
||||
|
||||
case '1':
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
case '7':
|
||||
case '8':
|
||||
case '9':
|
||||
throw invalidChar(read())
|
||||
|
||||
case undefined:
|
||||
throw invalidChar(read())
|
||||
}
|
||||
|
||||
return read()
|
||||
}
|
||||
|
||||
function hexEscape () {
|
||||
var buffer = '';
|
||||
var c = peek();
|
||||
|
||||
if (!util.isHexDigit(c)) {
|
||||
throw invalidChar(read())
|
||||
}
|
||||
|
||||
buffer += read();
|
||||
|
||||
c = peek();
|
||||
if (!util.isHexDigit(c)) {
|
||||
throw invalidChar(read())
|
||||
}
|
||||
|
||||
buffer += read();
|
||||
|
||||
return String.fromCodePoint(parseInt(buffer, 16))
|
||||
}
|
||||
|
||||
function unicodeEscape () {
|
||||
var buffer = '';
|
||||
var count = 4;
|
||||
|
||||
while (count-- > 0) {
|
||||
var c = peek();
|
||||
if (!util.isHexDigit(c)) {
|
||||
throw invalidChar(read())
|
||||
}
|
||||
|
||||
buffer += read();
|
||||
}
|
||||
|
||||
return String.fromCodePoint(parseInt(buffer, 16))
|
||||
}
|
||||
|
||||
var parseStates = {
|
||||
start: function start () {
|
||||
if (token.type === 'eof') {
|
||||
throw invalidEOF()
|
||||
}
|
||||
|
||||
push();
|
||||
},
|
||||
|
||||
beforePropertyName: function beforePropertyName () {
|
||||
switch (token.type) {
|
||||
case 'identifier':
|
||||
case 'string':
|
||||
key = token.value;
|
||||
parseState = 'afterPropertyName';
|
||||
return
|
||||
|
||||
case 'punctuator':
|
||||
// This code is unreachable since it's handled by the lexState.
|
||||
// if (token.value !== '}') {
|
||||
// throw invalidToken()
|
||||
// }
|
||||
|
||||
pop();
|
||||
return
|
||||
|
||||
case 'eof':
|
||||
throw invalidEOF()
|
||||
}
|
||||
|
||||
// This code is unreachable since it's handled by the lexState.
|
||||
// throw invalidToken()
|
||||
},
|
||||
|
||||
afterPropertyName: function afterPropertyName () {
|
||||
// This code is unreachable since it's handled by the lexState.
|
||||
// if (token.type !== 'punctuator' || token.value !== ':') {
|
||||
// throw invalidToken()
|
||||
// }
|
||||
|
||||
if (token.type === 'eof') {
|
||||
throw invalidEOF()
|
||||
}
|
||||
|
||||
parseState = 'beforePropertyValue';
|
||||
},
|
||||
|
||||
beforePropertyValue: function beforePropertyValue () {
|
||||
if (token.type === 'eof') {
|
||||
throw invalidEOF()
|
||||
}
|
||||
|
||||
push();
|
||||
},
|
||||
|
||||
beforeArrayValue: function beforeArrayValue () {
|
||||
if (token.type === 'eof') {
|
||||
throw invalidEOF()
|
||||
}
|
||||
|
||||
if (token.type === 'punctuator' && token.value === ']') {
|
||||
pop();
|
||||
return
|
||||
}
|
||||
|
||||
push();
|
||||
},
|
||||
|
||||
afterPropertyValue: function afterPropertyValue () {
|
||||
// This code is unreachable since it's handled by the lexState.
|
||||
// if (token.type !== 'punctuator') {
|
||||
// throw invalidToken()
|
||||
// }
|
||||
|
||||
if (token.type === 'eof') {
|
||||
throw invalidEOF()
|
||||
}
|
||||
|
||||
switch (token.value) {
|
||||
case ',':
|
||||
parseState = 'beforePropertyName';
|
||||
return
|
||||
|
||||
case '}':
|
||||
pop();
|
||||
}
|
||||
|
||||
// This code is unreachable since it's handled by the lexState.
|
||||
// throw invalidToken()
|
||||
},
|
||||
|
||||
afterArrayValue: function afterArrayValue () {
|
||||
// This code is unreachable since it's handled by the lexState.
|
||||
// if (token.type !== 'punctuator') {
|
||||
// throw invalidToken()
|
||||
// }
|
||||
|
||||
if (token.type === 'eof') {
|
||||
throw invalidEOF()
|
||||
}
|
||||
|
||||
switch (token.value) {
|
||||
case ',':
|
||||
parseState = 'beforeArrayValue';
|
||||
return
|
||||
|
||||
case ']':
|
||||
pop();
|
||||
}
|
||||
|
||||
// This code is unreachable since it's handled by the lexState.
|
||||
// throw invalidToken()
|
||||
},
|
||||
|
||||
end: function end () {
|
||||
// This code is unreachable since it's handled by the lexState.
|
||||
// if (token.type !== 'eof') {
|
||||
// throw invalidToken()
|
||||
// }
|
||||
},
|
||||
};
|
||||
|
||||
function push () {
|
||||
var value;
|
||||
|
||||
switch (token.type) {
|
||||
case 'punctuator':
|
||||
switch (token.value) {
|
||||
case '{':
|
||||
value = {};
|
||||
break
|
||||
|
||||
case '[':
|
||||
value = [];
|
||||
break
|
||||
}
|
||||
|
||||
break
|
||||
|
||||
case 'null':
|
||||
case 'boolean':
|
||||
case 'numeric':
|
||||
case 'string':
|
||||
value = token.value;
|
||||
break
|
||||
|
||||
// This code is unreachable.
|
||||
// default:
|
||||
// throw invalidToken()
|
||||
}
|
||||
|
||||
if (root === undefined) {
|
||||
root = value;
|
||||
} else {
|
||||
var parent = stack[stack.length - 1];
|
||||
if (Array.isArray(parent)) {
|
||||
parent.push(value);
|
||||
} else {
|
||||
Object.defineProperty(parent, key, {
|
||||
value: value,
|
||||
writable: true,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (value !== null && typeof value === 'object') {
|
||||
stack.push(value);
|
||||
|
||||
if (Array.isArray(value)) {
|
||||
parseState = 'beforeArrayValue';
|
||||
} else {
|
||||
parseState = 'beforePropertyName';
|
||||
}
|
||||
} else {
|
||||
var current = stack[stack.length - 1];
|
||||
if (current == null) {
|
||||
parseState = 'end';
|
||||
} else if (Array.isArray(current)) {
|
||||
parseState = 'afterArrayValue';
|
||||
} else {
|
||||
parseState = 'afterPropertyValue';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function pop () {
|
||||
stack.pop();
|
||||
|
||||
var current = stack[stack.length - 1];
|
||||
if (current == null) {
|
||||
parseState = 'end';
|
||||
} else if (Array.isArray(current)) {
|
||||
parseState = 'afterArrayValue';
|
||||
} else {
|
||||
parseState = 'afterPropertyValue';
|
||||
}
|
||||
}
|
||||
|
||||
// This code is unreachable.
|
||||
// function invalidParseState () {
|
||||
// return new Error(`JSON5: invalid parse state '${parseState}'`)
|
||||
// }
|
||||
|
||||
// This code is unreachable.
|
||||
// function invalidLexState (state) {
|
||||
// return new Error(`JSON5: invalid lex state '${state}'`)
|
||||
// }
|
||||
|
||||
function invalidChar (c) {
|
||||
if (c === undefined) {
|
||||
return syntaxError(("JSON5: invalid end of input at " + line + ":" + column))
|
||||
}
|
||||
|
||||
return syntaxError(("JSON5: invalid character '" + (formatChar(c)) + "' at " + line + ":" + column))
|
||||
}
|
||||
|
||||
function invalidEOF () {
|
||||
return syntaxError(("JSON5: invalid end of input at " + line + ":" + column))
|
||||
}
|
||||
|
||||
// This code is unreachable.
|
||||
// function invalidToken () {
|
||||
// if (token.type === 'eof') {
|
||||
// return syntaxError(`JSON5: invalid end of input at ${line}:${column}`)
|
||||
// }
|
||||
|
||||
// const c = String.fromCodePoint(token.value.codePointAt(0))
|
||||
// return syntaxError(`JSON5: invalid character '${formatChar(c)}' at ${line}:${column}`)
|
||||
// }
|
||||
|
||||
function invalidIdentifier () {
|
||||
column -= 5;
|
||||
return syntaxError(("JSON5: invalid identifier character at " + line + ":" + column))
|
||||
}
|
||||
|
||||
function separatorChar (c) {
|
||||
console.warn(("JSON5: '" + (formatChar(c)) + "' in strings is not valid ECMAScript; consider escaping"));
|
||||
}
|
||||
|
||||
function formatChar (c) {
|
||||
var replacements = {
|
||||
"'": "\\'",
|
||||
'"': '\\"',
|
||||
'\\': '\\\\',
|
||||
'\b': '\\b',
|
||||
'\f': '\\f',
|
||||
'\n': '\\n',
|
||||
'\r': '\\r',
|
||||
'\t': '\\t',
|
||||
'\v': '\\v',
|
||||
'\0': '\\0',
|
||||
'\u2028': '\\u2028',
|
||||
'\u2029': '\\u2029',
|
||||
};
|
||||
|
||||
if (replacements[c]) {
|
||||
return replacements[c]
|
||||
}
|
||||
|
||||
if (c < ' ') {
|
||||
var hexString = c.charCodeAt(0).toString(16);
|
||||
return '\\x' + ('00' + hexString).substring(hexString.length)
|
||||
}
|
||||
|
||||
return c
|
||||
}
|
||||
|
||||
function syntaxError (message) {
|
||||
var err = new SyntaxError(message);
|
||||
err.lineNumber = line;
|
||||
err.columnNumber = column;
|
||||
return err
|
||||
}
|
||||
|
||||
var stringify = function stringify (value, replacer, space) {
|
||||
var stack = [];
|
||||
var indent = '';
|
||||
var propertyList;
|
||||
var replacerFunc;
|
||||
var gap = '';
|
||||
var quote;
|
||||
|
||||
if (
|
||||
replacer != null &&
|
||||
typeof replacer === 'object' &&
|
||||
!Array.isArray(replacer)
|
||||
) {
|
||||
space = replacer.space;
|
||||
quote = replacer.quote;
|
||||
replacer = replacer.replacer;
|
||||
}
|
||||
|
||||
if (typeof replacer === 'function') {
|
||||
replacerFunc = replacer;
|
||||
} else if (Array.isArray(replacer)) {
|
||||
propertyList = [];
|
||||
for (var i = 0, list = replacer; i < list.length; i += 1) {
|
||||
var v = list[i];
|
||||
|
||||
var item = (void 0);
|
||||
|
||||
if (typeof v === 'string') {
|
||||
item = v;
|
||||
} else if (
|
||||
typeof v === 'number' ||
|
||||
v instanceof String ||
|
||||
v instanceof Number
|
||||
) {
|
||||
item = String(v);
|
||||
}
|
||||
|
||||
if (item !== undefined && propertyList.indexOf(item) < 0) {
|
||||
propertyList.push(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (space instanceof Number) {
|
||||
space = Number(space);
|
||||
} else if (space instanceof String) {
|
||||
space = String(space);
|
||||
}
|
||||
|
||||
if (typeof space === 'number') {
|
||||
if (space > 0) {
|
||||
space = Math.min(10, Math.floor(space));
|
||||
gap = ' '.substr(0, space);
|
||||
}
|
||||
} else if (typeof space === 'string') {
|
||||
gap = space.substr(0, 10);
|
||||
}
|
||||
|
||||
return serializeProperty('', {'': value})
|
||||
|
||||
function serializeProperty (key, holder) {
|
||||
var value = holder[key];
|
||||
if (value != null) {
|
||||
if (typeof value.toJSON5 === 'function') {
|
||||
value = value.toJSON5(key);
|
||||
} else if (typeof value.toJSON === 'function') {
|
||||
value = value.toJSON(key);
|
||||
}
|
||||
}
|
||||
|
||||
if (replacerFunc) {
|
||||
value = replacerFunc.call(holder, key, value);
|
||||
}
|
||||
|
||||
if (value instanceof Number) {
|
||||
value = Number(value);
|
||||
} else if (value instanceof String) {
|
||||
value = String(value);
|
||||
} else if (value instanceof Boolean) {
|
||||
value = value.valueOf();
|
||||
}
|
||||
|
||||
switch (value) {
|
||||
case null: return 'null'
|
||||
case true: return 'true'
|
||||
case false: return 'false'
|
||||
}
|
||||
|
||||
if (typeof value === 'string') {
|
||||
return quoteString(value, false)
|
||||
}
|
||||
|
||||
if (typeof value === 'number') {
|
||||
return String(value)
|
||||
}
|
||||
|
||||
if (typeof value === 'object') {
|
||||
return Array.isArray(value) ? serializeArray(value) : serializeObject(value)
|
||||
}
|
||||
|
||||
return undefined
|
||||
}
|
||||
|
||||
function quoteString (value) {
|
||||
var quotes = {
|
||||
"'": 0.1,
|
||||
'"': 0.2,
|
||||
};
|
||||
|
||||
var replacements = {
|
||||
"'": "\\'",
|
||||
'"': '\\"',
|
||||
'\\': '\\\\',
|
||||
'\b': '\\b',
|
||||
'\f': '\\f',
|
||||
'\n': '\\n',
|
||||
'\r': '\\r',
|
||||
'\t': '\\t',
|
||||
'\v': '\\v',
|
||||
'\0': '\\0',
|
||||
'\u2028': '\\u2028',
|
||||
'\u2029': '\\u2029',
|
||||
};
|
||||
|
||||
var product = '';
|
||||
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
var c = value[i];
|
||||
switch (c) {
|
||||
case "'":
|
||||
case '"':
|
||||
quotes[c]++;
|
||||
product += c;
|
||||
continue
|
||||
|
||||
case '\0':
|
||||
if (util.isDigit(value[i + 1])) {
|
||||
product += '\\x00';
|
||||
continue
|
||||
}
|
||||
}
|
||||
|
||||
if (replacements[c]) {
|
||||
product += replacements[c];
|
||||
continue
|
||||
}
|
||||
|
||||
if (c < ' ') {
|
||||
var hexString = c.charCodeAt(0).toString(16);
|
||||
product += '\\x' + ('00' + hexString).substring(hexString.length);
|
||||
continue
|
||||
}
|
||||
|
||||
product += c;
|
||||
}
|
||||
|
||||
var quoteChar = quote || Object.keys(quotes).reduce(function (a, b) { return (quotes[a] < quotes[b]) ? a : b; });
|
||||
|
||||
product = product.replace(new RegExp(quoteChar, 'g'), replacements[quoteChar]);
|
||||
|
||||
return quoteChar + product + quoteChar
|
||||
}
|
||||
|
||||
function serializeObject (value) {
|
||||
if (stack.indexOf(value) >= 0) {
|
||||
throw TypeError('Converting circular structure to JSON5')
|
||||
}
|
||||
|
||||
stack.push(value);
|
||||
|
||||
var stepback = indent;
|
||||
indent = indent + gap;
|
||||
|
||||
var keys = propertyList || Object.keys(value);
|
||||
var partial = [];
|
||||
for (var i = 0, list = keys; i < list.length; i += 1) {
|
||||
var key = list[i];
|
||||
|
||||
var propertyString = serializeProperty(key, value);
|
||||
if (propertyString !== undefined) {
|
||||
var member = serializeKey(key) + ':';
|
||||
if (gap !== '') {
|
||||
member += ' ';
|
||||
}
|
||||
member += propertyString;
|
||||
partial.push(member);
|
||||
}
|
||||
}
|
||||
|
||||
var final;
|
||||
if (partial.length === 0) {
|
||||
final = '{}';
|
||||
} else {
|
||||
var properties;
|
||||
if (gap === '') {
|
||||
properties = partial.join(',');
|
||||
final = '{' + properties + '}';
|
||||
} else {
|
||||
var separator = ',\n' + indent;
|
||||
properties = partial.join(separator);
|
||||
final = '{\n' + indent + properties + ',\n' + stepback + '}';
|
||||
}
|
||||
}
|
||||
|
||||
stack.pop();
|
||||
indent = stepback;
|
||||
return final
|
||||
}
|
||||
|
||||
function serializeKey (key) {
|
||||
if (key.length === 0) {
|
||||
return quoteString(key, true)
|
||||
}
|
||||
|
||||
var firstChar = String.fromCodePoint(key.codePointAt(0));
|
||||
if (!util.isIdStartChar(firstChar)) {
|
||||
return quoteString(key, true)
|
||||
}
|
||||
|
||||
for (var i = firstChar.length; i < key.length; i++) {
|
||||
if (!util.isIdContinueChar(String.fromCodePoint(key.codePointAt(i)))) {
|
||||
return quoteString(key, true)
|
||||
}
|
||||
}
|
||||
|
||||
return key
|
||||
}
|
||||
|
||||
function serializeArray (value) {
|
||||
if (stack.indexOf(value) >= 0) {
|
||||
throw TypeError('Converting circular structure to JSON5')
|
||||
}
|
||||
|
||||
stack.push(value);
|
||||
|
||||
var stepback = indent;
|
||||
indent = indent + gap;
|
||||
|
||||
var partial = [];
|
||||
for (var i = 0; i < value.length; i++) {
|
||||
var propertyString = serializeProperty(String(i), value);
|
||||
partial.push((propertyString !== undefined) ? propertyString : 'null');
|
||||
}
|
||||
|
||||
var final;
|
||||
if (partial.length === 0) {
|
||||
final = '[]';
|
||||
} else {
|
||||
if (gap === '') {
|
||||
var properties = partial.join(',');
|
||||
final = '[' + properties + ']';
|
||||
} else {
|
||||
var separator = ',\n' + indent;
|
||||
var properties$1 = partial.join(separator);
|
||||
final = '[\n' + indent + properties$1 + ',\n' + stepback + ']';
|
||||
}
|
||||
}
|
||||
|
||||
stack.pop();
|
||||
indent = stepback;
|
||||
return final
|
||||
}
|
||||
};
|
||||
|
||||
var JSON5 = {
|
||||
parse: parse,
|
||||
stringify: stringify,
|
||||
};
|
||||
|
||||
var lib = JSON5;
|
||||
|
||||
var es5 = lib;
|
||||
|
||||
return es5;
|
||||
|
||||
})));
|
||||
File diff suppressed because one or more lines are too long
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
/*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */
|
||||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).pako={})}(this,(function(t){"use strict";function e(t){let e=t.length;for(;--e>=0;)t[e]=0}const a=256,i=286,n=30,s=15,r=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),o=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),l=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),h=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),d=new Array(576);e(d);const _=new Array(60);e(_);const f=new Array(512);e(f);const c=new Array(256);e(c);const u=new Array(29);e(u);const w=new Array(n);function m(t,e,a,i,n){this.static_tree=t,this.extra_bits=e,this.extra_base=a,this.elems=i,this.max_length=n,this.has_stree=t&&t.length}let b,g,p;function k(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}e(w);const v=t=>t<256?f[t]:f[256+(t>>>7)],y=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},x=(t,e,a)=>{t.bi_valid>16-a?(t.bi_buf|=e<<t.bi_valid&65535,y(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=a-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=a)},z=(t,e,a)=>{x(t,a[2*e],a[2*e+1])},A=(t,e)=>{let a=0;do{a|=1&t,t>>>=1,a<<=1}while(--e>0);return a>>>1},E=(t,e,a)=>{const i=new Array(16);let n,r,o=0;for(n=1;n<=s;n++)o=o+a[n-1]<<1,i[n]=o;for(r=0;r<=e;r++){let e=t[2*r+1];0!==e&&(t[2*r]=A(i[e]++,e))}},R=t=>{let e;for(e=0;e<i;e++)t.dyn_ltree[2*e]=0;for(e=0;e<n;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},Z=t=>{t.bi_valid>8?y(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},U=(t,e,a,i)=>{const n=2*e,s=2*a;return t[n]<t[s]||t[n]===t[s]&&i[e]<=i[a]},S=(t,e,a)=>{const i=t.heap[a];let n=a<<1;for(;n<=t.heap_len&&(n<t.heap_len&&U(e,t.heap[n+1],t.heap[n],t.depth)&&n++,!U(e,i,t.heap[n],t.depth));)t.heap[a]=t.heap[n],a=n,n<<=1;t.heap[a]=i},D=(t,e,i)=>{let n,s,l,h,d=0;if(0!==t.sym_next)do{n=255&t.pending_buf[t.sym_buf+d++],n+=(255&t.pending_buf[t.sym_buf+d++])<<8,s=t.pending_buf[t.sym_buf+d++],0===n?z(t,s,e):(l=c[s],z(t,l+a+1,e),h=r[l],0!==h&&(s-=u[l],x(t,s,h)),n--,l=v(n),z(t,l,i),h=o[l],0!==h&&(n-=w[l],x(t,n,h)))}while(d<t.sym_next);z(t,256,e)},T=(t,e)=>{const a=e.dyn_tree,i=e.stat_desc.static_tree,n=e.stat_desc.has_stree,r=e.stat_desc.elems;let o,l,h,d=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<r;o++)0!==a[2*o]?(t.heap[++t.heap_len]=d=o,t.depth[o]=0):a[2*o+1]=0;for(;t.heap_len<2;)h=t.heap[++t.heap_len]=d<2?++d:0,a[2*h]=1,t.depth[h]=0,t.opt_len--,n&&(t.static_len-=i[2*h+1]);for(e.max_code=d,o=t.heap_len>>1;o>=1;o--)S(t,a,o);h=r;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],S(t,a,1),l=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=l,a[2*h]=a[2*o]+a[2*l],t.depth[h]=(t.depth[o]>=t.depth[l]?t.depth[o]:t.depth[l])+1,a[2*o+1]=a[2*l+1]=h,t.heap[1]=h++,S(t,a,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const a=e.dyn_tree,i=e.max_code,n=e.stat_desc.static_tree,r=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,l=e.stat_desc.extra_base,h=e.stat_desc.max_length;let d,_,f,c,u,w,m=0;for(c=0;c<=s;c++)t.bl_count[c]=0;for(a[2*t.heap[t.heap_max]+1]=0,d=t.heap_max+1;d<573;d++)_=t.heap[d],c=a[2*a[2*_+1]+1]+1,c>h&&(c=h,m++),a[2*_+1]=c,_>i||(t.bl_count[c]++,u=0,_>=l&&(u=o[_-l]),w=a[2*_],t.opt_len+=w*(c+u),r&&(t.static_len+=w*(n[2*_+1]+u)));if(0!==m){do{for(c=h-1;0===t.bl_count[c];)c--;t.bl_count[c]--,t.bl_count[c+1]+=2,t.bl_count[h]--,m-=2}while(m>0);for(c=h;0!==c;c--)for(_=t.bl_count[c];0!==_;)f=t.heap[--d],f>i||(a[2*f+1]!==c&&(t.opt_len+=(c-a[2*f+1])*a[2*f],a[2*f+1]=c),_--)}})(t,e),E(a,d,t.bl_count)},O=(t,e,a)=>{let i,n,s=-1,r=e[1],o=0,l=7,h=4;for(0===r&&(l=138,h=3),e[2*(a+1)+1]=65535,i=0;i<=a;i++)n=r,r=e[2*(i+1)+1],++o<l&&n===r||(o<h?t.bl_tree[2*n]+=o:0!==n?(n!==s&&t.bl_tree[2*n]++,t.bl_tree[32]++):o<=10?t.bl_tree[34]++:t.bl_tree[36]++,o=0,s=n,0===r?(l=138,h=3):n===r?(l=6,h=3):(l=7,h=4))},I=(t,e,a)=>{let i,n,s=-1,r=e[1],o=0,l=7,h=4;for(0===r&&(l=138,h=3),i=0;i<=a;i++)if(n=r,r=e[2*(i+1)+1],!(++o<l&&n===r)){if(o<h)do{z(t,n,t.bl_tree)}while(0!=--o);else 0!==n?(n!==s&&(z(t,n,t.bl_tree),o--),z(t,16,t.bl_tree),x(t,o-3,2)):o<=10?(z(t,17,t.bl_tree),x(t,o-3,3)):(z(t,18,t.bl_tree),x(t,o-11,7));o=0,s=n,0===r?(l=138,h=3):n===r?(l=6,h=3):(l=7,h=4)}};let F=!1;const L=(t,e,a,i)=>{x(t,0+(i?1:0),3),Z(t),y(t,a),y(t,~a),a&&t.pending_buf.set(t.window.subarray(e,e+a),t.pending),t.pending+=a};var N=(t,e,i,n)=>{let s,r,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,i=4093624447;for(e=0;e<=31;e++,i>>>=1)if(1&i&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<a;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),T(t,t.l_desc),T(t,t.d_desc),o=(t=>{let e;for(O(t,t.dyn_ltree,t.l_desc.max_code),O(t,t.dyn_dtree,t.d_desc.max_code),T(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*h[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),s=t.opt_len+3+7>>>3,r=t.static_len+3+7>>>3,r<=s&&(s=r)):s=r=i+5,i+4<=s&&-1!==e?L(t,e,i,n):4===t.strategy||r===s?(x(t,2+(n?1:0),3),D(t,d,_)):(x(t,4+(n?1:0),3),((t,e,a,i)=>{let n;for(x(t,e-257,5),x(t,a-1,5),x(t,i-4,4),n=0;n<i;n++)x(t,t.bl_tree[2*h[n]+1],3);I(t,t.dyn_ltree,e-1),I(t,t.dyn_dtree,a-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),D(t,t.dyn_ltree,t.dyn_dtree)),R(t),n&&Z(t)},B={_tr_init:t=>{F||((()=>{let t,e,a,h,k;const v=new Array(16);for(a=0,h=0;h<28;h++)for(u[h]=a,t=0;t<1<<r[h];t++)c[a++]=h;for(c[a-1]=h,k=0,h=0;h<16;h++)for(w[h]=k,t=0;t<1<<o[h];t++)f[k++]=h;for(k>>=7;h<n;h++)for(w[h]=k<<7,t=0;t<1<<o[h]-7;t++)f[256+k++]=h;for(e=0;e<=s;e++)v[e]=0;for(t=0;t<=143;)d[2*t+1]=8,t++,v[8]++;for(;t<=255;)d[2*t+1]=9,t++,v[9]++;for(;t<=279;)d[2*t+1]=7,t++,v[7]++;for(;t<=287;)d[2*t+1]=8,t++,v[8]++;for(E(d,287,v),t=0;t<n;t++)_[2*t+1]=5,_[2*t]=A(t,5);b=new m(d,r,257,i,s),g=new m(_,o,0,n,s),p=new m(new Array(0),l,0,19,7)})(),F=!0),t.l_desc=new k(t.dyn_ltree,b),t.d_desc=new k(t.dyn_dtree,g),t.bl_desc=new k(t.bl_tree,p),t.bi_buf=0,t.bi_valid=0,R(t)},_tr_stored_block:L,_tr_flush_block:N,_tr_tally:(t,e,i)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=i,0===e?t.dyn_ltree[2*i]++:(t.matches++,e--,t.dyn_ltree[2*(c[i]+a+1)]++,t.dyn_dtree[2*v(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{x(t,2,3),z(t,256,d),(t=>{16===t.bi_valid?(y(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}};var C=(t,e,a,i)=>{let n=65535&t|0,s=t>>>16&65535|0,r=0;for(;0!==a;){r=a>2e3?2e3:a,a-=r;do{n=n+e[i++]|0,s=s+n|0}while(--r);n%=65521,s%=65521}return n|s<<16|0};const M=new Uint32Array((()=>{let t,e=[];for(var a=0;a<256;a++){t=a;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[a]=t}return e})());var H=(t,e,a,i)=>{const n=M,s=i+a;t^=-1;for(let a=i;a<s;a++)t=t>>>8^n[255&(t^e[a])];return-1^t},j={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},K={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:P,_tr_stored_block:Y,_tr_flush_block:G,_tr_tally:X,_tr_align:W}=B,{Z_NO_FLUSH:q,Z_PARTIAL_FLUSH:J,Z_FULL_FLUSH:Q,Z_FINISH:V,Z_BLOCK:$,Z_OK:tt,Z_STREAM_END:et,Z_STREAM_ERROR:at,Z_DATA_ERROR:it,Z_BUF_ERROR:nt,Z_DEFAULT_COMPRESSION:st,Z_FILTERED:rt,Z_HUFFMAN_ONLY:ot,Z_RLE:lt,Z_FIXED:ht,Z_DEFAULT_STRATEGY:dt,Z_UNKNOWN:_t,Z_DEFLATED:ft}=K,ct=258,ut=262,wt=42,mt=113,bt=666,gt=(t,e)=>(t.msg=j[e],e),pt=t=>2*t-(t>4?9:0),kt=t=>{let e=t.length;for(;--e>=0;)t[e]=0},vt=t=>{let e,a,i,n=t.w_size;e=t.hash_size,i=e;do{a=t.head[--i],t.head[i]=a>=n?a-n:0}while(--e);e=n,i=e;do{a=t.prev[--i],t.prev[i]=a>=n?a-n:0}while(--e)};let yt=(t,e,a)=>(e<<t.hash_shift^a)&t.hash_mask;const xt=t=>{const e=t.state;let a=e.pending;a>t.avail_out&&(a=t.avail_out),0!==a&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+a),t.next_out),t.next_out+=a,e.pending_out+=a,t.total_out+=a,t.avail_out-=a,e.pending-=a,0===e.pending&&(e.pending_out=0))},zt=(t,e)=>{G(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,xt(t.strm)},At=(t,e)=>{t.pending_buf[t.pending++]=e},Et=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},Rt=(t,e,a,i)=>{let n=t.avail_in;return n>i&&(n=i),0===n?0:(t.avail_in-=n,e.set(t.input.subarray(t.next_in,t.next_in+n),a),1===t.state.wrap?t.adler=C(t.adler,e,n,a):2===t.state.wrap&&(t.adler=H(t.adler,e,n,a)),t.next_in+=n,t.total_in+=n,n)},Zt=(t,e)=>{let a,i,n=t.max_chain_length,s=t.strstart,r=t.prev_length,o=t.nice_match;const l=t.strstart>t.w_size-ut?t.strstart-(t.w_size-ut):0,h=t.window,d=t.w_mask,_=t.prev,f=t.strstart+ct;let c=h[s+r-1],u=h[s+r];t.prev_length>=t.good_match&&(n>>=2),o>t.lookahead&&(o=t.lookahead);do{if(a=e,h[a+r]===u&&h[a+r-1]===c&&h[a]===h[s]&&h[++a]===h[s+1]){s+=2,a++;do{}while(h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&h[++s]===h[++a]&&s<f);if(i=ct-(f-s),s=f-ct,i>r){if(t.match_start=e,r=i,i>=o)break;c=h[s+r-1],u=h[s+r]}}}while((e=_[e&d])>l&&0!=--n);return r<=t.lookahead?r:t.lookahead},Ut=t=>{const e=t.w_size;let a,i,n;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-ut)&&(t.window.set(t.window.subarray(e,e+e-i),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),vt(t),i+=e),0===t.strm.avail_in)break;if(a=Rt(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=a,t.lookahead+t.insert>=3)for(n=t.strstart-t.insert,t.ins_h=t.window[n],t.ins_h=yt(t,t.ins_h,t.window[n+1]);t.insert&&(t.ins_h=yt(t,t.ins_h,t.window[n+3-1]),t.prev[n&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=n,n++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<ut&&0!==t.strm.avail_in)},St=(t,e)=>{let a,i,n,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,r=0,o=t.strm.avail_in;do{if(a=65535,n=t.bi_valid+42>>3,t.strm.avail_out<n)break;if(n=t.strm.avail_out-n,i=t.strstart-t.block_start,a>i+t.strm.avail_in&&(a=i+t.strm.avail_in),a>n&&(a=n),a<s&&(0===a&&e!==V||e===q||a!==i+t.strm.avail_in))break;r=e===V&&a===i+t.strm.avail_in?1:0,Y(t,0,0,r),t.pending_buf[t.pending-4]=a,t.pending_buf[t.pending-3]=a>>8,t.pending_buf[t.pending-2]=~a,t.pending_buf[t.pending-1]=~a>>8,xt(t.strm),i&&(i>a&&(i=a),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+i),t.strm.next_out),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i,t.block_start+=i,a-=i),a&&(Rt(t.strm,t.strm.output,t.strm.next_out,a),t.strm.next_out+=a,t.strm.avail_out-=a,t.strm.total_out+=a)}while(0===r);return o-=t.strm.avail_in,o&&(o>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=o&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-o,t.strm.next_in),t.strstart),t.strstart+=o,t.insert+=o>t.w_size-t.insert?t.w_size-t.insert:o),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),r?4:e!==q&&e!==V&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(n=t.window_size-t.strstart,t.strm.avail_in>n&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,n+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),n>t.strm.avail_in&&(n=t.strm.avail_in),n&&(Rt(t.strm,t.window,t.strstart,n),t.strstart+=n,t.insert+=n>t.w_size-t.insert?t.w_size-t.insert:n),t.high_water<t.strstart&&(t.high_water=t.strstart),n=t.bi_valid+42>>3,n=t.pending_buf_size-n>65535?65535:t.pending_buf_size-n,s=n>t.w_size?t.w_size:n,i=t.strstart-t.block_start,(i>=s||(i||e===V)&&e!==q&&0===t.strm.avail_in&&i<=n)&&(a=i>n?n:i,r=e===V&&0===t.strm.avail_in&&a===i?1:0,Y(t,t.block_start,a,r),t.block_start+=a,xt(t.strm)),r?3:1)},Dt=(t,e)=>{let a,i;for(;;){if(t.lookahead<ut){if(Ut(t),t.lookahead<ut&&e===q)return 1;if(0===t.lookahead)break}if(a=0,t.lookahead>=3&&(t.ins_h=yt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==a&&t.strstart-a<=t.w_size-ut&&(t.match_length=Zt(t,a)),t.match_length>=3)if(i=X(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=yt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=yt(t,t.ins_h,t.window[t.strstart+1]);else i=X(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(zt(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===V?(zt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(zt(t,!1),0===t.strm.avail_out)?1:2},Tt=(t,e)=>{let a,i,n;for(;;){if(t.lookahead<ut){if(Ut(t),t.lookahead<ut&&e===q)return 1;if(0===t.lookahead)break}if(a=0,t.lookahead>=3&&(t.ins_h=yt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==a&&t.prev_length<t.max_lazy_match&&t.strstart-a<=t.w_size-ut&&(t.match_length=Zt(t,a),t.match_length<=5&&(t.strategy===rt||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){n=t.strstart+t.lookahead-3,i=X(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=n&&(t.ins_h=yt(t,t.ins_h,t.window[t.strstart+3-1]),a=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,i&&(zt(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=X(t,0,t.window[t.strstart-1]),i&&zt(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=X(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===V?(zt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(zt(t,!1),0===t.strm.avail_out)?1:2};function Ot(t,e,a,i,n){this.good_length=t,this.max_lazy=e,this.nice_length=a,this.max_chain=i,this.func=n}const It=[new Ot(0,0,0,0,St),new Ot(4,4,8,4,Dt),new Ot(4,5,16,8,Dt),new Ot(4,6,32,32,Dt),new Ot(4,4,16,16,Tt),new Ot(8,16,32,32,Tt),new Ot(8,16,128,128,Tt),new Ot(8,32,128,256,Tt),new Ot(32,128,258,1024,Tt),new Ot(32,258,258,4096,Tt)];function Ft(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=ft,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),kt(this.dyn_ltree),kt(this.dyn_dtree),kt(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),kt(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),kt(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const Lt=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==wt&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==mt&&e.status!==bt?1:0},Nt=t=>{if(Lt(t))return gt(t,at);t.total_in=t.total_out=0,t.data_type=_t;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?wt:mt,t.adler=2===e.wrap?0:1,e.last_flush=-2,P(e),tt},Bt=t=>{const e=Nt(t);var a;return e===tt&&((a=t.state).window_size=2*a.w_size,kt(a.head),a.max_lazy_match=It[a.level].max_lazy,a.good_match=It[a.level].good_length,a.nice_match=It[a.level].nice_length,a.max_chain_length=It[a.level].max_chain,a.strstart=0,a.block_start=0,a.lookahead=0,a.insert=0,a.match_length=a.prev_length=2,a.match_available=0,a.ins_h=0),e},Ct=(t,e,a,i,n,s)=>{if(!t)return at;let r=1;if(e===st&&(e=6),i<0?(r=0,i=-i):i>15&&(r=2,i-=16),n<1||n>9||a!==ft||i<8||i>15||e<0||e>9||s<0||s>ht||8===i&&1!==r)return gt(t,at);8===i&&(i=9);const o=new Ft;return t.state=o,o.strm=t,o.status=wt,o.wrap=r,o.gzhead=null,o.w_bits=i,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=n+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<n+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=e,o.strategy=s,o.method=a,Bt(t)};var Mt={deflateInit:(t,e)=>Ct(t,e,ft,15,8,dt),deflateInit2:Ct,deflateReset:Bt,deflateResetKeep:Nt,deflateSetHeader:(t,e)=>Lt(t)||2!==t.state.wrap?at:(t.state.gzhead=e,tt),deflate:(t,e)=>{if(Lt(t)||e>$||e<0)return t?gt(t,at):at;const a=t.state;if(!t.output||0!==t.avail_in&&!t.input||a.status===bt&&e!==V)return gt(t,0===t.avail_out?nt:at);const i=a.last_flush;if(a.last_flush=e,0!==a.pending){if(xt(t),0===t.avail_out)return a.last_flush=-1,tt}else if(0===t.avail_in&&pt(e)<=pt(i)&&e!==V)return gt(t,nt);if(a.status===bt&&0!==t.avail_in)return gt(t,nt);if(a.status===wt&&0===a.wrap&&(a.status=mt),a.status===wt){let e=ft+(a.w_bits-8<<4)<<8,i=-1;if(i=a.strategy>=ot||a.level<2?0:a.level<6?1:6===a.level?2:3,e|=i<<6,0!==a.strstart&&(e|=32),e+=31-e%31,Et(a,e),0!==a.strstart&&(Et(a,t.adler>>>16),Et(a,65535&t.adler)),t.adler=1,a.status=mt,xt(t),0!==a.pending)return a.last_flush=-1,tt}if(57===a.status)if(t.adler=0,At(a,31),At(a,139),At(a,8),a.gzhead)At(a,(a.gzhead.text?1:0)+(a.gzhead.hcrc?2:0)+(a.gzhead.extra?4:0)+(a.gzhead.name?8:0)+(a.gzhead.comment?16:0)),At(a,255&a.gzhead.time),At(a,a.gzhead.time>>8&255),At(a,a.gzhead.time>>16&255),At(a,a.gzhead.time>>24&255),At(a,9===a.level?2:a.strategy>=ot||a.level<2?4:0),At(a,255&a.gzhead.os),a.gzhead.extra&&a.gzhead.extra.length&&(At(a,255&a.gzhead.extra.length),At(a,a.gzhead.extra.length>>8&255)),a.gzhead.hcrc&&(t.adler=H(t.adler,a.pending_buf,a.pending,0)),a.gzindex=0,a.status=69;else if(At(a,0),At(a,0),At(a,0),At(a,0),At(a,0),At(a,9===a.level?2:a.strategy>=ot||a.level<2?4:0),At(a,3),a.status=mt,xt(t),0!==a.pending)return a.last_flush=-1,tt;if(69===a.status){if(a.gzhead.extra){let e=a.pending,i=(65535&a.gzhead.extra.length)-a.gzindex;for(;a.pending+i>a.pending_buf_size;){let n=a.pending_buf_size-a.pending;if(a.pending_buf.set(a.gzhead.extra.subarray(a.gzindex,a.gzindex+n),a.pending),a.pending=a.pending_buf_size,a.gzhead.hcrc&&a.pending>e&&(t.adler=H(t.adler,a.pending_buf,a.pending-e,e)),a.gzindex+=n,xt(t),0!==a.pending)return a.last_flush=-1,tt;e=0,i-=n}let n=new Uint8Array(a.gzhead.extra);a.pending_buf.set(n.subarray(a.gzindex,a.gzindex+i),a.pending),a.pending+=i,a.gzhead.hcrc&&a.pending>e&&(t.adler=H(t.adler,a.pending_buf,a.pending-e,e)),a.gzindex=0}a.status=73}if(73===a.status){if(a.gzhead.name){let e,i=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>i&&(t.adler=H(t.adler,a.pending_buf,a.pending-i,i)),xt(t),0!==a.pending)return a.last_flush=-1,tt;i=0}e=a.gzindex<a.gzhead.name.length?255&a.gzhead.name.charCodeAt(a.gzindex++):0,At(a,e)}while(0!==e);a.gzhead.hcrc&&a.pending>i&&(t.adler=H(t.adler,a.pending_buf,a.pending-i,i)),a.gzindex=0}a.status=91}if(91===a.status){if(a.gzhead.comment){let e,i=a.pending;do{if(a.pending===a.pending_buf_size){if(a.gzhead.hcrc&&a.pending>i&&(t.adler=H(t.adler,a.pending_buf,a.pending-i,i)),xt(t),0!==a.pending)return a.last_flush=-1,tt;i=0}e=a.gzindex<a.gzhead.comment.length?255&a.gzhead.comment.charCodeAt(a.gzindex++):0,At(a,e)}while(0!==e);a.gzhead.hcrc&&a.pending>i&&(t.adler=H(t.adler,a.pending_buf,a.pending-i,i))}a.status=103}if(103===a.status){if(a.gzhead.hcrc){if(a.pending+2>a.pending_buf_size&&(xt(t),0!==a.pending))return a.last_flush=-1,tt;At(a,255&t.adler),At(a,t.adler>>8&255),t.adler=0}if(a.status=mt,xt(t),0!==a.pending)return a.last_flush=-1,tt}if(0!==t.avail_in||0!==a.lookahead||e!==q&&a.status!==bt){let i=0===a.level?St(a,e):a.strategy===ot?((t,e)=>{let a;for(;;){if(0===t.lookahead&&(Ut(t),0===t.lookahead)){if(e===q)return 1;break}if(t.match_length=0,a=X(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,a&&(zt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===V?(zt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(zt(t,!1),0===t.strm.avail_out)?1:2})(a,e):a.strategy===lt?((t,e)=>{let a,i,n,s;const r=t.window;for(;;){if(t.lookahead<=ct){if(Ut(t),t.lookahead<=ct&&e===q)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=t.strstart-1,i=r[n],i===r[++n]&&i===r[++n]&&i===r[++n])){s=t.strstart+ct;do{}while(i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&i===r[++n]&&n<s);t.match_length=ct-(s-n),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(a=X(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(a=X(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),a&&(zt(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===V?(zt(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(zt(t,!1),0===t.strm.avail_out)?1:2})(a,e):It[a.level].func(a,e);if(3!==i&&4!==i||(a.status=bt),1===i||3===i)return 0===t.avail_out&&(a.last_flush=-1),tt;if(2===i&&(e===J?W(a):e!==$&&(Y(a,0,0,!1),e===Q&&(kt(a.head),0===a.lookahead&&(a.strstart=0,a.block_start=0,a.insert=0))),xt(t),0===t.avail_out))return a.last_flush=-1,tt}return e!==V?tt:a.wrap<=0?et:(2===a.wrap?(At(a,255&t.adler),At(a,t.adler>>8&255),At(a,t.adler>>16&255),At(a,t.adler>>24&255),At(a,255&t.total_in),At(a,t.total_in>>8&255),At(a,t.total_in>>16&255),At(a,t.total_in>>24&255)):(Et(a,t.adler>>>16),Et(a,65535&t.adler)),xt(t),a.wrap>0&&(a.wrap=-a.wrap),0!==a.pending?tt:et)},deflateEnd:t=>{if(Lt(t))return at;const e=t.state.status;return t.state=null,e===mt?gt(t,it):tt},deflateSetDictionary:(t,e)=>{let a=e.length;if(Lt(t))return at;const i=t.state,n=i.wrap;if(2===n||1===n&&i.status!==wt||i.lookahead)return at;if(1===n&&(t.adler=C(t.adler,e,a,0)),i.wrap=0,a>=i.w_size){0===n&&(kt(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(e.subarray(a-i.w_size,a),0),e=t,a=i.w_size}const s=t.avail_in,r=t.next_in,o=t.input;for(t.avail_in=a,t.next_in=0,t.input=e,Ut(i);i.lookahead>=3;){let t=i.strstart,e=i.lookahead-2;do{i.ins_h=yt(i,i.ins_h,i.window[t+3-1]),i.prev[t&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=t,t++}while(--e);i.strstart=t,i.lookahead=2,Ut(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=r,t.input=o,t.avail_in=s,i.wrap=n,tt},deflateInfo:"pako deflate (from Nodeca project)"};const Ht=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var jt=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const a=e.shift();if(a){if("object"!=typeof a)throw new TypeError(a+"must be non-object");for(const e in a)Ht(a,e)&&(t[e]=a[e])}}return t},Kt=t=>{let e=0;for(let a=0,i=t.length;a<i;a++)e+=t[a].length;const a=new Uint8Array(e);for(let e=0,i=0,n=t.length;e<n;e++){let n=t[e];a.set(n,i),i+=n.length}return a};let Pt=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Pt=!1}const Yt=new Uint8Array(256);for(let t=0;t<256;t++)Yt[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Yt[254]=Yt[254]=1;var Gt=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,a,i,n,s,r=t.length,o=0;for(n=0;n<r;n++)a=t.charCodeAt(n),55296==(64512&a)&&n+1<r&&(i=t.charCodeAt(n+1),56320==(64512&i)&&(a=65536+(a-55296<<10)+(i-56320),n++)),o+=a<128?1:a<2048?2:a<65536?3:4;for(e=new Uint8Array(o),s=0,n=0;s<o;n++)a=t.charCodeAt(n),55296==(64512&a)&&n+1<r&&(i=t.charCodeAt(n+1),56320==(64512&i)&&(a=65536+(a-55296<<10)+(i-56320),n++)),a<128?e[s++]=a:a<2048?(e[s++]=192|a>>>6,e[s++]=128|63&a):a<65536?(e[s++]=224|a>>>12,e[s++]=128|a>>>6&63,e[s++]=128|63&a):(e[s++]=240|a>>>18,e[s++]=128|a>>>12&63,e[s++]=128|a>>>6&63,e[s++]=128|63&a);return e},Xt=(t,e)=>{const a=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let i,n;const s=new Array(2*a);for(n=0,i=0;i<a;){let e=t[i++];if(e<128){s[n++]=e;continue}let r=Yt[e];if(r>4)s[n++]=65533,i+=r-1;else{for(e&=2===r?31:3===r?15:7;r>1&&i<a;)e=e<<6|63&t[i++],r--;r>1?s[n++]=65533:e<65536?s[n++]=e:(e-=65536,s[n++]=55296|e>>10&1023,s[n++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Pt)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let a="";for(let i=0;i<e;i++)a+=String.fromCharCode(t[i]);return a})(s,n)},Wt=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let a=e-1;for(;a>=0&&128==(192&t[a]);)a--;return a<0||0===a?e:a+Yt[t[a]]>e?a:e};var qt=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Jt=Object.prototype.toString,{Z_NO_FLUSH:Qt,Z_SYNC_FLUSH:Vt,Z_FULL_FLUSH:$t,Z_FINISH:te,Z_OK:ee,Z_STREAM_END:ae,Z_DEFAULT_COMPRESSION:ie,Z_DEFAULT_STRATEGY:ne,Z_DEFLATED:se}=K;function re(t){this.options=jt({level:ie,method:se,chunkSize:16384,windowBits:15,memLevel:8,strategy:ne},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new qt,this.strm.avail_out=0;let a=Mt.deflateInit2(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(a!==ee)throw new Error(j[a]);if(e.header&&Mt.deflateSetHeader(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Gt(e.dictionary):"[object ArrayBuffer]"===Jt.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,a=Mt.deflateSetDictionary(this.strm,t),a!==ee)throw new Error(j[a]);this._dict_set=!0}}function oe(t,e){const a=new re(e);if(a.push(t,!0),a.err)throw a.msg||j[a.err];return a.result}re.prototype.push=function(t,e){const a=this.strm,i=this.options.chunkSize;let n,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?te:Qt,"string"==typeof t?a.input=Gt(t):"[object ArrayBuffer]"===Jt.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;;)if(0===a.avail_out&&(a.output=new Uint8Array(i),a.next_out=0,a.avail_out=i),(s===Vt||s===$t)&&a.avail_out<=6)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else{if(n=Mt.deflate(a,s),n===ae)return a.next_out>0&&this.onData(a.output.subarray(0,a.next_out)),n=Mt.deflateEnd(this.strm),this.onEnd(n),this.ended=!0,n===ee;if(0!==a.avail_out){if(s>0&&a.next_out>0)this.onData(a.output.subarray(0,a.next_out)),a.avail_out=0;else if(0===a.avail_in)break}else this.onData(a.output)}return!0},re.prototype.onData=function(t){this.chunks.push(t)},re.prototype.onEnd=function(t){t===ee&&(this.result=Kt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var le={Deflate:re,deflate:oe,deflateRaw:function(t,e){return(e=e||{}).raw=!0,oe(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,oe(t,e)},constants:K};const he=16209;var de=function(t,e){let a,i,n,s,r,o,l,h,d,_,f,c,u,w,m,b,g,p,k,v,y,x,z,A;const E=t.state;a=t.next_in,z=t.input,i=a+(t.avail_in-5),n=t.next_out,A=t.output,s=n-(e-t.avail_out),r=n+(t.avail_out-257),o=E.dmax,l=E.wsize,h=E.whave,d=E.wnext,_=E.window,f=E.hold,c=E.bits,u=E.lencode,w=E.distcode,m=(1<<E.lenbits)-1,b=(1<<E.distbits)-1;t:do{c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),g=u[f&m];e:for(;;){if(p=g>>>24,f>>>=p,c-=p,p=g>>>16&255,0===p)A[n++]=65535&g;else{if(!(16&p)){if(0==(64&p)){g=u[(65535&g)+(f&(1<<p)-1)];continue e}if(32&p){E.mode=16191;break t}t.msg="invalid literal/length code",E.mode=he;break t}k=65535&g,p&=15,p&&(c<p&&(f+=z[a++]<<c,c+=8),k+=f&(1<<p)-1,f>>>=p,c-=p),c<15&&(f+=z[a++]<<c,c+=8,f+=z[a++]<<c,c+=8),g=w[f&b];a:for(;;){if(p=g>>>24,f>>>=p,c-=p,p=g>>>16&255,!(16&p)){if(0==(64&p)){g=w[(65535&g)+(f&(1<<p)-1)];continue a}t.msg="invalid distance code",E.mode=he;break t}if(v=65535&g,p&=15,c<p&&(f+=z[a++]<<c,c+=8,c<p&&(f+=z[a++]<<c,c+=8)),v+=f&(1<<p)-1,v>o){t.msg="invalid distance too far back",E.mode=he;break t}if(f>>>=p,c-=p,p=n-s,v>p){if(p=v-p,p>h&&E.sane){t.msg="invalid distance too far back",E.mode=he;break t}if(y=0,x=_,0===d){if(y+=l-p,p<k){k-=p;do{A[n++]=_[y++]}while(--p);y=n-v,x=A}}else if(d<p){if(y+=l+d-p,p-=d,p<k){k-=p;do{A[n++]=_[y++]}while(--p);if(y=0,d<k){p=d,k-=p;do{A[n++]=_[y++]}while(--p);y=n-v,x=A}}}else if(y+=d-p,p<k){k-=p;do{A[n++]=_[y++]}while(--p);y=n-v,x=A}for(;k>2;)A[n++]=x[y++],A[n++]=x[y++],A[n++]=x[y++],k-=3;k&&(A[n++]=x[y++],k>1&&(A[n++]=x[y++]))}else{y=n-v;do{A[n++]=A[y++],A[n++]=A[y++],A[n++]=A[y++],k-=3}while(k>2);k&&(A[n++]=A[y++],k>1&&(A[n++]=A[y++]))}break}}break}}while(a<i&&n<r);k=c>>3,a-=k,c-=k<<3,f&=(1<<c)-1,t.next_in=a,t.next_out=n,t.avail_in=a<i?i-a+5:5-(a-i),t.avail_out=n<r?r-n+257:257-(n-r),E.hold=f,E.bits=c};const _e=15,fe=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),ce=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),ue=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),we=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var me=(t,e,a,i,n,s,r,o)=>{const l=o.bits;let h,d,_,f,c,u,w=0,m=0,b=0,g=0,p=0,k=0,v=0,y=0,x=0,z=0,A=null;const E=new Uint16Array(16),R=new Uint16Array(16);let Z,U,S,D=null;for(w=0;w<=_e;w++)E[w]=0;for(m=0;m<i;m++)E[e[a+m]]++;for(p=l,g=_e;g>=1&&0===E[g];g--);if(p>g&&(p=g),0===g)return n[s++]=20971520,n[s++]=20971520,o.bits=1,0;for(b=1;b<g&&0===E[b];b++);for(p<b&&(p=b),y=1,w=1;w<=_e;w++)if(y<<=1,y-=E[w],y<0)return-1;if(y>0&&(0===t||1!==g))return-1;for(R[1]=0,w=1;w<_e;w++)R[w+1]=R[w]+E[w];for(m=0;m<i;m++)0!==e[a+m]&&(r[R[e[a+m]]++]=m);if(0===t?(A=D=r,u=20):1===t?(A=fe,D=ce,u=257):(A=ue,D=we,u=0),z=0,m=0,w=b,c=s,k=p,v=0,_=-1,x=1<<p,f=x-1,1===t&&x>852||2===t&&x>592)return 1;for(;;){Z=w-v,r[m]+1<u?(U=0,S=r[m]):r[m]>=u?(U=D[r[m]-u],S=A[r[m]-u]):(U=96,S=0),h=1<<w-v,d=1<<k,b=d;do{d-=h,n[c+(z>>v)+d]=Z<<24|U<<16|S|0}while(0!==d);for(h=1<<w-1;z&h;)h>>=1;if(0!==h?(z&=h-1,z+=h):z=0,m++,0==--E[w]){if(w===g)break;w=e[a+r[m]]}if(w>p&&(z&f)!==_){for(0===v&&(v=p),c+=b,k=w-v,y=1<<k;k+v<g&&(y-=E[k+v],!(y<=0));)k++,y<<=1;if(x+=1<<k,1===t&&x>852||2===t&&x>592)return 1;_=z&f,n[_]=p<<24|k<<16|c-s|0}}return 0!==z&&(n[c+z]=w-v<<24|64<<16|0),o.bits=p,0};const{Z_FINISH:be,Z_BLOCK:ge,Z_TREES:pe,Z_OK:ke,Z_STREAM_END:ve,Z_NEED_DICT:ye,Z_STREAM_ERROR:xe,Z_DATA_ERROR:ze,Z_MEM_ERROR:Ae,Z_BUF_ERROR:Ee,Z_DEFLATED:Re}=K,Ze=16180,Ue=16190,Se=16191,De=16192,Te=16194,Oe=16199,Ie=16200,Fe=16206,Le=16209,Ne=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function Be(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const Ce=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<Ze||e.mode>16211?1:0},Me=t=>{if(Ce(t))return xe;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=Ze,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,ke},He=t=>{if(Ce(t))return xe;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,Me(t)},je=(t,e)=>{let a;if(Ce(t))return xe;const i=t.state;return e<0?(a=0,e=-e):(a=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?xe:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=a,i.wbits=e,He(t))},Ke=(t,e)=>{if(!t)return xe;const a=new Be;t.state=a,a.strm=t,a.window=null,a.mode=Ze;const i=je(t,e);return i!==ke&&(t.state=null),i};let Pe,Ye,Ge=!0;const Xe=t=>{if(Ge){Pe=new Int32Array(512),Ye=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(me(1,t.lens,0,288,Pe,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;me(2,t.lens,0,32,Ye,0,t.work,{bits:5}),Ge=!1}t.lencode=Pe,t.lenbits=9,t.distcode=Ye,t.distbits=5},We=(t,e,a,i)=>{let n;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),i>=s.wsize?(s.window.set(e.subarray(a-s.wsize,a),0),s.wnext=0,s.whave=s.wsize):(n=s.wsize-s.wnext,n>i&&(n=i),s.window.set(e.subarray(a-i,a-i+n),s.wnext),(i-=n)?(s.window.set(e.subarray(a-i,a),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=n,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=n))),0};var qe={inflateReset:He,inflateReset2:je,inflateResetKeep:Me,inflateInit:t=>Ke(t,15),inflateInit2:Ke,inflate:(t,e)=>{let a,i,n,s,r,o,l,h,d,_,f,c,u,w,m,b,g,p,k,v,y,x,z=0;const A=new Uint8Array(4);let E,R;const Z=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(Ce(t)||!t.output||!t.input&&0!==t.avail_in)return xe;a=t.state,a.mode===Se&&(a.mode=De),r=t.next_out,n=t.output,l=t.avail_out,s=t.next_in,i=t.input,o=t.avail_in,h=a.hold,d=a.bits,_=o,f=l,x=ke;t:for(;;)switch(a.mode){case Ze:if(0===a.wrap){a.mode=De;break}for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(2&a.wrap&&35615===h){0===a.wbits&&(a.wbits=15),a.check=0,A[0]=255&h,A[1]=h>>>8&255,a.check=H(a.check,A,2,0),h=0,d=0,a.mode=16181;break}if(a.head&&(a.head.done=!1),!(1&a.wrap)||(((255&h)<<8)+(h>>8))%31){t.msg="incorrect header check",a.mode=Le;break}if((15&h)!==Re){t.msg="unknown compression method",a.mode=Le;break}if(h>>>=4,d-=4,y=8+(15&h),0===a.wbits&&(a.wbits=y),y>15||y>a.wbits){t.msg="invalid window size",a.mode=Le;break}a.dmax=1<<a.wbits,a.flags=0,t.adler=a.check=1,a.mode=512&h?16189:Se,h=0,d=0;break;case 16181:for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(a.flags=h,(255&a.flags)!==Re){t.msg="unknown compression method",a.mode=Le;break}if(57344&a.flags){t.msg="unknown header flags set",a.mode=Le;break}a.head&&(a.head.text=h>>8&1),512&a.flags&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,a.check=H(a.check,A,2,0)),h=0,d=0,a.mode=16182;case 16182:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.head&&(a.head.time=h),512&a.flags&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,A[2]=h>>>16&255,A[3]=h>>>24&255,a.check=H(a.check,A,4,0)),h=0,d=0,a.mode=16183;case 16183:for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.head&&(a.head.xflags=255&h,a.head.os=h>>8),512&a.flags&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,a.check=H(a.check,A,2,0)),h=0,d=0,a.mode=16184;case 16184:if(1024&a.flags){for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.length=h,a.head&&(a.head.extra_len=h),512&a.flags&&4&a.wrap&&(A[0]=255&h,A[1]=h>>>8&255,a.check=H(a.check,A,2,0)),h=0,d=0}else a.head&&(a.head.extra=null);a.mode=16185;case 16185:if(1024&a.flags&&(c=a.length,c>o&&(c=o),c&&(a.head&&(y=a.head.extra_len-a.length,a.head.extra||(a.head.extra=new Uint8Array(a.head.extra_len)),a.head.extra.set(i.subarray(s,s+c),y)),512&a.flags&&4&a.wrap&&(a.check=H(a.check,i,c,s)),o-=c,s+=c,a.length-=c),a.length))break t;a.length=0,a.mode=16186;case 16186:if(2048&a.flags){if(0===o)break t;c=0;do{y=i[s+c++],a.head&&y&&a.length<65536&&(a.head.name+=String.fromCharCode(y))}while(y&&c<o);if(512&a.flags&&4&a.wrap&&(a.check=H(a.check,i,c,s)),o-=c,s+=c,y)break t}else a.head&&(a.head.name=null);a.length=0,a.mode=16187;case 16187:if(4096&a.flags){if(0===o)break t;c=0;do{y=i[s+c++],a.head&&y&&a.length<65536&&(a.head.comment+=String.fromCharCode(y))}while(y&&c<o);if(512&a.flags&&4&a.wrap&&(a.check=H(a.check,i,c,s)),o-=c,s+=c,y)break t}else a.head&&(a.head.comment=null);a.mode=16188;case 16188:if(512&a.flags){for(;d<16;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(4&a.wrap&&h!==(65535&a.check)){t.msg="header crc mismatch",a.mode=Le;break}h=0,d=0}a.head&&(a.head.hcrc=a.flags>>9&1,a.head.done=!0),t.adler=a.check=0,a.mode=Se;break;case 16189:for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}t.adler=a.check=Ne(h),h=0,d=0,a.mode=Ue;case Ue:if(0===a.havedict)return t.next_out=r,t.avail_out=l,t.next_in=s,t.avail_in=o,a.hold=h,a.bits=d,ye;t.adler=a.check=1,a.mode=Se;case Se:if(e===ge||e===pe)break t;case De:if(a.last){h>>>=7&d,d-=7&d,a.mode=Fe;break}for(;d<3;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}switch(a.last=1&h,h>>>=1,d-=1,3&h){case 0:a.mode=16193;break;case 1:if(Xe(a),a.mode=Oe,e===pe){h>>>=2,d-=2;break t}break;case 2:a.mode=16196;break;case 3:t.msg="invalid block type",a.mode=Le}h>>>=2,d-=2;break;case 16193:for(h>>>=7&d,d-=7&d;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if((65535&h)!=(h>>>16^65535)){t.msg="invalid stored block lengths",a.mode=Le;break}if(a.length=65535&h,h=0,d=0,a.mode=Te,e===pe)break t;case Te:a.mode=16195;case 16195:if(c=a.length,c){if(c>o&&(c=o),c>l&&(c=l),0===c)break t;n.set(i.subarray(s,s+c),r),o-=c,s+=c,l-=c,r+=c,a.length-=c;break}a.mode=Se;break;case 16196:for(;d<14;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(a.nlen=257+(31&h),h>>>=5,d-=5,a.ndist=1+(31&h),h>>>=5,d-=5,a.ncode=4+(15&h),h>>>=4,d-=4,a.nlen>286||a.ndist>30){t.msg="too many length or distance symbols",a.mode=Le;break}a.have=0,a.mode=16197;case 16197:for(;a.have<a.ncode;){for(;d<3;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.lens[Z[a.have++]]=7&h,h>>>=3,d-=3}for(;a.have<19;)a.lens[Z[a.have++]]=0;if(a.lencode=a.lendyn,a.lenbits=7,E={bits:a.lenbits},x=me(0,a.lens,0,19,a.lencode,0,a.work,E),a.lenbits=E.bits,x){t.msg="invalid code lengths set",a.mode=Le;break}a.have=0,a.mode=16198;case 16198:for(;a.have<a.nlen+a.ndist;){for(;z=a.lencode[h&(1<<a.lenbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(g<16)h>>>=m,d-=m,a.lens[a.have++]=g;else{if(16===g){for(R=m+2;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(h>>>=m,d-=m,0===a.have){t.msg="invalid bit length repeat",a.mode=Le;break}y=a.lens[a.have-1],c=3+(3&h),h>>>=2,d-=2}else if(17===g){for(R=m+3;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,y=0,c=3+(7&h),h>>>=3,d-=3}else{for(R=m+7;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=m,d-=m,y=0,c=11+(127&h),h>>>=7,d-=7}if(a.have+c>a.nlen+a.ndist){t.msg="invalid bit length repeat",a.mode=Le;break}for(;c--;)a.lens[a.have++]=y}}if(a.mode===Le)break;if(0===a.lens[256]){t.msg="invalid code -- missing end-of-block",a.mode=Le;break}if(a.lenbits=9,E={bits:a.lenbits},x=me(1,a.lens,0,a.nlen,a.lencode,0,a.work,E),a.lenbits=E.bits,x){t.msg="invalid literal/lengths set",a.mode=Le;break}if(a.distbits=6,a.distcode=a.distdyn,E={bits:a.distbits},x=me(2,a.lens,a.nlen,a.ndist,a.distcode,0,a.work,E),a.distbits=E.bits,x){t.msg="invalid distances set",a.mode=Le;break}if(a.mode=Oe,e===pe)break t;case Oe:a.mode=Ie;case Ie:if(o>=6&&l>=258){t.next_out=r,t.avail_out=l,t.next_in=s,t.avail_in=o,a.hold=h,a.bits=d,de(t,f),r=t.next_out,n=t.output,l=t.avail_out,s=t.next_in,i=t.input,o=t.avail_in,h=a.hold,d=a.bits,a.mode===Se&&(a.back=-1);break}for(a.back=0;z=a.lencode[h&(1<<a.lenbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(b&&0==(240&b)){for(p=m,k=b,v=g;z=a.lencode[v+((h&(1<<p+k)-1)>>p)],m=z>>>24,b=z>>>16&255,g=65535&z,!(p+m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=p,d-=p,a.back+=p}if(h>>>=m,d-=m,a.back+=m,a.length=g,0===b){a.mode=16205;break}if(32&b){a.back=-1,a.mode=Se;break}if(64&b){t.msg="invalid literal/length code",a.mode=Le;break}a.extra=15&b,a.mode=16201;case 16201:if(a.extra){for(R=a.extra;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.length+=h&(1<<a.extra)-1,h>>>=a.extra,d-=a.extra,a.back+=a.extra}a.was=a.length,a.mode=16202;case 16202:for(;z=a.distcode[h&(1<<a.distbits)-1],m=z>>>24,b=z>>>16&255,g=65535&z,!(m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(0==(240&b)){for(p=m,k=b,v=g;z=a.distcode[v+((h&(1<<p+k)-1)>>p)],m=z>>>24,b=z>>>16&255,g=65535&z,!(p+m<=d);){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}h>>>=p,d-=p,a.back+=p}if(h>>>=m,d-=m,a.back+=m,64&b){t.msg="invalid distance code",a.mode=Le;break}a.offset=g,a.extra=15&b,a.mode=16203;case 16203:if(a.extra){for(R=a.extra;d<R;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}a.offset+=h&(1<<a.extra)-1,h>>>=a.extra,d-=a.extra,a.back+=a.extra}if(a.offset>a.dmax){t.msg="invalid distance too far back",a.mode=Le;break}a.mode=16204;case 16204:if(0===l)break t;if(c=f-l,a.offset>c){if(c=a.offset-c,c>a.whave&&a.sane){t.msg="invalid distance too far back",a.mode=Le;break}c>a.wnext?(c-=a.wnext,u=a.wsize-c):u=a.wnext-c,c>a.length&&(c=a.length),w=a.window}else w=n,u=r-a.offset,c=a.length;c>l&&(c=l),l-=c,a.length-=c;do{n[r++]=w[u++]}while(--c);0===a.length&&(a.mode=Ie);break;case 16205:if(0===l)break t;n[r++]=a.length,l--,a.mode=Ie;break;case Fe:if(a.wrap){for(;d<32;){if(0===o)break t;o--,h|=i[s++]<<d,d+=8}if(f-=l,t.total_out+=f,a.total+=f,4&a.wrap&&f&&(t.adler=a.check=a.flags?H(a.check,n,f,r-f):C(a.check,n,f,r-f)),f=l,4&a.wrap&&(a.flags?h:Ne(h))!==a.check){t.msg="incorrect data check",a.mode=Le;break}h=0,d=0}a.mode=16207;case 16207:if(a.wrap&&a.flags){for(;d<32;){if(0===o)break t;o--,h+=i[s++]<<d,d+=8}if(4&a.wrap&&h!==(4294967295&a.total)){t.msg="incorrect length check",a.mode=Le;break}h=0,d=0}a.mode=16208;case 16208:x=ve;break t;case Le:x=ze;break t;case 16210:return Ae;default:return xe}return t.next_out=r,t.avail_out=l,t.next_in=s,t.avail_in=o,a.hold=h,a.bits=d,(a.wsize||f!==t.avail_out&&a.mode<Le&&(a.mode<Fe||e!==be))&&We(t,t.output,t.next_out,f-t.avail_out),_-=t.avail_in,f-=t.avail_out,t.total_in+=_,t.total_out+=f,a.total+=f,4&a.wrap&&f&&(t.adler=a.check=a.flags?H(a.check,n,f,t.next_out-f):C(a.check,n,f,t.next_out-f)),t.data_type=a.bits+(a.last?64:0)+(a.mode===Se?128:0)+(a.mode===Oe||a.mode===Te?256:0),(0===_&&0===f||e===be)&&x===ke&&(x=Ee),x},inflateEnd:t=>{if(Ce(t))return xe;let e=t.state;return e.window&&(e.window=null),t.state=null,ke},inflateGetHeader:(t,e)=>{if(Ce(t))return xe;const a=t.state;return 0==(2&a.wrap)?xe:(a.head=e,e.done=!1,ke)},inflateSetDictionary:(t,e)=>{const a=e.length;let i,n,s;return Ce(t)?xe:(i=t.state,0!==i.wrap&&i.mode!==Ue?xe:i.mode===Ue&&(n=1,n=C(n,e,a,0),n!==i.check)?ze:(s=We(t,e,a,a),s?(i.mode=16210,Ae):(i.havedict=1,ke)))},inflateInfo:"pako inflate (from Nodeca project)"};var Je=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Qe=Object.prototype.toString,{Z_NO_FLUSH:Ve,Z_FINISH:$e,Z_OK:ta,Z_STREAM_END:ea,Z_NEED_DICT:aa,Z_STREAM_ERROR:ia,Z_DATA_ERROR:na,Z_MEM_ERROR:sa}=K;function ra(t){this.options=jt({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new qt,this.strm.avail_out=0;let a=qe.inflateInit2(this.strm,e.windowBits);if(a!==ta)throw new Error(j[a]);if(this.header=new Je,qe.inflateGetHeader(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Gt(e.dictionary):"[object ArrayBuffer]"===Qe.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(a=qe.inflateSetDictionary(this.strm,e.dictionary),a!==ta)))throw new Error(j[a])}function oa(t,e){const a=new ra(e);if(a.push(t),a.err)throw a.msg||j[a.err];return a.result}ra.prototype.push=function(t,e){const a=this.strm,i=this.options.chunkSize,n=this.options.dictionary;let s,r,o;if(this.ended)return!1;for(r=e===~~e?e:!0===e?$e:Ve,"[object ArrayBuffer]"===Qe.call(t)?a.input=new Uint8Array(t):a.input=t,a.next_in=0,a.avail_in=a.input.length;;){for(0===a.avail_out&&(a.output=new Uint8Array(i),a.next_out=0,a.avail_out=i),s=qe.inflate(a,r),s===aa&&n&&(s=qe.inflateSetDictionary(a,n),s===ta?s=qe.inflate(a,r):s===na&&(s=aa));a.avail_in>0&&s===ea&&a.state.wrap>0&&0!==t[a.next_in];)qe.inflateReset(a),s=qe.inflate(a,r);switch(s){case ia:case na:case aa:case sa:return this.onEnd(s),this.ended=!0,!1}if(o=a.avail_out,a.next_out&&(0===a.avail_out||s===ea))if("string"===this.options.to){let t=Wt(a.output,a.next_out),e=a.next_out-t,n=Xt(a.output,t);a.next_out=e,a.avail_out=i-e,e&&a.output.set(a.output.subarray(t,t+e),0),this.onData(n)}else this.onData(a.output.length===a.next_out?a.output:a.output.subarray(0,a.next_out));if(s!==ta||0!==o){if(s===ea)return s=qe.inflateEnd(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===a.avail_in)break}}return!0},ra.prototype.onData=function(t){this.chunks.push(t)},ra.prototype.onEnd=function(t){t===ta&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Kt(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var la={Inflate:ra,inflate:oa,inflateRaw:function(t,e){return(e=e||{}).raw=!0,oa(t,e)},ungzip:oa,constants:K};const{Deflate:ha,deflate:da,deflateRaw:_a,gzip:fa}=le,{Inflate:ca,inflate:ua,inflateRaw:wa,ungzip:ma}=la;var ba=ha,ga=da,pa=_a,ka=fa,va=ca,ya=ua,xa=wa,za=ma,Aa=K,Ea={Deflate:ba,deflate:ga,deflateRaw:pa,gzip:ka,Inflate:va,inflate:ya,inflateRaw:xa,ungzip:za,constants:Aa};t.Deflate=ba,t.Inflate=va,t.constants=Aa,t.default=Ea,t.deflate=ga,t.deflateRaw=pa,t.gzip=ka,t.inflate=ya,t.inflateRaw=xa,t.ungzip=za,Object.defineProperty(t,"__esModule",{value:!0})}));
|
||||
+412
-304
@@ -1,304 +1,412 @@
|
||||
if (typeof Object.assign != 'function') {
|
||||
Object.assign = function () {
|
||||
var target = arguments[0];
|
||||
for (var i = 1; i < arguments.length; i++) {
|
||||
var source = arguments[i];
|
||||
for (var key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
};
|
||||
}
|
||||
function getMubans() {
|
||||
var mubanDict = { // 模板字典
|
||||
mxpro: {
|
||||
title: '',
|
||||
host: '',
|
||||
// homeUrl:'/',
|
||||
url: '/vodshow/fyclass--------fypage---.html',
|
||||
searchUrl: '/vodsearch/**----------fypage---.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {//网站的请求头,完整支持所有的,常带ua和cookies
|
||||
'User-Agent': 'MOBILE_UA',
|
||||
// "Cookie": "searchneed=ok"
|
||||
},
|
||||
class_parse: '.navbar-items li:gt(2):lt(8);a&&Text;a&&href;/(\\d+).html',
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
推荐: '.tab-list.active;a.module-poster-item.module-item;.module-poster-item-title&&Text;.lazyload&&data-original;.module-item-note&&Text;a&&href',
|
||||
double: true, // 推荐内容是否双层定位
|
||||
一级: 'body a.module-poster-item.module-item;a&&title;.lazyload&&data-original;.module-item-note&&Text;a&&href',
|
||||
二级: {
|
||||
"title": "h1&&Text;.module-info-tag&&Text",
|
||||
"img": ".lazyload&&data-original",
|
||||
"desc": ".module-info-item:eq(1)&&Text;.module-info-item:eq(2)&&Text;.module-info-item:eq(3)&&Text",
|
||||
"content": ".module-info-introduction&&Text",
|
||||
"tabs": ".module-tab-item",
|
||||
"lists": ".module-play-list:eq(#id) a"
|
||||
},
|
||||
搜索: 'body .module-item;.module-card-item-title&&Text;.lazyload&&data-original;.module-item-note&&Text;a&&href;.module-info-item-content&&Text',
|
||||
},
|
||||
mxone5: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/show/fyclass--------fypage---.html',
|
||||
searchUrl: '/search/**----------fypage---.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
class_parse: '.nav-menu-items&&li;a&&Text;a&&href;.*/(.*?).html',
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
推荐: '.module-list;.module-items&&.module-item;a&&title;img&&data-src;.module-item-text&&Text;a&&href',
|
||||
double: true, // 推荐内容是否双层定位
|
||||
一级: '.module-items .module-item;a&&title;img&&data-src;.module-item-text&&Text;a&&href',
|
||||
二级: {
|
||||
"title": "h1&&Text;.tag-link&&Text",
|
||||
"img": ".module-item-pic&&img&&data-src",
|
||||
"desc": ".video-info-items:eq(0)&&Text;.video-info-items:eq(1)&&Text;.video-info-items:eq(2)&&Text;.video-info-items:eq(3)&&Text",
|
||||
"content": ".vod_content&&Text",
|
||||
"tabs": ".module-tab-item",
|
||||
"lists": ".module-player-list:eq(#id)&&.scroll-content&&a"
|
||||
},
|
||||
搜索: '.module-items .module-search-item;a&&title;img&&data-src;.video-serial&&Text;a&&href',
|
||||
},
|
||||
首图: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/vodshow/fyclass--------fypage---/',
|
||||
searchUrl: '/vodsearch/**----------fypage---.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {//网站的请求头,完整支持所有的,常带ua和cookies
|
||||
'User-Agent': 'MOBILE_UA',
|
||||
// "Cookie": "searchneed=ok"
|
||||
},
|
||||
class_parse: '.myui-header__menu li.hidden-sm:gt(0):lt(5);a&&Text;a&&href;/(\\d+).html',
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
推荐: 'ul.myui-vodlist.clearfix;li;a&&title;a&&data-original;.pic-text&&Text;a&&href',
|
||||
double: true, // 推荐内容是否双层定位
|
||||
一级: '.myui-vodlist li;a&&title;a&&data-original;.pic-text&&Text;a&&href',
|
||||
二级: {
|
||||
"title": ".myui-content__detail .title&&Text;.myui-content__detail p:eq(-2)&&Text",
|
||||
"img": ".myui-content__thumb .lazyload&&data-original",
|
||||
"desc": ".myui-content__detail p:eq(0)&&Text;.myui-content__detail p:eq(1)&&Text;.myui-content__detail p:eq(2)&&Text",
|
||||
"content": ".content&&Text",
|
||||
"tabs": ".nav-tabs:eq(0) li",
|
||||
"lists": ".myui-content__list:eq(#id) li"
|
||||
},
|
||||
搜索: '#searchList li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text',
|
||||
},
|
||||
首图2: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/list/fyclass-fypage.html',
|
||||
searchUrl: '/vodsearch/**----------fypage---.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {
|
||||
'User-Agent': 'UC_UA',
|
||||
// "Cookie": ""
|
||||
},
|
||||
// class_parse:'.stui-header__menu li:gt(0):lt(7);a&&Text;a&&href;/(\\d+).html',
|
||||
class_parse: '.stui-header__menu li:gt(0):lt(7);a&&Text;a&&href;.*/(.*?).html',
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
推荐: 'ul.stui-vodlist.clearfix;li;a&&title;.lazyload&&data-original;.pic-text&&Text;a&&href',
|
||||
double: true, // 推荐内容是否双层定位
|
||||
一级: '.stui-vodlist li;a&&title;a&&data-original;.pic-text&&Text;a&&href',
|
||||
二级: {
|
||||
"title": ".stui-content__detail .title&&Text;.stui-content__detail p:eq(-2)&&Text",
|
||||
"img": ".stui-content__thumb .lazyload&&data-original",
|
||||
"desc": ".stui-content__detail p:eq(0)&&Text;.stui-content__detail p:eq(1)&&Text;.stui-content__detail p:eq(2)&&Text",
|
||||
"content": ".detail&&Text",
|
||||
"tabs": ".stui-vodlist__head h3",
|
||||
"lists": ".stui-content__playlist:eq(#id) li"
|
||||
},
|
||||
搜索: 'ul.stui-vodlist__media:eq(0) li,ul.stui-vodlist:eq(0) li,#searchList li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text',
|
||||
搜索1: 'ul.stui-vodlist&&li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text',
|
||||
搜索2: 'ul.stui-vodlist__media&&li;a&&title;.lazyload&&data-original;.text-muted&&Text;a&&href;.text-muted:eq(-1)&&Text',
|
||||
},
|
||||
默认: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/vodshow/fyclass--------fypage---.html',
|
||||
searchUrl: '/vodsearch/-------------.html?wd=**',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {
|
||||
'User-Agent': 'MOBILE_UA',
|
||||
},
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
double: true, // 推荐内容是否双层定位
|
||||
},
|
||||
vfed: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/index.php/vod/show/id/fyclass/page/fypage.html',
|
||||
searchUrl: '/index.php/vod/search/page/fypage/wd/**.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {
|
||||
'User-Agent': 'UC_UA',
|
||||
},
|
||||
// class_parse:'.fed-pops-navbar&&ul.fed-part-rows&&a.fed-part-eone:gt(0):lt(5);a&&Text;a&&href;.*/(.*?).html',
|
||||
class_parse: '.fed-pops-navbar&&ul.fed-part-rows&&a;a&&Text;a&&href;.*/(.*?).html',
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
推荐: 'ul.fed-list-info.fed-part-rows;li;a.fed-list-title&&Text;a&&data-original;.fed-list-remarks&&Text;a&&href',
|
||||
double: true, // 推荐内容是否双层定位
|
||||
一级: '.fed-list-info&&li;a.fed-list-title&&Text;a&&data-original;.fed-list-remarks&&Text;a&&href',
|
||||
二级: {
|
||||
"title": "h1.fed-part-eone&&Text;.fed-deta-content&&.fed-part-rows&&li&&Text",
|
||||
"img": ".fed-list-info&&a&&data-original",
|
||||
"desc": ".fed-deta-content&&.fed-part-rows&&li:eq(1)&&Text;.fed-deta-content&&.fed-part-rows&&li:eq(2)&&Text;.fed-deta-content&&.fed-part-rows&&li:eq(3)&&Text",
|
||||
"content": ".fed-part-esan&&Text",
|
||||
"tabs": ".fed-drop-boxs&&.fed-part-rows&&li",
|
||||
"lists": ".fed-play-item:eq(#id)&&ul:eq(1)&&li"
|
||||
},
|
||||
搜索: '.fed-deta-info;h1&&Text;.lazyload&&data-original;.fed-list-remarks&&Text;a&&href;.fed-deta-content&&Text',
|
||||
},
|
||||
海螺3: {
|
||||
title: '',
|
||||
host: '',
|
||||
searchUrl: '/v_search/**----------fypage---.html',
|
||||
url: '/vod_____show/fyclass--------fypage---.html',
|
||||
headers: {
|
||||
'User-Agent': 'MOBILE_UA'
|
||||
},
|
||||
timeout: 5000,
|
||||
class_parse: 'body&&.hl-nav li:gt(0);a&&Text;a&&href;.*/(.*?).html',
|
||||
cate_exclude: '明星|专题|最新|排行',
|
||||
limit: 40,
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
推荐: '.hl-vod-list;li;a&&title;a&&data-original;.remarks&&Text;a&&href',
|
||||
double: true,
|
||||
一级: '.hl-vod-list&&.hl-list-item;a&&title;a&&data-original;.remarks&&Text;a&&href',
|
||||
二级: {
|
||||
"title": ".hl-infos-title&&Text;.hl-text-conch&&Text",
|
||||
"img": ".hl-lazy&&data-original",
|
||||
"desc": ".hl-infos-content&&.hl-text-conch&&Text",
|
||||
"content": ".hl-content-text&&Text",
|
||||
"tabs": ".hl-tabs&&a",
|
||||
"lists": ".hl-plays-list:eq(#id)&&li"
|
||||
},
|
||||
搜索: '.hl-list-item;a&&title;a&&data-original;.remarks&&Text;a&&href',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
},
|
||||
海螺2: {
|
||||
title: '',
|
||||
host: '',
|
||||
searchUrl: '/index.php/vod/search/page/fypage/wd/**/',
|
||||
url: '/index.php/vod/show/id/fyclass/page/fypage/',
|
||||
headers: {
|
||||
'User-Agent': 'MOBILE_UA'
|
||||
},
|
||||
timeout: 5000,
|
||||
class_parse: '#nav-bar li;a&&Text;a&&href;id/(.*?)/',
|
||||
limit: 40,
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
推荐: '.list-a.size;li;a&&title;.lazy&&data-original;.bt&&Text;a&&href',
|
||||
double: true,
|
||||
一级: '.list-a&&li;a&&title;.lazy&&data-original;.list-remarks&&Text;a&&href',
|
||||
二级: {
|
||||
"title": "h2&&Text;.deployment&&Text",
|
||||
"img": ".lazy&&data-original",
|
||||
"desc": ".deployment&&Text",
|
||||
"content": ".ec-show&&Text",
|
||||
"tabs": "#tag&&a",
|
||||
"lists": ".play_list_box:eq(#id)&&li"
|
||||
},
|
||||
搜索: '.search-list;a&&title;.lazy&&data-original;.deployment&&Text;a&&href',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
},
|
||||
短视: {
|
||||
title: '',
|
||||
host: '',
|
||||
// homeUrl:'/',
|
||||
url: '/channel/fyclass-fypage.html',
|
||||
searchUrl: '/search.html?wd=**',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {//网站的请求头,完整支持所有的,常带ua和cookies
|
||||
'User-Agent': 'MOBILE_UA',
|
||||
// "Cookie": "searchneed=ok"
|
||||
},
|
||||
class_parse: '.menu_bottom ul li;a&&Text;a&&href;.*/(.*?).html',
|
||||
cate_exclude: '解析|动态',
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
推荐: '.indexShowBox;ul&&li;a&&title;img&&data-src;.s1&&Text;a&&href',
|
||||
double: true, // 推荐内容是否双层定位
|
||||
一级: '.pic-list&&li;a&&title;img&&data-src;.s1&&Text;a&&href',
|
||||
二级: {
|
||||
"title": "h1&&Text;.content-rt&&p:eq(0)&&Text",
|
||||
"img": ".img&&img&&data-src",
|
||||
"desc": ".content-rt&&p:eq(1)&&Text;.content-rt&&p:eq(2)&&Text;.content-rt&&p:eq(3)&&Text;.content-rt&&p:eq(4)&&Text;.content-rt&&p:eq(5)&&Text",
|
||||
"content": ".zkjj_a&&Text",
|
||||
"tabs": ".py-tabs&&option",
|
||||
"lists": ".player:eq(#id) li"
|
||||
},
|
||||
搜索: '.sr_lists&&ul&&li;h3&&Text;img&&data-src;.int&&p:eq(0)&&Text;a&&href',
|
||||
},
|
||||
短视2:{
|
||||
title: '',
|
||||
host: '',
|
||||
class_name:'电影&电视剧&综艺&动漫',
|
||||
class_url:'1&2&3&4',
|
||||
searchUrl: '/index.php/ajax/suggest?mid=1&wd=**&limit=50',
|
||||
searchable: 2,
|
||||
quickSearch: 0,
|
||||
headers:{'User-Agent':'MOBILE_UA'},
|
||||
url: '/index.php/api/vod#type=fyclass&page=fypage',
|
||||
filterable:0,//是否启用分类筛选,
|
||||
filter_url:'',
|
||||
filter: {},
|
||||
filter_def:{},
|
||||
detailUrl:'/index.php/vod/detail/id/fyid.html',
|
||||
play_parse: true,
|
||||
lazy: '',
|
||||
limit: 6,
|
||||
推荐:'.list-vod.flex .public-list-box;a&&title;.lazy&&data-original;.public-list-prb&&Text;a&&href',
|
||||
一级:'js:let body=input.split("#")[1];let t=Math.round(new Date/1e3).toString();let key=md5("DS"+t+"DCC147D11943AF75");let url=input.split("#")[0];body=body+"&time="+t+"&key="+key;print(body);fetch_params.body=body;let html=post(url,fetch_params);let data=JSON.parse(html);VODS=data.list.map(function(it){it.vod_pic=urljoin2(input.split("/i")[0],it.vod_pic);return it});',
|
||||
二级:{
|
||||
"title":".slide-info-title&&Text;.slide-info:eq(3)--strong&&Text",
|
||||
"img":".detail-pic&&data-original",
|
||||
"desc":".fraction&&Text;.slide-info-remarks:eq(1)&&Text;.slide-info-remarks:eq(2)&&Text;.slide-info:eq(2)--strong&&Text;.slide-info:eq(1)--strong&&Text",
|
||||
"content":"#height_limit&&Text",
|
||||
"tabs":".anthology.wow.fadeInUp.animated&&.swiper-wrapper&&a",
|
||||
"tab_text":".swiper-slide&&Text",
|
||||
"lists":".anthology-list-box:eq(#id) li"
|
||||
},
|
||||
搜索:'json:list;name;pic;;id',
|
||||
}
|
||||
};
|
||||
return JSON.parse(JSON.stringify(mubanDict));
|
||||
}
|
||||
var mubanDict = getMubans();
|
||||
var muban = getMubans();
|
||||
export default {muban,getMubans};
|
||||
if (typeof Object.assign !== 'function') {
|
||||
Object.assign = function () {
|
||||
let target = arguments[0];
|
||||
for (let i = 1; i < arguments.length; i++) {
|
||||
let source = arguments[i];
|
||||
for (let key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
return target;
|
||||
};
|
||||
}
|
||||
|
||||
// 通用免嗅探播放
|
||||
let common_lazy = `js:
|
||||
let html = request(input);
|
||||
let hconf = html.match(/r player_.*?=(.*?)</)[1];
|
||||
let json = JSON5.parse(hconf);
|
||||
let url = json.url;
|
||||
if (json.encrypt == '1') {
|
||||
url = unescape(url);
|
||||
} else if (json.encrypt == '2') {
|
||||
url = unescape(base64Decode(url));
|
||||
}
|
||||
if (/\\.(m3u8|mp4|m4a|mp3)/.test(url)) {
|
||||
input = {
|
||||
parse: 0,
|
||||
jx: 0,
|
||||
url: url,
|
||||
};
|
||||
} else {
|
||||
input;
|
||||
}`;
|
||||
// 默认嗅探播放
|
||||
|
||||
let def_lazy = `js:
|
||||
input = { parse: 1, url: input, js: '' };`;
|
||||
// 采集站播放
|
||||
|
||||
let cj_lazy = `js:
|
||||
if (/\\.(m3u8|mp4)/.test(input)) {
|
||||
input = { parse: 0, url: input };
|
||||
} else {
|
||||
if (rule.parse_url.startsWith('json:')) {
|
||||
let purl = rule.parse_url.replace('json:', '') + input;
|
||||
let html = request(purl);
|
||||
let json = JSON.parse(html);
|
||||
if (json.url) {
|
||||
input = { parse: 0, url: json.url };
|
||||
}
|
||||
} else {
|
||||
input = rule.parse_url + input;
|
||||
}
|
||||
}`;
|
||||
|
||||
function getMubans() {
|
||||
const mubanDict = { // 模板字典
|
||||
mx: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/vodshow/fyclass--------fypage---/',
|
||||
searchUrl: '/vodsearch/**----------fypage---/',
|
||||
class_parse: '.top_nav li;a&&Text;a&&href;.*/(.*?)/',
|
||||
searchable: 2,
|
||||
quickSearch: 0,
|
||||
filterable: 0,
|
||||
headers: {
|
||||
'User-Agent': 'MOBILE_UA',
|
||||
},
|
||||
play_parse: true,
|
||||
lazy: common_lazy,
|
||||
limit: 6,
|
||||
double: true,
|
||||
推荐: '.cbox_list;*;*;*;*;*',
|
||||
一级: 'ul.vodlist li;a&&title;a&&data-original;.pic_text&&Text;a&&href',
|
||||
二级: {
|
||||
title: 'h2&&Text;.content_detail:eq(1)&&li&&a:eq(2)&&Text',
|
||||
img: '.vodlist_thumb&&data-original',
|
||||
desc: '.content_detail:eq(1)&&li:eq(1)&&Text;.content_detail:eq(1)&&li&&a&&Text;.content_detail:eq(1)&&li&&a:eq(1)&&Text;.content_detail:eq(1)&&li:eq(2)&&Text;.content_detail:eq(1)&&li:eq(3)&&Text',
|
||||
content: '.content_desc&&span&&Text',
|
||||
tabs: '.play_source_tab&&a',
|
||||
lists: '.content_playlist:eq(#id) li',
|
||||
},
|
||||
搜索: '*',
|
||||
},
|
||||
mxpro: {
|
||||
title: '',
|
||||
host: '', // homeUrl:'/',
|
||||
url: '/vodshow/fyclass--------fypage---.html',
|
||||
searchUrl: '/vodsearch/**----------fypage---.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {//网站的请求头,完整支持所有的,常带ua和cookies
|
||||
'User-Agent': 'MOBILE_UA', // "Cookie": "searchneed=ok"
|
||||
},
|
||||
class_parse: '.navbar-items li:gt(0):lt(10);a&&Text;a&&href;/(\\d+)',
|
||||
play_parse: true,
|
||||
lazy: common_lazy,
|
||||
limit: 6,
|
||||
double: true, // 推荐内容是否双层定位
|
||||
推荐: '.tab-list.active;a.module-poster-item.module-item;.module-poster-item-title&&Text;.lazyload&&data-original;.module-item-note&&Text;a&&href',
|
||||
一级: 'body a.module-poster-item.module-item;a&&title;.lazyload&&data-original;.module-item-note&&Text;a&&href',
|
||||
二级: {
|
||||
title: 'h1&&Text;.module-info-tag-link:eq(-1)&&Text',
|
||||
img: '.lazyload&&data-original||data-src||src',
|
||||
desc: '.module-info-item:eq(-2)&&Text;.module-info-tag-link&&Text;.module-info-tag-link:eq(1)&&Text;.module-info-item:eq(2)&&Text;.module-info-item:eq(1)&&Text',
|
||||
content: '.module-info-introduction&&Text',
|
||||
tabs: '.module-tab-item',
|
||||
lists: '.module-play-list:eq(#id) a',
|
||||
tab_text: 'div--small&&Text',
|
||||
},
|
||||
搜索: 'body .module-item;.module-card-item-title&&Text;.lazyload&&data-original;.module-item-note&&Text;a&&href;.module-info-item-content&&Text',
|
||||
}, mxone5: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/show/fyclass--------fypage---.html',
|
||||
searchUrl: '/search/**----------fypage---.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
class_parse: '.nav-menu-items&&li;a&&Text;a&&href;.*/(.*?)\.html',
|
||||
play_parse: true,
|
||||
lazy: common_lazy,
|
||||
limit: 6,
|
||||
double: true, // 推荐内容是否双层定位
|
||||
推荐: '.module-list;.module-items&&.module-item;a&&title;img&&data-src;.module-item-text&&Text;a&&href',
|
||||
一级: '.module-items .module-item;a&&title;img&&data-src;.module-item-text&&Text;a&&href',
|
||||
二级: {
|
||||
title: 'h1&&Text;.tag-link&&Text',
|
||||
img: '.module-item-pic&&img&&data-src',
|
||||
desc: '.video-info-items:eq(3)&&Text;.tag-link:eq(2)&&Text;.tag-link:eq(1)&&Text;.video-info-items:eq(1)&&Text;.video-info-items:eq(0)&&Text',
|
||||
content: '.vod_content&&Text',
|
||||
tabs: '.module-tab-item',
|
||||
lists: '.module-player-list:eq(#id)&&.scroll-content&&a',
|
||||
tab_text: 'div--small&&Text',
|
||||
},
|
||||
搜索: '.module-items .module-search-item;a&&title;img&&data-src;.video-serial&&Text;a&&href',
|
||||
}, 首图: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/vodshow/fyclass--------fypage---/',
|
||||
searchUrl: '/vodsearch/**----------fypage---.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {//网站的请求头,完整支持所有的,常带ua和cookies
|
||||
'User-Agent': 'MOBILE_UA', // "Cookie": "searchneed=ok"
|
||||
},
|
||||
class_parse: '.myui-header__menu li.hidden-sm:gt(0):lt(7);a&&Text;a&&href;/(\\d+).html',
|
||||
play_parse: true,
|
||||
lazy: common_lazy,
|
||||
limit: 6,
|
||||
double: true, // 推荐内容是否双层定位
|
||||
推荐: 'ul.myui-vodlist.clearfix;li;a&&title;a&&data-original;.pic-text&&Text;a&&href',
|
||||
一级: '.myui-vodlist li;a&&title;a&&data-original;.pic-text&&Text;a&&href',
|
||||
二级: {
|
||||
title: '.myui-content__detail .title--span&&Text;.myui-content__detail p.data:eq(3)&&Text',
|
||||
img: '.myui-content__thumb .lazyload&&data-original',
|
||||
desc: '.myui-content__detail p.otherbox&&Text;.year&&Text;.myui-content__detail p.data:eq(4)&&Text;.myui-content__detail p.data:eq(2)&&Text;.myui-content__detail p.data:eq(0)&&Text',
|
||||
content: '.content&&Text',
|
||||
tabs: '.myui-panel__head&&li',
|
||||
// tabs: '.nav-tabs&&li',
|
||||
lists: '.myui-content__list:eq(#id) li',
|
||||
},
|
||||
搜索: '#searchList li;a&&title;.lazyload&&data-original;.pic-text&&Text;a&&href;.detail&&Text',
|
||||
}, 首图2: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/list/fyclass-fypage.html',
|
||||
searchUrl: '/vodsearch/**----------fypage---.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {
|
||||
'User-Agent': 'UC_UA', // "Cookie": ""
|
||||
},
|
||||
class_parse: '.stui-header__menu li:gt(0):lt(7);a&&Text;a&&href;.*/(.*?).html',
|
||||
play_parse: true,
|
||||
lazy: common_lazy,
|
||||
limit: 6,
|
||||
double: true, // 推荐内容是否双层定位
|
||||
推荐: 'ul.stui-vodlist.clearfix;li;a&&title;.lazyload&&data-original;.pic-text&&Text;a&&href',
|
||||
一级: '.stui-vodlist li;a&&title;a&&data-original;.pic-text&&Text;a&&href',
|
||||
二级: {
|
||||
title: '.stui-content__detail .title&&Text;.stui-content__detail&&p:eq(-2)&&a&&Text',
|
||||
title1: '.stui-content__detail .title&&Text;.stui-content__detail&&p&&Text',
|
||||
img: '.stui-content__thumb .lazyload&&data-original',
|
||||
desc: '.stui-content__detail p&&Text;.stui-content__detail&&p:eq(-2)&&a:eq(2)&&Text;.stui-content__detail&&p:eq(-2)&&a:eq(1)&&Text;.stui-content__detail p:eq(2)&&Text;.stui-content__detail p:eq(1)&&Text',
|
||||
desc1: '.stui-content__detail p:eq(4)&&Text;;;.stui-content__detail p:eq(1)&&Text',
|
||||
content: '.detail&&Text',
|
||||
tabs: '.stui-pannel__head h3',
|
||||
tabs1: '.stui-vodlist__head h3',
|
||||
lists: '.stui-content__playlist:eq(#id) li',
|
||||
},
|
||||
搜索: 'ul.stui-vodlist__media,ul.stui-vodlist,#searchList li;a&&title;.lazyload&&data-original;.pic-text&&Text;a&&href;.detail&&Text',
|
||||
}, 默认: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '',
|
||||
searchUrl: '',
|
||||
searchable: 2,
|
||||
quickSearch: 0,
|
||||
filterable: 0,
|
||||
filter: '',
|
||||
filter_url: '',
|
||||
filter_def: {},
|
||||
headers: {
|
||||
'User-Agent': 'MOBILE_UA',
|
||||
},
|
||||
timeout: 5000,
|
||||
class_parse: '#side-menu li;a&&Text;a&&href;/(.*?)\.html',
|
||||
cate_exclude: '',
|
||||
play_parse: true,
|
||||
lazy: def_lazy,
|
||||
double: true,
|
||||
推荐: '列表1;列表2;标题;图片;描述;链接;详情',
|
||||
一级: '列表;标题;图片;描述;链接;详情',
|
||||
二级: {
|
||||
title: 'vod_name;vod_type',
|
||||
img: '图片链接',
|
||||
desc: '主要信息;年代;地区;演员;导演',
|
||||
content: '简介',
|
||||
tabs: '',
|
||||
lists: 'xx:eq(#id)&&a',
|
||||
tab_text: 'body&&Text',
|
||||
list_text: 'body&&Text',
|
||||
list_url: 'a&&href',
|
||||
},
|
||||
搜索: '列表;标题;图片;描述;链接;详情',
|
||||
}, vfed: {
|
||||
title: '',
|
||||
host: '',
|
||||
url: '/index.php/vod/show/id/fyclass/page/fypage.html',
|
||||
searchUrl: '/index.php/vod/search/page/fypage/wd/**.html',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {
|
||||
'User-Agent': 'UC_UA',
|
||||
},
|
||||
class_parse: '.fed-pops-navbar&&ul.fed-part-rows&&a;a&&Text;a&&href;.*/(.*?).html',
|
||||
play_parse: true,
|
||||
lazy: common_lazy,
|
||||
limit: 6,
|
||||
double: true, // 推荐内容是否双层定位
|
||||
推荐: 'ul.fed-list-info.fed-part-rows;li;a.fed-list-title&&Text;a&&data-original;.fed-list-remarks&&Text;a&&href',
|
||||
一级: '.fed-list-info&&li;a.fed-list-title&&Text;a&&data-original;.fed-list-remarks&&Text;a&&href',
|
||||
二级: {
|
||||
title: 'h1.fed-part-eone&&Text;.fed-deta-content&&.fed-part-rows&&li&&Text',
|
||||
img: '.fed-list-info&&a&&data-original',
|
||||
desc: '.fed-deta-content&&.fed-part-rows&&li:eq(1)&&Text;.fed-deta-content&&.fed-part-rows&&li:eq(2)&&Text;.fed-deta-content&&.fed-part-rows&&li:eq(3)&&Text',
|
||||
content: '.fed-part-esan&&Text',
|
||||
tabs: '.fed-drop-boxs&&.fed-part-rows&&li',
|
||||
lists: '.fed-play-item:eq(#id)&&ul:eq(1)&&li',
|
||||
},
|
||||
搜索: '.fed-deta-info;h1&&Text;.lazyload&&data-original;.fed-list-remarks&&Text;a&&href;.fed-deta-content&&Text',
|
||||
}, 海螺3: {
|
||||
title: '',
|
||||
host: '',
|
||||
searchUrl: '/v_search/**----------fypage---.html',
|
||||
url: '/vod_____show/fyclass--------fypage---.html',
|
||||
headers: {
|
||||
'User-Agent': 'MOBILE_UA',
|
||||
},
|
||||
timeout: 5000,
|
||||
class_parse: 'body&&.hl-nav li:gt(0);a&&Text;a&&href;.*/(.*?).html',
|
||||
cate_exclude: '明星|专题|最新|排行',
|
||||
limit: 40,
|
||||
play_parse: true,
|
||||
lazy: common_lazy,
|
||||
double: true,
|
||||
推荐: '.hl-vod-list;li;a&&title;a&&data-original;.remarks&&Text;a&&href',
|
||||
一级: '.hl-vod-list&&.hl-list-item;a&&title;a&&data-original;.remarks&&Text;a&&href',
|
||||
二级: {
|
||||
title: '.hl-dc-title&&Text;.hl-dc-content&&li:eq(6)&&Text',
|
||||
img: '.hl-lazy&&data-original',
|
||||
desc: '.hl-dc-content&&li:eq(10)&&Text;.hl-dc-content&&li:eq(4)&&Text;.hl-dc-content&&li:eq(5)&&Text;.hl-dc-content&&li:eq(2)&&Text;.hl-dc-content&&li:eq(3)&&Text',
|
||||
content: '.hl-content-text&&Text',
|
||||
tabs: '.hl-tabs&&a',
|
||||
tab_text: 'a--span&&Text',
|
||||
lists: '.hl-plays-list:eq(#id)&&li',
|
||||
},
|
||||
搜索: '.hl-list-item;a&&title;a&&data-original;.remarks&&Text;a&&href',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
}, 海螺2: {
|
||||
title: '',
|
||||
host: '',
|
||||
searchUrl: '/index.php/vod/search/page/fypage/wd/**/',
|
||||
url: '/index.php/vod/show/id/fyclass/page/fypage/',
|
||||
headers: {
|
||||
'User-Agent': 'MOBILE_UA',
|
||||
},
|
||||
timeout: 5000,
|
||||
class_parse: '#nav-bar li;a&&Text;a&&href;id/(.*?)/',
|
||||
limit: 40,
|
||||
play_parse: true,
|
||||
lazy: common_lazy,
|
||||
double: true,
|
||||
推荐: '.list-a.size;li;a&&title;.lazy&&data-original;.bt&&Text;a&&href',
|
||||
一级: '.list-a&&li;a&&title;.lazy&&data-original;.list-remarks&&Text;a&&href',
|
||||
二级: {
|
||||
title: 'h2&&Text;.deployment&&Text',
|
||||
img: '.lazy&&data-original',
|
||||
desc: '.deployment&&Text',
|
||||
content: '.ec-show&&Text',
|
||||
tabs: '#tag&&a',
|
||||
lists: '.play_list_box:eq(#id)&&li',
|
||||
},
|
||||
搜索: '.search-list;a&&title;.lazy&&data-original;.deployment&&Text;a&&href',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
}, 短视: {
|
||||
title: '',
|
||||
host: '', // homeUrl:'/',
|
||||
url: '/channel/fyclass-fypage.html',
|
||||
searchUrl: '/search.html?wd=**',
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 0,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
headers: {//网站的请求头,完整支持所有的,常带ua和cookies
|
||||
'User-Agent': 'MOBILE_UA', // "Cookie": "searchneed=ok"
|
||||
},
|
||||
class_parse: '.menu_bottom ul li;a&&Text;a&&href;.*/(.*?).html',
|
||||
cate_exclude: '解析|动态',
|
||||
play_parse: true,
|
||||
lazy: common_lazy,
|
||||
limit: 6,
|
||||
double: true, // 推荐内容是否双层定位
|
||||
推荐: '.indexShowBox;ul&&li;a&&title;img&&data-src;.s1&&Text;a&&href',
|
||||
一级: '.pic-list&&li;a&&title;img&&data-src;.s1&&Text;a&&href',
|
||||
二级: {
|
||||
title: 'h1&&Text;.content-rt&&p:eq(0)&&Text',
|
||||
img: '.img&&img&&data-src',
|
||||
desc: '.content-rt&&p:eq(1)&&Text;.content-rt&&p:eq(2)&&Text;.content-rt&&p:eq(3)&&Text;.content-rt&&p:eq(4)&&Text;.content-rt&&p:eq(5)&&Text',
|
||||
content: '.zkjj_a&&Text',
|
||||
tabs: '.py-tabs&&option',
|
||||
lists: '.player:eq(#id) li',
|
||||
},
|
||||
搜索: '.sr_lists&&ul&&li;h3&&Text;img&&data-src;.int&&p:eq(0)&&Text;a&&href',
|
||||
}, 短视2: {
|
||||
title: '',
|
||||
host: '',
|
||||
class_name: '电影&电视剧&综艺&动漫',
|
||||
class_url: '1&2&3&4',
|
||||
searchUrl: '/index.php/ajax/suggest?mid=1&wd=**&limit=50',
|
||||
searchable: 2,
|
||||
quickSearch: 0,
|
||||
headers: {'User-Agent': 'MOBILE_UA'},
|
||||
url: '/index.php/api/vod#type=fyclass&page=fypage',
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
filter_url: '',
|
||||
filter: {},
|
||||
filter_def: {},
|
||||
detailUrl: '/index.php/vod/detail/id/fyid.html',
|
||||
play_parse: true,
|
||||
lazy: common_lazy,
|
||||
limit: 6,
|
||||
推荐: '.list-vod.flex .public-list-box;a&&title;.lazy&&data-original;.public-list-prb&&Text;a&&href',
|
||||
一级: 'js:let body=input.split("#")[1];let t=Math.round(new Date/1e3).toString();let key=md5("DS"+t+"DCC147D11943AF75");let url=input.split("#")[0];body=body+"&time="+t+"&key="+key;print(body);fetch_params.body=body;let html=post(url,fetch_params);let data=JSON.parse(html);VODS=data.list.map(function(it){it.vod_pic=urljoin2(input.split("/i")[0],it.vod_pic);return it});',
|
||||
二级: {
|
||||
title: '.slide-info-title&&Text;.slide-info:eq(2)--strong&&Text',
|
||||
img: '.detail-pic&&data-original',
|
||||
desc: '.slide-info-remarks&&Text;.slide-info-remarks:eq(1)&&Text;.slide-info-remarks:eq(2)&&Text;.slide-info:eq(1)--strong&&Text;.info-parameter&&ul&&li:eq(3)&&Text',
|
||||
content: '#height_limit&&Text',
|
||||
tabs: '.anthology.wow.fadeInUp.animated&&.swiper-wrapper&&a',
|
||||
tab_text: 'a--span&&Text',
|
||||
lists: '.anthology-list-box:eq(#id) li',
|
||||
},
|
||||
搜索: 'json:list;name;pic;;id',
|
||||
}, 采集1: {
|
||||
title: '',
|
||||
host: '',
|
||||
homeTid: '13',
|
||||
homeUrl: '/api.php/provide/vod/?ac=detail&t={{rule.homeTid}}',
|
||||
detailUrl: '/api.php/provide/vod/?ac=detail&ids=fyid',
|
||||
searchUrl: '/api.php/provide/vod/?wd=**&pg=fypage',
|
||||
url: '/api.php/provide/vod/?ac=detail&pg=fypage&t=fyclass',
|
||||
headers: {'User-Agent': 'MOBILE_UA'},
|
||||
timeout: 5000, // class_name: '电影&电视剧&综艺&动漫',
|
||||
// class_url: '1&2&3&4',
|
||||
// class_parse:'js:let html=request(input);input=JSON.parse(html).class;',
|
||||
class_parse: 'json:class;',
|
||||
limit: 20,
|
||||
multi: 1,
|
||||
searchable: 2,//是否启用全局搜索,
|
||||
quickSearch: 1,//是否启用快速搜索,
|
||||
filterable: 0,//是否启用分类筛选,
|
||||
play_parse: true,
|
||||
parse_url: '',
|
||||
lazy: cj_lazy,
|
||||
推荐: '*',
|
||||
一级: 'json:list;vod_name;vod_pic;vod_remarks;vod_id;vod_play_from',
|
||||
二级: `js:
|
||||
let html=request(input);
|
||||
html=JSON.parse(html);
|
||||
let data=html.list;
|
||||
VOD=data[0];`,
|
||||
搜索: '*',
|
||||
},
|
||||
};
|
||||
return JSON.parse(JSON.stringify(mubanDict));
|
||||
}
|
||||
|
||||
var mubanDict = getMubans();
|
||||
var muban = getMubans();
|
||||
export default {muban, getMubans};
|
||||
+5
-130
@@ -1,130 +1,5 @@
|
||||
var rule = {
|
||||
title:'斗鱼直播',
|
||||
host:'https://m.douyu.com',
|
||||
homeUrl:'/api/home/mix',//网站的首页链接,用于分类获取和推荐获取
|
||||
url:'/api/room/list?page=fypage&type=fyfilter',
|
||||
filterable:1,//是否启用分类筛选,
|
||||
filter_url:'{{fl.cateId}}',
|
||||
filter:{
|
||||
"yl":[{"key":"cateId","name":"分类","value":[{"n":"二次元","v":"ecy"},{"n":"一起看","v":"yqk"},{"n":"音乐","v":"music"},{"n":"户外","v":"HW"},{"n":"美食","v":"ms"},{"n":"原创IP","v":"ip"},{"n":"心动派对","v":"xdpd"},{"n":"音遇恋人","v":"yinyu"},{"n":"星秀","v":"xingxiu"},{"n":"心动FM","v":"dtxs"},{"n":"娱乐推荐","v":"yltj"},{"n":"中国地质大学(武汉)","v":"CUGWH"}]}],
|
||||
"PCgame":[{"key":"cateId","name":"分类","value":[{"n":"英雄联盟","v":"LOL"},{"n":"热门游戏","v":"rmyx"},{"n":"穿越火线","v":"CF"},{"n":"重生边缘","v":"CSBYOL"},{"n":"无畏契约","v":"VALORANT"},{"n":"CFHD","v":"CFHD"},{"n":"命运方舟","v":"LostArk"},{"n":"DNF","v":"DNF"},{"n":"DOTA2","v":"DOTA2"},{"n":"使命召唤","v":"COD"},{"n":"炉石传说","v":"How"},{"n":"CS2","v":"CounterStrike"},{"n":"lol云顶之弈","v":"ydzhy"},{"n":"魔兽争霸","v":"mszb"},{"n":"魔兽怀旧服","v":"wowclassic"},{"n":"自走棋","v":"dota2rpg"},{"n":"传奇","v":"cq"},{"n":"跑跑卡丁车","v":"Popkart"},{"n":"网易游戏","v":"wyyx"},{"n":"星际争霸","v":"SC"},{"n":"守望先锋","v":"Overwatch"},{"n":"DOTA","v":"DOTA"},{"n":"魔兽世界","v":"WOW"},{"n":"剑网3","v":"JX3"},{"n":"我的世界","v":"MC"},{"n":"超激斗梦境","v":"cjdmj"},{"n":"冒险岛","v":"mxd"},{"n":"三国杀","v":"sanguosha"},{"n":"梦幻西游","v":"MHXYOL"},{"n":"天涯明月刀","v":"tianya"},{"n":"街头篮球","v":"jtlq"},{"n":"NBA2KOL2","v":"NBA2KOL2"},{"n":"QQ飞车端游","v":"qqfcdy"},{"n":"军事游戏","v":"jsyx"},{"n":"棋牌娱乐","v":"qipai"},{"n":"FC ONLINE","v":"FCOL"},{"n":"热门网游","v":"rmwy"},{"n":"卡拉彼丘","v":"klbq"},{"n":"诛仙世界","v":"zxsj"},{"n":"APEX","v":"APEX"},{"n":"流放之路POE","v":"PathofExile"},{"n":"剑网3缘起","v":"JW3YQ"},{"n":"逆水寒","v":"nsh"},{"n":"风暴英雄","v":"HOTS"},{"n":"逆战","v":"NZ"},{"n":"坦克世界","v":"TKSJ"},{"n":"战舰世界","v":"wfws"},{"n":"反恐精英Online","v":"CS"},{"n":"暗黑破坏神","v":"DIABLO"},{"n":"梦三国2","v":"msg2"},{"n":"传奇世界","v":"cqsj"},{"n":"方舟:生存进化","v":"fzscjh"},{"n":"神武4电脑版","v":"swdnb"},{"n":"群雄逐鹿","v":"qxzl"},{"n":"堡垒之夜","v":"blzy"},{"n":"无限法则","v":"roe"},{"n":"问道电脑版","v":"wddnb"},{"n":"西山居游戏","v":"Seasun"},{"n":"最终幻想14","v":"FF14"},{"n":"战意","v":"WYZY"},{"n":"剑灵","v":"BladeSoul"},{"n":"星际战甲","v":"Warframe"},{"n":"龙之谷","v":"DragonNest"},{"n":"铁甲雄兵","v":"tjxb"},{"n":"古剑奇谭网络版","v":"gjqtwlb"},{"n":"轩辕传奇","v":"XYCQ"},{"n":"神途","v":"shentu"},{"n":"激战2","v":"GuildWars2"},{"n":"高达文化区","v":"gdyxq"},{"n":"忍者村大战2","v":"rzcdz2"},{"n":"RPG网游专区","v":"rpgwyzq"},{"n":"诛仙3","v":"zhuxian3"},{"n":"笑傲江湖OL","v":"xajhol"},{"n":"冒险岛2","v":"MXD2"},{"n":"超击突破","v":"SuperPeople"},{"n":"无尽战区","v":"WJZQ"},{"n":"永恒之塔","v":"AION"},{"n":"竞速游戏","v":"jingsu"},{"n":"FPS综合网游","v":"FPSOL"},{"n":"劲舞团","v":"jwt"},{"n":"天下","v":"tianxai"},{"n":"火箭联盟","v":"hjlm"},{"n":"泡泡堂","v":"ppt"},{"n":"音乐游戏","v":"MG"},{"n":"新倩女幽魂","v":"ONLINE"},{"n":"天谕","v":"tianyu"},{"n":"QQ炫舞","v":"qqxw"},{"n":"大唐无双","v":"dtws"},{"n":"怪物猎人ol","v":"MHol"},{"n":"手工星球","v":"sgxq"},{"n":"热血传奇:本源","v":"rxcqhjsgb"},{"n":"彩虹岛","v":"CHD"},{"n":"御龙在天","v":"YLZT"},{"n":"自由篮球","v":"ZYLQ"},{"n":"洛奇英雄传","v":"LQYXZ"},{"n":"洛奇","v":"LQ"},{"n":"封印者","v":"FYZ"},{"n":"合金弹头","v":"HJDT"},{"n":"新英雄年代","v":"XYXSD"},{"n":"盛趣游戏","v":"SQYX"},{"n":"新热血英豪","v":"XRXYH"},{"n":"沙盒游戏","v":"SHYX"},{"n":"恐鬼症","v":"KGZ"},{"n":"领地人生","v":"LDRS"},{"n":"大话西游2","v":"dhxy2"},{"n":"猎人","v":"lr"},{"n":"热血江湖online","v":"rxjhol"},{"n":"千年3","v":"qn3"},{"n":"逍遥情缘","v":"xyqy"},{"n":"快乐西游","v":"klxy"},{"n":"诺亚传说","v":"nycs"},{"n":"鹿鼎记","v":"ldj"},{"n":"武魂2电脑版","v":"wh2pc"},{"n":"奇迹世界sun","v":"qjsjsun"},{"n":"剑侠世界2电脑版","v":"jxsj2pc"},{"n":"斩魂","v":"zhpc"},{"n":"大唐2","v":"dt2pc"},{"n":"幻想神域电脑版","v":"hxsypc"},{"n":"蜀山:初章","v":"ssczpc"},{"n":"狼人对决网游","v":"lrdjpc"},{"n":"武林群侠传","v":"wlqxzpc"},{"n":"飘流幻境","v":"plhjpc"},{"n":"破天一剑","v":"ptyj"},{"n":"四国军棋","v":"sgjq"},{"n":"新大话西游3","v":"xy3"},{"n":"装甲战争","v":"zjzz"},{"n":"暴雪游戏综合","v":"g_bliz"},{"n":"HypeSquad","v":"HypeSquad"},{"n":"长尾4部虚拟分区","v":"cw4bxnfq"},{"n":"燕云十六声","v":"WHEREWINDSMEET"},{"n":"THE FINALS","v":"THEFINALS"},{"n":"NBA2K Online","v":"NBA2KOL"},{"n":"跑跑卡丁车:漂移","v":"KartRiderDrift"},{"n":"传奇永恒","v":"EternalLegend"},{"n":"盛趣传奇","v":"sqcq"},{"n":"火爆热游","v":"hbry"}]}],
|
||||
"djry":[{"key":"cateId","name":"分类","value":[{"n":"主机游戏","v":"TVgame"},{"n":"刺客信条:英灵殿","v":"AC"},{"n":"马里奥制造","v":"Mario"},{"n":"逃离塔科夫","v":"EFT"},{"n":"命运2","v":"MY2"},{"n":"恐怖游戏","v":"Horror"},{"n":"荒野大镖客","v":"hydbk"},{"n":"灵魂筹码","v":"lhcm"},{"n":"骑马与砍杀","v":"MountAndBlade"},{"n":"只狼","v":"ZL"},{"n":"格斗游戏","v":"FTG"},{"n":"饥荒","v":"DontStarve"},{"n":"全境封锁","v":"qjfs"},{"n":"怀旧游戏","v":"classic"},{"n":"NBA2K","v":"NBA2K"},{"n":"八方旅人","v":"OT"},{"n":"人类一败涂地","v":"Human"},{"n":"环世界","v":"RimWorld"},{"n":"古墓丽影","v":"gmly"},{"n":"鬼泣","v":"DMC"},{"n":"往日不再","v":"WRBZ"},{"n":"仙剑奇侠传","v":"PAL"},{"n":"神秘海域","v":"Uncharted"},{"n":"塞尔达系列","v":"TLoZ"},{"n":"僵尸世界大战","v":"WWZ"},{"n":"足球游戏","v":"zq"},{"n":"橙光","v":"cg"},{"n":"了不起的修仙模拟器","v":"ACS"},{"n":"超级马里奥","v":"SMO"},{"n":"三国志系列","v":"Sangokushi"},{"n":"星际公民","v":"StarCitizen"},{"n":"最终幻想","v":"FF"},{"n":"中土世界:战争之影","v":"MiddleEarth"},{"n":"流放者柯南","v":"Conan"},{"n":"三国群英传","v":"SANGO"},{"n":"无主之地","v":"Bor"},{"n":"辐射","v":"fs"},{"n":"太吾绘卷","v":"twhj"},{"n":"SCUM","v":"Scum"},{"n":"正当防卫","v":"zdfw"},{"n":"以撒的结合","v":"Isaac"},{"n":"文明","v":"CVI"},{"n":"仁王","v":"NIOH"},{"n":"缺氧","v":"ONI"},{"n":"皇牌空战","v":"hpkz"},{"n":"体育游戏","v":"tyyx"},{"n":"海岛大亨","v":"hddh"},{"n":"植物大战僵尸:花园战争系列","v":"PvsZ"},{"n":"蜘蛛侠","v":"Spide"},{"n":"勇者斗恶龙:建造者2","v":"DQB2"},{"n":"遗迹:灰烬重生","v":"Rem"},{"n":"血源","v":"BB"},{"n":"旺达与巨像","v":"SotC"},{"n":"模拟人生","v":"Sims"},{"n":"空洞骑士","v":"HKS"},{"n":"极品飞车","v":"jpfc"},{"n":"胡闹厨房","v":"Overcooked"},{"n":"地铁:离去","v":"ME"},{"n":"生死狙击2","v":"ssjjtwo"},{"n":"三国战纪","v":"sgzj"},{"n":"怀旧FC","v":"edwcy"},{"n":"经典单机","v":"jddj"},{"n":"英雄无敌","v":"HoMM"},{"n":"街机游戏","v":"jjyx"},{"n":"合金装备","v":"MetalGear"},{"n":"红色警戒","v":"hsjj"},{"n":"镜之边缘","v":"MsE"},{"n":"火焰纹章系列","v":"FireEmblem"},{"n":"星露谷物语","v":"Stardew"},{"n":"赛博朋克2077","v":"Cyberpunk"},{"n":"中国式家长","v":"CP"},{"n":"尼尔:机械纪元","v":"NieR"},{"n":"无人深空","v":"NMS"},{"n":"EVOTINCTION","v":"EVOTINCTION"},{"n":"GT赛车7","v":"GT"},{"n":"超级机器人大战","v":"SRW"},{"n":"信长之野望","v":"KOEINOBU"},{"n":"这是我的战争","v":"TWoM"},{"n":"杀戮尖塔","v":"sljt"},{"n":"冰汽时代","v":"Frostpunk"},{"n":"帝国时代","v":"AoEIV"},{"n":"死亡空间","v":"swkj"},{"n":"凯瑟琳Full Body","v":"CFB"},{"n":"足球经理","v":"Football"},{"n":"雨中冒险","v":"RoR"},{"n":"亿万僵尸","v":"Billions"},{"n":"武装突袭","v":"ArmA"},{"n":"石油大亨","v":"Oil"},{"n":"荣耀战魂","v":"Honor"},{"n":"欧洲卡车模拟器","v":"Truck"},{"n":"美国逃亡者","v":"Fugitive"},{"n":"漫漫长夜","v":"mmcy"},{"n":"永恒轮回","v":"Survival"},{"n":"孤岛惊魂","v":"FarCry"},{"n":"都市:天际线","v":"Skylines"},{"n":"盗贼之海","v":"hdzh"},{"n":"Dayz","v":"DayZ"},{"n":"60秒","v":"60S"},{"n":"俄罗斯钓鱼","v":"RF"},{"n":"猎人:荒野的召唤","v":"theHunter"},{"n":"恐怖黎明","v":"GD"},{"n":"看门狗","v":"kmg"},{"n":"真三国无双","v":"DW"},{"n":"泰拉瑞亚","v":"Terraria"},{"n":"UFC","v":"UFC"},{"n":"底特律:变人","v":"Detroit"},{"n":"恶魔城","v":"Castlevania"},{"n":"毁灭战士","v":"Doom"},{"n":"火影忍者:究极忍者风暴","v":"Naruto"},{"n":"无尽地牢","v":"DOTE"},{"n":"坎巴拉太空计划","v":"Kerbal"},{"n":"龙珠:超宇宙","v":"DBX"},{"n":"马里奥赛车","v":"MarioKart"},{"n":"模拟山羊","v":"GoatSim"},{"n":"欧陆风云","v":"EU"},{"n":"乞丐模拟器","v":"HoboToughLife"},{"n":"小偷模拟器","v":"ThiefSimulator"},{"n":"逆转裁判","v":"AceA"},{"n":"超越光速","v":"FTL"},{"n":"植物大战僵尸","v":"PvZ"},{"n":"游戏开发者","v":"GGM"},{"n":"最后的绿洲","v":"LO"},{"n":"大富翁","v":"RichMan"},{"n":"英雄连","v":"yxl"},{"n":"永劫无间","v":"NB"},{"n":"部落与弯刀","v":"BLYWD"},{"n":"森林","v":"Forest"},{"n":"只只大冒险","v":"biped"},{"n":"一起开火车!","v":"Unrailed"},{"n":"主机其他游戏","v":"OG"},{"n":"北境之地","v":"BJZD"},{"n":"temtem","v":"temtem"},{"n":"弹丸论破","v":"dwlp"},{"n":"基佬大乱斗","v":"jldld"},{"n":"僵尸毁灭工程","v":"jshmgc"},{"n":"神力科莎","v":"SLKS"},{"n":"超级兔子人","v":"Bunny"},{"n":"岛屿生存者","v":"Sur"},{"n":"盟军敢死队","v":"COMM"},{"n":"冬日计划","v":"drjh"},{"n":"泰坦陨落","v":"Titanfall"},{"n":"四海兄弟","v":"shxd"},{"n":"创世理想乡","v":"Craftopia"},{"n":"柯娜:精神之桥","v":"Kena"},{"n":"幽灵线:东京","v":"GTO"},{"n":"Solar Ash","v":"Ash"},{"n":"BUGSNAX","v":"BUGSNAX"},{"n":"生化危机4重制版","v":"ResidentEvil"},{"n":"Grounded","v":"Grounded"},{"n":"Superliminal","v":"Superliminal"},{"n":"Omno","v":"Omno"},{"n":"Röki","v":"Roki"},{"n":"Undungeon","v":"Undungeon"},{"n":"糖豆人","v":"FallGuys"},{"n":"渡神纪","v":"Gods"},{"n":"Aeolis Tournament","v":"Aeolis"},{"n":"猛兽派对","v":"Animals"},{"n":"Olija","v":"Olija"},{"n":"Creaks","v":"Creaks"},{"n":"暗影火炬城","v":"FIST"},{"n":"阿尔比恩","v":"Albion"},{"n":"Uragun","v":"Uragun"},{"n":"鬼谷八荒","v":"GGBH"},{"n":"Muse Dash","v":"MuseDash"},{"n":"恐惧之间","v":"Fearsurrounds"},{"n":"孤岛惊魂6","v":"FarCry6"},{"n":"怪物猎人","v":"MonsterHunterRise"},{"n":"黑神话:悟空","v":"BlackMythWuKong"},{"n":"仁王2","v":"Nioh2"},{"n":"三国志14","v":"THREEKINGDOMSXIV"},{"n":"杀手3","v":"Hitman3"},{"n":"双人成行","v":"ittakestwo"},{"n":"Scrapnaut","v":"Scrapnaut"},{"n":"租房达人","v":"TheTenants"},{"n":"狙击手:幽灵战士契约2","v":"SniperContracts2"},{"n":"全面战争","v":"TotalWarWARHAMMER"},{"n":"复体","v":"TheComplex"},{"n":"战争机器:战术小队","v":"GearsTactics"},{"n":"侠之道","v":"PathOfWuxia"},{"n":"海绵宝宝:比奇堡的冒险","v":"BattleforBikini"},{"n":"奇妙探险队2","v":"CuriousExpedition2"},{"n":"刺客信条:奥德赛","v":"Odyssey"},{"n":"星球大战:前线","v":"Battlefront"},{"n":"Moonray","v":"Moonray"},{"n":"灵魂旅人","v":"SpiritFarerlhlr"},{"n":"面容","v":"Visage"},{"n":"破门而入2:北方特遣队","v":"DoorKickers2"},{"n":"俄罗斯方块效应:连接","v":"TetrisEffect"},{"n":"SD高达G世纪:起源","v":"SDGundamG"},{"n":"东方计划:不可思议的幻想乡","v":"TouHou"},{"n":"Fate/EXTELLA","v":"FateEXTELLA"},{"n":"临终:重生试炼","v":"DYINGReborn"},{"n":"虚拟现实乐园","v":"VRWorlds"},{"n":"妖精剑士F","v":"FairyFencerF"},{"n":"苍翼默示录:神观之梦","v":"CentralFiction"},{"n":"晚班","v":"LateShift"},{"n":"子弹风暴","v":"Bulletstorm"},{"n":"巡警","v":"BeatCop"},{"n":"耻辱之日","v":"DayofInfamy"},{"n":"狙击精英4","v":"SniperElite4"},{"n":"三国志13:威力加强版","v":"Sangokushi13"},{"n":"热血物语:地下世界","v":"RiverCityRansom"},{"n":"史诗战争模拟器","v":"BattleSimulator"},{"n":"银河护卫队","v":"Guardians"},{"n":"闪乱神乐:少女们的选择","v":"SenranKagura"},{"n":"幽灵行动:荒野","v":"GhostReconWildland"},{"n":"白色情人节","v":"WhiteDay"},{"n":"美国职业摔角联盟2K17","v":"WWE2K"},{"n":"誓死坚守","v":"UntilWeDie"},{"n":"喷射侠","v":"Splasher"},{"n":"双截龙4","v":"DoubleDragon4"},{"n":"地下蚁国","v":"Undergrowth"},{"n":"九张羊皮纸","v":"NineParchments"},{"n":"咒语力量3","v":"Spellforce3"},{"n":"小兵大战","v":"Warpips"},{"n":"维京人 人中之狼","v":"VikingsWofM"},{"n":"你好邻居","v":"Helloneighbor"},{"n":"寻找天堂","v":"findparadise"},{"n":"画中世界","v":"Gorogoa"},{"n":"桥梁工程师传送门","v":"bridgecons"},{"n":"现代战争","v":"ModernCombat"},{"n":"SCP:秘密实验室","v":"scpsl"},{"n":"绯红结系","v":"SCARLETNEXUS"},{"n":"罪恶装备:STRIVE","v":"GuiltyGear"},{"n":"骑士精神2","v":"Chivalry2"},{"n":"Rune Knights","v":"RuneKnights"},{"n":"最后的咒语","v":"TheLastSpell"},{"n":"红至日2:幸存者","v":"TheRed2"},{"n":"真女神转生3","v":"ShinMegami3"},{"n":"速降王者","v":"Descenders"},{"n":"工业崛起","v":"RiseIndustry"},{"n":"征服的荣耀:围城","v":"SIEGE"},{"n":"前往中世纪","v":"GoMedieval"},{"n":"Arid","v":"Arid"},{"n":"伊始之地","v":"TerraNil"},{"n":"进击的巨人2","v":"AttackonTitan2"},{"n":"航海日记2","v":"hhrj2"},{"n":"隐龙传:影踪","v":"HiddenDragon"},{"n":"魔域之书","v":"Bookofdevil"},{"n":"诸神灰烬:救赎","v":"AshofGods"},{"n":"自由人:游击战争","v":"Freeman"},{"n":"战国无双5","v":"SWarriors5"},{"n":"死亡教堂","v":"DeathCathedral"},{"n":"灵魂能力6","v":"SoulCalibur6"},{"n":"不要喂食猴子","v":"NotFeedMonkeys"},{"n":"古剑奇谭3","v":"GuJianqitan3"},{"n":"迷城重生","v":"RebornCity"},{"n":"剑士","v":"KenshiJS"},{"n":"GRIS","v":"GRIS"},{"n":"古剑奇谭:永夜","v":"gujianyongye"},{"n":"核爆RPG","v":"ATOMRPG"},{"n":"Below","v":"Below"},{"n":"嗜血印","v":"BloodySpell"},{"n":"伊苏9","v":"Ys9"},{"n":"兽人必须死3","v":"OrcsDie3"},{"n":"狙击精英VR","v":"SniperEliteVR"},{"n":"遗忘之城","v":"ForgotCity"},{"n":"Last Stop","v":"LastStop"},{"n":"从军","v":"jointhearmy"},{"n":"石炉","v":"Stonehearth"},{"n":"狂热运输2","v":"TransportFever2"},{"n":"机甲战士5","v":"MechWarrior5"},{"n":"分手装修","v":"ToolUP"},{"n":"PICO PARK","v":"PICOPARK"},{"n":"光明记忆:无限","v":"Brightmemory"},{"n":"秘馆疑踪","v":"HeavenDust"},{"n":"英雄传说:创之轨迹","v":"HajimariNOKiseki"},{"n":"战地系列","v":"Battlefiel"},{"n":"塞尔达传说:天空之剑HD","v":"SkywardSword"},{"n":"国王的恩赐2","v":"KingsBounty2"},{"n":"脑航员2","v":"Psychonauts2"},{"n":"九十六号公路","v":"Road96"},{"n":"FORECLOSED","v":"FORECLOSED"},{"n":"RiMS Racing","v":"RiMSRacing"},{"n":"漫威银河护卫队","v":"GuardiansGalaxy"},{"n":"剑侠图","v":"JianXiaTu"},{"n":"审判之逝","v":"Lostjudgment"},{"n":"艾尔登法环","v":"ELDENRING"},{"n":"互动派对","v":"INTERACTIVEPARTY"},{"n":"极限竞速:地平线5","v":"ForzaHorizon5"},{"n":"使命召唤系列","v":"CALLOFDUTYCOD"},{"n":"网吧模拟器","v":"InternetCS"},{"n":"The Anacrusis","v":"TheAnacrusis"},{"n":"文字游戏","v":"WordGame"},{"n":"消逝的光芒2","v":"DyingLight2"},{"n":"战神:诸神黄昏","v":"GodofWarRagnarok"},{"n":"师父","v":"SIFU"},{"n":"海上狼人杀","v":"DreadHunger"},{"n":"最终幻想:起源","v":"STRANGEROFPARADISE"},{"n":"HordeCore","v":"HordeCore"},{"n":"Indies’ Lies","v":"IndiesLies"},{"n":"霍格沃茨之遗","v":"HogwartsLegacy"},{"n":"太荒初境","v":"TalesofWild"},{"n":"Deck of Ashes","v":"DeckofAshes"},{"n":"星空","v":"Starfield"},{"n":"隐秘的角落","v":"YinMiDeJiaoLuo"},{"n":"江湖客栈","v":"TheJianghu"},{"n":"Ilysia","v":"Ilysia"},{"n":"Project Q","v":"ProjectQ"},{"n":"Pummel Party","v":"PummelParty"},{"n":"Holomento","v":"Holomento"},{"n":"Overprime","v":"Overprime"},{"n":"森林之子","v":"SonsOfTheForest"},{"n":"弈仙牌","v":"yixianpai"},{"n":"夜族崛起","v":"VRising"},{"n":"漫威SNAP","v":"MarvelSnap"},{"n":"魔力宝贝","v":"CrossGate"},{"n":"木卫四协议","v":"CallistoProtocol"},{"n":"罗马复兴","v":"RomanRenaissance"},{"n":"风暴之门","v":"StormGate"},{"n":"暗邪西部","v":"EvilWest"},{"n":"堕落之主","v":"LordsofFallen"},{"n":"High on Life","v":"HighonLife"},{"n":"匹诺曹的谎言","v":"LiesofP"},{"n":"逃生:试炼","v":"TheOutlastTrials"},{"n":"战锤40K:暗潮","v":"40KDarktide"},{"n":"Isonzo","v":"Isonzo"},{"n":"索尼克 未知边境","v":"SonicFrontiers"},{"n":"漂泊牧歌","v":"WanderingVillage"},{"n":"塞尔达传说:王国之泪","v":"TEARSKINGDOM"},{"n":"破碎线","v":"Shatterline"},{"n":"卧龙:苍天陨落","v":"Wolong"},{"n":"卡库远古封印","v":"KAKU"},{"n":"原子之心","v":"AtomicHeart"},{"n":"霓虹入侵者","v":"FromSpace"},{"n":"Warhaven","v":"Warhaven"},{"n":"宝可梦:朱/紫","v":"ScarletandViolet"},{"n":"第一后裔","v":"TheFirstDescendant"},{"n":"铳墓G.O.R.E.","v":"GUNGRAVEGORE"},{"n":"Kingshunt","v":"Kingshunt"},{"n":"漫威暗夜之子","v":"MarvelMidnightSuns"},{"n":"奇怪的RPG","v":"WeirdRPG"},{"n":"Evercore Heroes","v":"EvercoreHeroes"},{"n":"东方:平野孤鸿","v":"MomentinEast"},{"n":"神之天平","v":"ASTLIBRARevision"},{"n":"伊克西翁","v":"IXION"},{"n":"主机一起看","v":"zjyqk"},{"n":"社交互动游戏","v":"SJHDYX"},{"n":"Divine Knockout","v":"DivineKnockout"},{"n":"巫师系列","v":"TheWitcher"},{"n":"至暗时刻","v":"DarkandDarker"},{"n":"江湖十一","v":"Jianghu11"},{"n":"XDefiant","v":"XDefiant"},{"n":"刺客信条:幻景","v":"ACMirage"},{"n":"Warlander","v":"Warlander"},{"n":"狂野之心","v":"WildHearts"},{"n":"Scars Above","v":"ScarsAbove"},{"n":"Pacific Drive","v":"PacificDrive"},{"n":"收获日3","v":"PAYDAY"},{"n":"浮生箓2:九九行歌","v":"FloatingLife"},{"n":"The Front","v":"TheFront"},{"n":"最终幻想16","v":"FinalFantasyXVI"},{"n":"街头霸王","v":"StreetFighter"},{"n":"Tchia","v":"Tchia"},{"n":"魔戒:咕噜","v":"Gollum"},{"n":"Prison Life 2","v":"PrisonLife"},{"n":"Innchanted","v":"Innchanted"},{"n":"Life by You","v":"LifebyYou"},{"n":"Eresys","v":"Eresys"},{"n":"Pax Dei","v":"PaxDei"},{"n":"Teravit","v":"Teravit"},{"n":"Caliber","v":"Caliber"},{"n":"沙盒与副本:英勇之地","v":"HerosLand"},{"n":"Coridden","v":"Coridden"},{"n":"Unrecord","v":"Unrecord"},{"n":"Deducto 2","v":"Deducto2"},{"n":"装甲核心6:境界天火","v":"ArmoredCore"},{"n":"Wayfinder","v":"Wayfinder"},{"n":"迷瘴纪事","v":"MiasmaChronicles"},{"n":"Minigame Madness","v":"MinigameMadness"},{"n":"Only Up","v":"onlyup"},{"n":"天文世界","v":"AstroWorld"},{"n":"学园构想家","v":"SchoolHomeroom"},{"n":"Jusant","v":"JUSANT"},{"n":"潜水员戴夫","v":"DAVETHEDIVER"},{"n":"GYLT","v":"GYLT"},{"n":"遗迹2","v":"RemnantII"},{"n":"索利斯堡","v":"FortSolis"},{"n":"Towerborne","v":"Towerborne"},{"n":"33 Immortals","v":"33Immortals"},{"n":"Wildmender","v":"Wildmender"},{"n":"How 2 Escape","v":"How2Escape"},{"n":"漫威蜘蛛侠2","v":"MarvelSpiderman2"},{"n":"博德之门3","v":"BG3"},{"n":"Eternights","v":"Eternights"},{"n":"Project F","v":"ProjectF"},{"n":"BaldMan Climbs Up","v":"BaldManClimbsUp"},{"n":"FC24","v":"FC24"},{"n":"NBA 2K24","v":"NBA2K24"},{"n":"超级马里奥兄弟:惊奇","v":"MarioWonder"},{"n":"蛮荒志异","v":"Taleswild"}]}],
|
||||
"syxx":[{"key":"cateId","name":"分类","value":[{"n":"王者荣耀","v":"wzry"},{"n":"LOL手游","v":"LOLM"},{"n":"崩坏:星穹铁道","v":"bhxqtd"},{"n":"逆水寒手游","v":"NSHM"},{"n":"和平精英","v":"hpjy"},{"n":"暗区突围","v":"aqtw"},{"n":"蛋仔派对","v":"dzpd"},{"n":"高能英雄","v":"gnyx"},{"n":"幻塔","v":"ht"},{"n":"火影忍者","v":"hyrz"},{"n":"COD手游","v":"smzhsy"},{"n":"lol电竞经理","v":"EGAME"},{"n":"DNF手游","v":"mdnf"},{"n":"金铲铲之战","v":"JGAME"},{"n":"天刀手游","v":"tdsy"},{"n":"原神","v":"yuanshen"},{"n":"航海王热血航线","v":"HHWRXHX"},{"n":"元梦之星","v":"YMZX"},{"n":"鸿图之下","v":"htzx"},{"n":"欢乐麻将","v":"HLMJ"},{"n":"王者模拟战","v":"wzrpg"},{"n":"中国象棋","v":"ZGXQ"},{"n":"天谕手游","v":"tysy"},{"n":"巅峰坦克","v":"DFTK"},{"n":"新游中心","v":"xyzx"},{"n":"热门手游","v":"phone"},{"n":"梦幻手游","v":"mhxy"},{"n":"QQ飞车","v":"qqfcsy"},{"n":"第五人格","v":"dwrg"},{"n":"欢乐斗地主","v":"hlddz"},{"n":"荒野乱斗","v":"hyld"},{"n":"阴阳师","v":"yys"},{"n":"狼人杀","v":"LRS"},{"n":"JJ斗地主","v":"jj"},{"n":"梦幻新诛仙","v":"mhxzx"},{"n":"多多自走棋","v":"zzq"},{"n":"崩坏3","v":"bhxl"},{"n":"风云岛行动","v":"fydxd"},{"n":"云游戏","v":"cloudgame"},{"n":"跑跑手游","v":"PPKDCSY"},{"n":"率土之滨","v":"stzb"},{"n":"灌篮高手","v":"glgs"},{"n":"皇室战争","v":"hszz"},{"n":"忍者必须死3","v":"rzbxs3"},{"n":"神武4手游","v":"sw3"},{"n":"梦幻模拟战","v":"mhmnz"},{"n":"实况足球","v":"skzq"},{"n":"航海王:燃烧意志","v":"hhwrsyz"},{"n":"球球大作战","v":"qqdzz"},{"n":"英雄杀","v":"yxs"},{"n":"魔域口袋版","v":"mykdb"},{"n":"口袋新旅程","v":"KDXLC"},{"n":"剑网3:指尖江湖","v":"jw3zjjh"},{"n":"部落冲突","v":"blct"},{"n":"剑与家园","v":"jyjy"},{"n":"新笑傲江湖","v":"xxajh"},{"n":"猫和老鼠","v":"mhls"},{"n":"猎人手游","v":"lrlr"},{"n":"明日之后","v":"mrzh"},{"n":"影之诗","v":"yzs"},{"n":"决战平安京","v":"jzpaj"},{"n":"魂斗罗归来","v":"DLHGL"},{"n":"圣斗士星矢","v":"sdsxs"},{"n":"魔力宝贝手游","v":"mlbbsy"},{"n":"哈利波特:魔法觉醒","v":"HarryPotter"},{"n":"手游推广","v":"rmsy"},{"n":"魔灵召唤","v":"mlzh"},{"n":"香肠派对","v":"xcpd"},{"n":"迷你世界","v":"MNSJ"},{"n":"FC足球世界","v":"FCZQSJ"},{"n":"街篮","v":"jl"},{"n":"明日方舟","v":"mrfz"},{"n":"一梦江湖","v":"ymjh"},{"n":"完美世界手游","v":"wmsjsy"},{"n":"拳皇98OL","v":"kof98"},{"n":"赛尔号","v":"srh"},{"n":"仙境传说","v":"xjcs"},{"n":"流星群侠传","v":"liuxinghudiejian"},{"n":"逃跑吧少年","v":"tpbsn"},{"n":"石器时代","v":"sqsd"},{"n":"RPG手游","v":"rpgsy"},{"n":"英魂之刃口袋版","v":"yh"},{"n":"倩女幽魂手游","v":"qnyhsy"},{"n":"决斗之城2","v":"jdzc2"},{"n":"传奇手游","v":"cqsy"},{"n":"雀魂","v":"Majsoul"},{"n":"二次元手游","v":"ecysy"},{"n":"征途2手游","v":"zt2sy"},{"n":"万王之王3D","v":"wwzw3D"},{"n":"武林外传","v":"wlwz"},{"n":"潮人篮球","v":"crlq"},{"n":"元气骑士","v":"yuanqiqishi"},{"n":"红警OL手游","v":"hjolsy"},{"n":"植物大战僵尸手游","v":"ZWDZJS"},{"n":"创造与魔法","v":"ccymf"},{"n":"奇迹觉醒","v":"qjjx"},{"n":"光遇","v":"skygy"},{"n":"游戏王:决斗链接","v":"yxwjdlj"},{"n":"巅峰战舰","v":"dfzj"},{"n":"寻仙","v":"xunxian"},{"n":"天天象棋","v":"ttxq"},{"n":"王国纪元","v":"wgjy"},{"n":"龙族幻想","v":"lzhx"},{"n":"三国杀移动版","v":"SGSSY"},{"n":"罗布乐思","v":"Roblox"},{"n":"足球手游","v":"zqsy"},{"n":"月圆之夜","v":"yyzy"},{"n":"秦时明月世界","v":"qsmysj"},{"n":"麻将来了","v":"mjll"},{"n":"风之大陆","v":"fzdl"},{"n":"金属对决","v":"jsdj"},{"n":"轩辕剑龙舞云山","v":"xyjlwys"},{"n":"微乐棋牌","v":"WLQP"},{"n":"辐射:避难所Online","v":"fsbnsonline"},{"n":"街篮2","v":"jl2"},{"n":"极光计划","v":"jgjh"},{"n":"不良人3","v":"blr3"},{"n":"镇魔曲手游","v":"zmq"},{"n":"乱世王者","v":"lswz"},{"n":"篮球手游","v":"lqsy"},{"n":"鬼泣-巅峰之战","v":"gqdfzz"},{"n":"射击类手游","v":"qtsy"},{"n":"命运歌姬","v":"mygj"},{"n":"暗黑不朽","v":"diabloimmortal"},{"n":"新神魔大陆","v":"xsmdl"},{"n":"三国志战略版","v":"sgzzlb"},{"n":"天地劫:幽城再临","v":"tdj"},{"n":"Disorder","v":"Disorder"},{"n":"云上城之歌","v":"ysczg"},{"n":"五子棋","v":"wzq"},{"n":"围棋","v":"wq"},{"n":"全球行动","v":"qqxd"},{"n":"诛仙手游","v":"zxsy"},{"n":"妄想山海","v":"wxsh"},{"n":"黎明觉醒:生机","v":"lmjx"},{"n":"庆余年","v":"QYN"},{"n":"我的侠客","v":"wdxk"},{"n":"曙光英雄","v":"sgyx"},{"n":"大话西游手游","v":"dhxysy"},{"n":"战争怒吼","v":"zznh"},{"n":"忘川风华录","v":"wcfhl"},{"n":"新剑侠情缘手游","v":"xjxqysy"},{"n":"重生细胞","v":"csxb"},{"n":"汉家江湖","v":"HJJH"},{"n":"海岛奇兵","v":"hdqb"},{"n":"钢铁力量2","v":"gtll2"},{"n":"仙剑奇侠传九野","v":"xjqxzjy"},{"n":"大唐无双手游","v":"dtwssy"},{"n":"地铁跑酷","v":"dtpk"},{"n":"战舰世界闪击战","v":"zjsjsjz"},{"n":"狂暴之翼","v":"kbzy"},{"n":"横扫千军","v":"hsqj"},{"n":"节奏大爆炸","v":"jzdbz"},{"n":"喵斯快跑","v":"mskp"},{"n":"双子","v":"sz"},{"n":"小美斗地主","v":"xmddz"},{"n":"精灵之境","v":"jlzj"},{"n":"斗罗大陆:武魂觉醒","v":"dldlwhjx"},{"n":"斗罗大陆2绝世唐门","v":"dldl2jstm"},{"n":"战神觉醒","v":"zsjx"},{"n":"九州仙剑传H5","v":"jzxjzh5"},{"n":"荣耀大天使","v":"rydts"},{"n":"蓝月传奇","v":"lycq"},{"n":"凡人修仙传挂机版H5","v":"frxxzgjbh5"},{"n":"攻城掠地","v":"gcld"},{"n":"盗墓笔记","v":"dmbj"},{"n":"拳魂觉醒","v":"qhjx"},{"n":"大天使之剑","v":"dtszj"},{"n":"绝世仙王","v":"jsxw"},{"n":"一刀传世","v":"ydcs"},{"n":"斗罗大陆","v":"dldl"},{"n":"破雪刃","v":"pxr"},{"n":"JJ象棋","v":"jjxq"},{"n":"天姬变","v":"tjb"},{"n":"剑玲珑","v":"jll"},{"n":"火线精英","v":"hxjy"},{"n":"造梦西游OL","v":"zmxyol"},{"n":"奥奇传说手游","v":"aqcssy"},{"n":"战斗吧龙魂","v":"zdblh"},{"n":"剑开仙门","v":"jkxm"},{"n":"狼人对决","v":"lrdj"},{"n":"最终幻想:勇气启示录 幻影战争","v":"hyzz"},{"n":"葫芦娃兄弟","v":"hlwxd"},{"n":"造梦西游4","v":"zmxy4"},{"n":"比特小队","v":"btxd"},{"n":"流言侦探","v":"lyzt"},{"n":"战舰联盟","v":"zjlm"},{"n":"另一个伊甸:超越时空的猫","v":"lygyd"},{"n":"少女前线","v":"snqx"},{"n":"遇见","v":"yj"},{"n":"霓虹深渊:无限","v":"nhsywx"},{"n":"胡莱三国3","v":"hlsg3"},{"n":"奥拉星","v":"alx"},{"n":"先游云游戏","v":"Gamer"},{"n":"万象物语手游","v":"wxwy1"},{"n":"绿茵信仰","v":"lyxy"},{"n":"烟雨江湖","v":"yyjhsy"},{"n":"球球联盟","v":"qqlm"},{"n":"文明与征服","v":"wmyzf"},{"n":"碧蓝航线手游","v":"blhxsy"},{"n":"300大作战","v":"300dzz"},{"n":"2047","v":"2047"},{"n":"第七史诗","v":"dqss"},{"n":"汉末霸业","v":"hmby"},{"n":"EVE星战前夜:无烬星河","v":"evexzqywjxh"},{"n":"少女前线2:追放","v":"sq2zf"},{"n":"弹力果冻","v":"tlgd"},{"n":"火力苏打(T3)","v":"T3"},{"n":"植物大战僵尸2","v":"zwdzjs2"},{"n":"球球英雄","v":"qqyx"},{"n":"悠长假期","v":"ycjq"},{"n":"无悔华夏","v":"whrhx"},{"n":"猫之城","v":"mzc"},{"n":"未定事件簿","v":"wdsjp"},{"n":"白夜极光","v":"byjg"},{"n":"ProjectGAIA","v":"projectgaia"},{"n":"斗罗大陆:魂师对决","v":"dldlhsdj"},{"n":"古墓丽影传说:迷踪","v":"gmlycsmz"},{"n":"漫威对决","v":"mwdj"},{"n":"放置与召唤","v":"fzyzh"},{"n":"我是航海家","v":"wshhj"},{"n":"军团战棋英雄时代","v":"jtzqyxsd"},{"n":"繁荣美食市场物语","v":"frmsscwy"},{"n":"老农种树","v":"lnzs"},{"n":"三国演义:吞噬无界","v":"sgyytswj"},{"n":"偶像梦幻祭2","v":"oxmhj2"},{"n":"卡卡保皇","v":"kkbh"},{"n":"灵猫传","v":"lmz"},{"n":"剑侠世界3","v":"jxsj3"},{"n":"召唤与合成2","v":"zhyhc2"},{"n":"像素时代","v":"xssd"},{"n":"仙侠第一放置","v":"xxdyfz"},{"n":"无尽的拉格朗日","v":"wjdlglr"},{"n":"弓箭手大作战","v":"gjsdzz"},{"n":"挨饿荒野","v":"aehy"},{"n":"诺亚之心","v":"nyzx"},{"n":"闪耀暖暖","v":"synn"},{"n":"物种起源","v":"wzqy"},{"n":"模拟城市:我是市长","v":"mncswssc"},{"n":"重返帝国","v":"cfdg"},{"n":"太古仙尊","v":"tgxz"},{"n":"长安幻想","v":"cahx"},{"n":"火炬之光:无限","v":"hjzgwx"},{"n":"富豪闯三国","v":"fhcsg"},{"n":"拂晓","v":"fx"},{"n":"古剑奇谭木语人","v":"gjqtmyr"},{"n":"火影忍者:忍者新世代","v":"hyrzrzxsd"},{"n":"末日远征","v":"mryz"},{"n":"滚动的天空","v":"gddtk"},{"n":"新斗罗大陆","v":"xdldl"},{"n":"登山赛车","v":"dssc"},{"n":"荒野乱斗(腾讯版)","v":"hyldtxb"},{"n":"小小勇者","v":"xxyz"},{"n":"小冰冰传奇","v":"xbbcq"},{"n":"三国战纪2手游","v":"sgzj2"},{"n":"幸存者危城","v":"xczwc"},{"n":"冒险公社手游","v":"mxgs"},{"n":"欧陆战争5:帝国","v":"olzz5dg"},{"n":"纪念碑谷2","v":"jnbg2"},{"n":"大航海探险物语","v":"dhhtxwy"},{"n":"航海日记","v":"hhrj"},{"n":"一拳超人:最强之男","v":"yqcrzqzn"},{"n":"王国保卫战4","v":"wgbwz4"},{"n":"半世界之旅","v":"bsjzl"},{"n":"奥特曼宇宙英雄","v":"atmyzyx"},{"n":"新三国杀","v":"xsgs"},{"n":"奶块","v":"nk"},{"n":"策魂三国","v":"chsg"},{"n":"奥特曼系列OL","v":"atmxlol"},{"n":"欢喜斗地主","v":"HXDDZ"},{"n":"洪荒文明","v":"hhwm"},{"n":"街头足球","v":"jtzq"},{"n":"同人圣三国蜀汉传","v":"trssgshc"},{"n":"塔防之光","v":"tfzg"},{"n":"我做夫人那些年","v":"wzfrnxn"},{"n":"小小五千年","v":"xxwqn"},{"n":"乖离性百万亚瑟王:环","v":"glxbwyswh"},{"n":"时空猎人","v":"sklr"},{"n":"星际逆战","v":"xjnz"},{"n":"羽毛球高高手","v":"ymqggs"},{"n":"LoveLive! 学园偶像祭","v":"lovelivexyoxj"},{"n":"黑色沙漠手游","v":"hesmsy"},{"n":"魔力宝贝:旅人","v":"mlbblr"},{"n":"大家饿餐厅","v":"dject"},{"n":"魔力宝贝归来","v":"mlbbgl"},{"n":"巅峰极速","v":"dfjs"},{"n":"新盗墓笔记","v":"xdmbj"},{"n":"轩辕传奇手游","v":"XYCQSY"},{"n":"萤火突击国际服","v":"yhtj"},{"n":"武林闲侠","v":"wlxx"},{"n":"淘米游戏","v":"tmyx"},{"n":"无期迷途","v":"wqmt"},{"n":"逆光潜入","v":"ngqr"},{"n":"深空之眼","v":"skzy"},{"n":"CF手游","v":"CFSY"},{"n":"新天龙八部手游","v":"xtlbbsy"},{"n":"尘白禁区","v":"cbjq"},{"n":"原始征途","v":"yszt"},{"n":"全民大灌篮","v":"qmdgl"},{"n":"枪火重生手游","v":"GunfireReborn"},{"n":"火影三国志","v":"g_hysg"},{"n":"网易其它组","v":"g_wyqt"},{"n":"三国战纪手游","v":"sgzjsy"},{"n":"染·钟楼谜团","v":"BOTC"},{"n":"绝区零","v":"jql"},{"n":"重返CODM","v":"RECODM"},{"n":"综合手游","v":"zhsy"},{"n":"IP游戏","v":"ipyx"},{"n":"鸣潮","v":"cm"},{"n":"棋牌游戏","v":"QPYX"},{"n":"奥比岛:梦想国度","v":"abdmxgd"},{"n":"晶核","v":"jhcoa"},{"n":"星之破晓","v":"dhpx"},{"n":"赛尔计划","v":"srjh"},{"n":"SLG综合","v":"SLG"},{"n":"代号:伙伴","v":"DHGB"},{"n":"天使之战","v":"tszz"},{"n":"全明星街球派对","v":"hoopheroes"},{"n":"合金弹头:觉醒","v":"MetalSlug"},{"n":"劲乐幻想","v":"g_jyhx"},{"n":"白荆回廊","v":"BJHL"},{"n":"战地无疆","v":"zdwj"},{"n":"三国志战棋版","v":"g_sgzzqb"},{"n":"一拳超人:世界","v":"yqcrsj"},{"n":"鹅鸭杀手游","v":"GooseDuck"},{"n":"太空杀","v":"SuperSus"},{"n":"大话西游:归来","v":"dhxygl"},{"n":"战火勋章","v":"zhxz"},{"n":"西行纪 燃魂","v":"xxjrh"},{"n":"决胜巅峰","v":"jueshengdianfeng"},{"n":"冒险岛:枫之传说","v":"MapleStory"},{"n":"七人传奇:光与暗之交战","v":"qirenchuanqi"},{"n":"综合桌游","v":"ZHZY"},{"n":"闪耀!优俊少女","v":"PrettyDerby"},{"n":"三角洲行动","v":"DF"},{"n":"二次元游戏","v":"ECYYX"}]}],
|
||||
// "yz":[{"key":"cateId","name":"分类","value":[{"n":"颜值","v":"yz"}]}],
|
||||
"kjwh":[{"key":"cateId","name":"分类","value":[{"n":"企鹅直播","v":"qezb"},{"n":"数码科技","v":"smkj"},{"n":"纪录片","v":"jlp"},{"n":"成年教育","v":"jiaoyu"},{"n":"人文社科","v":"Humanities"}]}],
|
||||
"yp":[{"key":"cateId","name":"分类","value":[{"n":"派对","v":"paidui"},{"n":"心动FM.","v":"DIANT"},{"n":"一起玩","v":"yiqiwan"}]}],
|
||||
"voice":[{"key":"cateId","name":"分类","value":[{"n":"语音交友","v":"yyjy"},{"n":"音乐之声","v":"yyzs"},{"n":"连麦互动","v":"lianmaihudong"},{"n":"娱乐开黑","v":"ylkh"}]}]
|
||||
// "znl":[{"key":"cateId","name":"分类","value":[{"n":"正能量","v":"znl"}]}]
|
||||
},
|
||||
filter_def:{
|
||||
yl:{cateId:'yqk'},
|
||||
PCgame:{cateId:'LOL'},
|
||||
djry:{cateId:'AC'},
|
||||
syxx:{cateId:'wzry'},
|
||||
yz:{cateId:'yz'},
|
||||
kjwh:{cateId:'smkj'},
|
||||
yp:{cateId:'yiqiwan'},
|
||||
voice:{cateId:'yyzs'},
|
||||
znl:{cateId:'znl'}
|
||||
},
|
||||
class_name:'娱乐天地&网游竞技&单机热游&手游休闲&颜值&科技文化&语音互动&语音直播&正能量',// /api/cate/list
|
||||
class_url:'yl&PCgame&djry&syxx&yz&kjwh&yp&voice&znl',
|
||||
detailUrl: 'http://live.yj1211.work/api/live/getRoomInfo?uid=&platform=douyu&roomId=fyid',// JustLive
|
||||
searchUrl:'/api/search/liveRoom?#did=10000000000000000000000000001501&limit=20&offset=0&sk=**;post',
|
||||
searchable:2,
|
||||
quickSearch:0,
|
||||
headers:{
|
||||
'User-Agent':'MOBILE_UA'
|
||||
},
|
||||
timeout:5000,
|
||||
limit:8,
|
||||
play_parse:true,
|
||||
lazy:'',
|
||||
推荐:`js:
|
||||
let d = [];
|
||||
let jo = JSON.parse(request(input)).data;
|
||||
jo.forEach((it,idex) => {
|
||||
let slist = jo[idex].list ;
|
||||
slist.forEach(it => {
|
||||
d.push({
|
||||
url: it.rid,
|
||||
title: it.roomName,
|
||||
img: it.roomSrc,
|
||||
desc: '👁' + it.hn + ' ' + '🆙' + it.nickname,
|
||||
})
|
||||
});
|
||||
});
|
||||
setResult(d);
|
||||
`,
|
||||
一级:`js:
|
||||
let d = [];
|
||||
let jo = JSON.parse(request(input)).data.list;
|
||||
jo.forEach(it => {
|
||||
d.push({
|
||||
url: it.rid,
|
||||
title: it.roomName,
|
||||
img: it.roomSrc,
|
||||
desc: '👁' + it.hn + ' ' + '🆙' + it.nickname,
|
||||
})
|
||||
});
|
||||
setResult(d);
|
||||
`,
|
||||
二级:`js:
|
||||
var d = [];
|
||||
var jo = JSON.parse(request(input)).data;
|
||||
VOD = {
|
||||
vod_id: jo.roomId,
|
||||
vod_name: jo.roomName,
|
||||
vod_pic: jo.roomPic,
|
||||
type_name: jo.platForm.replace("douyu", "斗鱼") + "." + jo.categoryName,
|
||||
vod_remarks: '🏷roomId ' + jo.roomId,
|
||||
vod_director: '👥在线人数 ' + jo.online,
|
||||
vod_actor: '🆙 ' + jo.ownerName,
|
||||
vod_content: '🏷roomId:' + jo.roomId + "|" + ' 🏷状态:' + (jo.isLive == 1 ? '正在直播' : '未开播'),
|
||||
// vod_content: "🏷分区:" + jo.platForm.replace("douyu", "斗鱼") + "·" + jo.categoryName + " 🏷UP主:" + jo.ownerName + " 🏷人气:" + jo.online + (jo.isLive === 1 ? " 🏷状态:正在直播" : "状态:未开播"),
|
||||
};
|
||||
var playurl = JSON.parse(request("http://live.yj1211.work/api/live/getRealUrl?platform=" + jo.platForm + "&roomId=" + jo.roomId)).data;
|
||||
// var name = {
|
||||
// OD: "JustLive",
|
||||
// FD: "流畅",
|
||||
// LD: "标清",
|
||||
// SD: "高清",
|
||||
// HD: "JustLive(预览)",
|
||||
// "2K": "2K",
|
||||
// "4K": "4K",
|
||||
// FHD: "全高清",
|
||||
// XLD: "极速",
|
||||
// SQ: "普通音质",
|
||||
// HQ: "高音质",
|
||||
// };
|
||||
Object.keys(playurl).forEach(function(key) {
|
||||
// if (!/ayyuid|to/.test(key)) {
|
||||
if (/OD/.test(key)) {
|
||||
d.push({
|
||||
// title: name[key],
|
||||
title: 'JustLive',
|
||||
url: playurl[key]
|
||||
})
|
||||
}
|
||||
});
|
||||
d.push({
|
||||
title: "斗鱼解析1",
|
||||
url: "http://epg.112114.xyz/douyu/" + jo.roomId
|
||||
}, {
|
||||
title: "斗鱼解析2",
|
||||
url: "https://www.aois.eu.org/live/douyu/" + jo.roomId
|
||||
}, {
|
||||
title: "斗鱼解析3",
|
||||
url: "https://www.goodiptv.club/douyu/" + jo.roomId
|
||||
}, {
|
||||
title: "斗鱼解析4",
|
||||
url: "http://maomao.kandiantv.cn/douyu1.php?id=" + jo.roomId
|
||||
});
|
||||
VOD.vod_play_from = "播放源";
|
||||
VOD.vod_play_url = d.map(function(it) {
|
||||
return it.title + "$" + it.url
|
||||
}).join("#");
|
||||
setResult(d);
|
||||
`,
|
||||
搜索:'json:data.list;roomName;roomSrc;nickname;roomId',
|
||||
}
|
||||
var rule={title:"斗鱼直播",host:"https://m.douyu.com",homeUrl:"/api/home/mix",url:"/api/room/list?page=fypage&type=fyfilter",filterable:1,filter_url:"{{fl.cateId}}",filter:{yl:[{key:"cateId",name:"分类",value:[{n:"原创IP",v:"ip"},{n:"一起看",v:"yqk"},{n:"二次元",v:"ecy"},{n:"音乐",v:"music"},{n:"户外",v:"HW"},{n:"美食",v:"ms"},{n:"心动派对",v:"xdpd"},{n:"音遇恋人",v:"yinyu"},{n:"星秀",v:"xingxiu"},{n:"心动FM",v:"dtxs"},{n:"娱乐推荐",v:"yltj"},{n:"新选",v:"xinxuan"}]}],PCgame:[{key:"cateId",name:"分类",value:[{n:"英雄联盟",v:"LOL"},{n:"热门游戏",v:"rmyx"},{n:"穿越火线",v:"CF"},{n:"重生边缘",v:"CSBYOL"},{n:"无畏契约",v:"VALORANT"},{n:"CFHD",v:"CFHD"},{n:"命运方舟",v:"LostArk"},{n:"DNF",v:"DNF"},{n:"DOTA2",v:"DOTA2"},{n:"使命召唤",v:"COD"},{n:"炉石传说",v:"How"},{n:"CS2",v:"CounterStrike"},{n:"lol云顶之弈",v:"ydzhy"},{n:"魔兽争霸",v:"mszb"},{n:"魔兽怀旧服",v:"wowclassic"},{n:"全民街篮",v:"qmjl"},{n:"自走棋",v:"dota2rpg"},{n:"传奇",v:"cq"},{n:"跑跑卡丁车",v:"Popkart"},{n:"网易游戏",v:"wyyx"},{n:"星际争霸",v:"SC"},{n:"守望先锋",v:"Overwatch"},{n:"DOTA",v:"DOTA"},{n:"魔兽世界",v:"WOW"},{n:"剑网3",v:"JX3"},{n:"魔域",v:"EudemonsOnline"},{n:"我的世界",v:"MC"},{n:"超激斗梦境",v:"cjdmj"},{n:"冒险岛",v:"mxd"},{n:"三国杀",v:"sanguosha"},{n:"梦幻西游",v:"MHXYOL"},{n:"天涯明月刀",v:"tianya"},{n:"街头篮球",v:"jtlq"},{n:"NBA2KOL2",v:"NBA2KOL2"},{n:"QQ飞车端游",v:"qqfcdy"},{n:"战地之王",v:"AVA"},{n:"军事游戏",v:"jsyx"},{n:"棋牌娱乐",v:"qipai"},{n:"FC ONLINE",v:"FCOL"},{n:"热门网游",v:"rmwy"},{n:"卡拉彼丘",v:"klbq"},{n:"诛仙世界",v:"zxsj"},{n:"千古风流",v:"qgflpc"},{n:"APEX",v:"APEX"},{n:"流放之路POE",v:"PathofExile"},{n:"剑网3缘起",v:"JW3YQ"},{n:"逆水寒",v:"nsh"},{n:"风暴英雄",v:"HOTS"},{n:"逆战",v:"NZ"},{n:"坦克世界",v:"TKSJ"},{n:"战舰世界",v:"wfws"},{n:"巫师之昆特牌",v:"wszktp"},{n:"反恐精英Online",v:"CS"},{n:"暗黑破坏神",v:"DIABLO"},{n:"梦三国2",v:"msg2"},{n:"传奇世界",v:"cqsj"},{n:"方舟:生存进化",v:"fzscjh"},{n:"神武4电脑版",v:"swdnb"},{n:"群雄逐鹿",v:"qxzl"},{n:"堡垒之夜",v:"blzy"},{n:"无限法则",v:"roe"},{n:"问道电脑版",v:"wddnb"},{n:"西山居游戏",v:"Seasun"},{n:"最终幻想14",v:"FF14"},{n:"战意",v:"WYZY"},{n:"剑灵",v:"BladeSoul"},{n:"星际战甲",v:"Warframe"},{n:"龙之谷",v:"DragonNest"},{n:"铁甲雄兵",v:"tjxb"},{n:"古剑奇谭网络版",v:"gjqtwlb"},{n:"轩辕传奇",v:"XYCQ"},{n:"神途",v:"shentu"},{n:"激战2",v:"GuildWars2"},{n:"高达文化区",v:"gdyxq"},{n:"忍者村大战2",v:"rzcdz2"},{n:"RPG网游专区",v:"rpgwyzq"},{n:"诛仙3",v:"zhuxian3"},{n:"笑傲江湖OL",v:"xajhol"},{n:"冒险岛2",v:"MXD2"},{n:"超击突破",v:"SuperPeople"},{n:"无尽战区",v:"WJZQ"},{n:"斗战神",v:"dzs"},{n:"永恒之塔",v:"AION"},{n:"九阴真经",v:"JYZJ"},{n:"FPS综合网游",v:"FPSOL"},{n:"劲舞团",v:"jwt"},{n:"天下",v:"tianxai"},{n:"泡泡堂",v:"ppt"},{n:"武侠乂",v:"wxy"},{n:"音乐游戏",v:"MG"},{n:"新倩女幽魂",v:"ONLINE"},{n:"天谕",v:"tianyu"},{n:"征途2",v:"zhengtu2"},{n:"QQ炫舞",v:"qqxw"},{n:"泰亚史诗",v:"tyss"},{n:"怪物猎人ol",v:"MHol"},{n:"手工星球",v:"sgxq"},{n:"星战前夜:晨曦",v:"EVE"},{n:"热血传奇:本源",v:"rxcqhjsgb"},{n:"枪火重生",v:"qhcs"},{n:"彩虹岛",v:"CHD"},{n:"御龙在天",v:"YLZT"},{n:"英魂之刃",v:"YHZR"},{n:"自由篮球",v:"ZYLQ"},{n:"洛奇英雄传",v:"LQYXZ"},{n:"封印者",v:"FYZ"},{n:"合金弹头",v:"HJDT"},{n:"新英雄年代",v:"XYXSD"},{n:"星尘传说",v:"XCCS"},{n:"盛趣游戏",v:"SQYX"},{n:"新热血英豪",v:"XRXYH"},{n:"沙盒游戏",v:"SHYX"},{n:"我的世界:地下城",v:"MD"},{n:"恐鬼症",v:"KGZ"},{n:"领地人生",v:"LDRS"},{n:"梦塔防",v:"TDOTK"},{n:"大话西游2",v:"dhxy2"},{n:"猎人",v:"lr"},{n:"热血江湖online",v:"rxjhol"},{n:"千年3",v:"qn3"},{n:"逍遥情缘",v:"xyqy"},{n:"快乐西游",v:"klxy"},{n:"鹿鼎记",v:"ldj"},{n:"新桃花源记",v:"xthyj"},{n:"疾风之刃电脑版",v:"jfzr1"},{n:"武魂2电脑版",v:"wh2pc"},{n:"奇迹世界sun",v:"qjsjsun"},{n:"剑侠世界2电脑版",v:"jxsj2pc"},{n:"斩魂",v:"zhpc"},{n:"大唐2",v:"dt2pc"},{n:"蜀山:初章",v:"ssczpc"},{n:"狼人对决网游",v:"lrdjpc"},{n:"武林群侠传",v:"wlqxzpc"},{n:"飘流幻境",v:"plhjpc"},{n:"破天一剑",v:"ptyj"},{n:"四国军棋",v:"sgjq"},{n:"新大话西游3",v:"xy3"},{n:"装甲战争",v:"zjzz"},{n:"暴雪游戏综合",v:"g_bliz"},{n:"长尾4部虚拟分区",v:"cw4bxnfq"},{n:"燕云十六声",v:"WHEREWINDSMEET"},{n:"THE FINALS",v:"THEFINALS"},{n:"NBA2K Online",v:"NBA2KOL"},{n:"塔瑞斯世界",v:"Tarisland"},{n:"跑跑卡丁车:漂移",v:"KartRiderDrift"},{n:"传奇永恒",v:"EternalLegend"},{n:"全境封锁2",v:"TheDivision2"},{n:"盛趣传奇",v:"sqcq"},{n:"火爆热游",v:"hbry"},{n:"火爆传奇",v:"hbcq"}]}],djry:[{key:"cateId",name:"分类",value:[{n:"主机游戏",v:"TVgame"},{n:"刺客信条:英灵殿",v:"AC"},{n:"马里奥制造",v:"Mario"},{n:"逃离塔科夫",v:"EFT"},{n:"命运2",v:"MY2"},{n:"恐怖游戏",v:"Horror"},{n:"荒野大镖客",v:"hydbk"},{n:"灵魂筹码",v:"lhcm"},{n:"骑马与砍杀",v:"MountAndBlade"},{n:"只狼",v:"ZL"},{n:"格斗游戏",v:"FTG"},{n:"饥荒",v:"DontStarve"},{n:"全境封锁",v:"qjfs"},{n:"怀旧游戏",v:"classic"},{n:"NBA2K",v:"NBA2K"},{n:"八方旅人",v:"OT"},{n:"血污:夜之仪式",v:"Blood"},{n:"人类一败涂地",v:"Human"},{n:"环世界",v:"RimWorld"},{n:"古墓丽影",v:"gmly"},{n:"鬼泣",v:"DMC"},{n:"往日不再",v:"WRBZ"},{n:"仙剑奇侠传",v:"PAL"},{n:"神秘海域",v:"Uncharted"},{n:"塞尔达系列",v:"TLoZ"},{n:"僵尸世界大战",v:"WWZ"},{n:"足球游戏",v:"zq"},{n:"橙光",v:"cg"},{n:"了不起的修仙模拟器",v:"ACS"},{n:"女神异闻录",v:"P5"},{n:"超级马里奥",v:"SMO"},{n:"三国志系列",v:"Sangokushi"},{n:"最终幻想",v:"FF"},{n:"中土世界:战争之影",v:"MiddleEarth"},{n:"流放者柯南",v:"Conan"},{n:"三国群英传",v:"SANGO"},{n:"无主之地",v:"Bor"},{n:"辐射",v:"fs"},{n:"SCUM",v:"Scum"},{n:"文明",v:"CVI"},{n:"仁王",v:"NIOH"},{n:"缺氧",v:"ONI"},{n:"全面吃鸡模拟器",v:"TAB"},{n:"古剑奇谭",v:"GuJian3"},{n:"皇牌空战",v:"hpkz"},{n:"体育游戏",v:"tyyx"},{n:"海岛大亨",v:"hddh"},{n:"碧海黑帆",v:"klhdt"},{n:"植物大战僵尸:花园战争系列",v:"PvsZ"},{n:"蜘蛛侠",v:"Spide"},{n:"勇者斗恶龙:建造者2",v:"DQB2"},{n:"遗迹:灰烬重生",v:"Rem"},{n:"血源",v:"BB"},{n:"旺达与巨像",v:"SotC"},{n:"死亡搁浅",v:"DS"},{n:"模拟人生",v:"Sims"},{n:"空洞骑士",v:"HKS"},{n:"胡闹厨房",v:"Overcooked"},{n:"地铁:离去",v:"ME"},{n:"生死狙击2",v:"ssjjtwo"},{n:"三国战纪",v:"sgzj"},{n:"怀旧FC",v:"edwcy"},{n:"经典单机",v:"jddj"},{n:"英雄无敌",v:"HoMM"},{n:"街机游戏",v:"jjyx"},{n:"合金装备",v:"MetalGear"},{n:"红色警戒",v:"hsjj"},{n:"镜之边缘",v:"MsE"},{n:"勿忘我",v:"Remw"},{n:"火焰纹章系列",v:"FireEmblem"},{n:"星露谷物语",v:"Stardew"},{n:"火炬之光",v:"Torchlight"},{n:"赛博朋克2077",v:"Cyberpunk"},{n:"中国式家长",v:"CP"},{n:"精灵宝可梦系列",v:"Pokemon"},{n:"尼尔:机械纪元",v:"NieR"},{n:"无人深空",v:"NMS"},{n:"EVOTINCTION",v:"EVOTINCTION"},{n:"GT赛车7",v:"GT"},{n:"超级机器人大战",v:"SRW"},{n:"这是我的战争",v:"TWoM"},{n:"杀戮尖塔",v:"sljt"},{n:"冰汽时代",v:"Frostpunk"},{n:"帝国时代",v:"AoEIV"},{n:"死亡空间",v:"swkj"},{n:"凯瑟琳Full Body",v:"CFB"},{n:"足球经理",v:"Football"},{n:"雨中冒险",v:"RoR"},{n:"亿万僵尸",v:"Billions"},{n:"武装突袭",v:"ArmA"},{n:"石油大亨",v:"Oil"},{n:"欧洲卡车模拟器",v:"Truck"},{n:"美国逃亡者",v:"Fugitive"},{n:"漫漫长夜",v:"mmcy"},{n:"永恒轮回",v:"Survival"},{n:"孤岛惊魂",v:"FarCry"},{n:"都市:天际线",v:"Skylines"},{n:"盗贼之海",v:"hdzh"},{n:"Dayz",v:"DayZ"},{n:"60秒",v:"60S"},{n:"俄罗斯钓鱼",v:"RF"},{n:"猎人:荒野的召唤",v:"theHunter"},{n:"恐怖黎明",v:"GD"},{n:"看门狗",v:"kmg"},{n:"真三国无双",v:"DW"},{n:"战斗砖块剧场",v:"BT"},{n:"泰拉瑞亚",v:"Terraria"},{n:"异星工厂",v:"Factorio"},{n:"UFC",v:"UFC"},{n:"底特律:变人",v:"Detroit"},{n:"恶魔城",v:"Castlevania"},{n:"毁灭战士",v:"Doom"},{n:"火影忍者:究极忍者风暴",v:"Naruto"},{n:"坎巴拉太空计划",v:"Kerbal"},{n:"龙珠:超宇宙",v:"DBX"},{n:"马里奥赛车",v:"MarioKart"},{n:"欧陆风云",v:"EU"},{n:"乞丐模拟器",v:"HoboToughLife"},{n:"小偷模拟器",v:"ThiefSimulator"},{n:"逆转裁判",v:"AceA"},{n:"超越光速",v:"FTL"},{n:"植物大战僵尸",v:"PvZ"},{n:"游戏开发者",v:"GGM"},{n:"最后的绿洲",v:"LO"},{n:"大富翁",v:"RichMan"},{n:"反恐精英",v:"fkjy"},{n:"英雄连",v:"yxl"},{n:"永劫无间",v:"NB"},{n:"初音未来:歌姬计划",v:"MIKU"},{n:"部落与弯刀",v:"BLYWD"},{n:"一起开火车!",v:"Unrailed"},{n:"霓虹深渊",v:"NA"},{n:"主机其他游戏",v:"OG"},{n:"战场兄弟",v:"ZCXD"},{n:"地狱潜者",v:"DYQZ"},{n:"地下城",v:"dxc"},{n:"人间地狱",v:"RJDY"},{n:"temtem",v:"temtem"},{n:"弹丸论破",v:"dwlp"},{n:"皇家美食",v:"HJMS"},{n:"基佬大乱斗",v:"jldld"},{n:"僵尸毁灭工程",v:"jshmgc"},{n:"岛屿生存者",v:"Sur"},{n:"冬日计划",v:"drjh"},{n:"四海兄弟",v:"shxd"},{n:"创世理想乡",v:"Craftopia"},{n:"柯娜:精神之桥",v:"Kena"},{n:"幽灵线:东京",v:"GTO"},{n:"Solar Ash",v:"Ash"},{n:"BUGSNAX",v:"BUGSNAX"},{n:"生化危机4重制版",v:"ResidentEvil"},{n:"Grounded",v:"Grounded"},{n:"Superliminal",v:"Superliminal"},{n:"Omno",v:"Omno"},{n:"Röki",v:"Roki"},{n:"Undungeon",v:"Undungeon"},{n:"糖豆人",v:"FallGuys"},{n:"渡神纪",v:"Gods"},{n:"Aeolis Tournament",v:"Aeolis"},{n:"猛兽派对",v:"Animals"},{n:"Olija",v:"Olija"},{n:"Creaks",v:"Creaks"},{n:"暗影火炬城",v:"FIST"},{n:"阿尔比恩",v:"Albion"},{n:"Uragun",v:"Uragun"},{n:"戴森球计划",v:"DSP"},{n:"Muse Dash",v:"MuseDash"},{n:"恐惧之间",v:"Fearsurrounds"},{n:"孤岛惊魂6",v:"FarCry6"},{n:"怪物猎人",v:"MonsterHunterRise"},{n:"黑神话:悟空",v:"BlackMythWuKong"},{n:"仁王2",v:"Nioh2"},{n:"三国群英传8",v:"TheThreeKingdoms8"},{n:"三国志14",v:"THREEKINGDOMSXIV"},{n:"杀手3",v:"Hitman3"},{n:"双人成行",v:"ittakestwo"},{n:"Scrapnaut",v:"Scrapnaut"},{n:"租房达人",v:"TheTenants"},{n:"狙击手:幽灵战士契约2",v:"SniperContracts2"},{n:"全面战争",v:"TotalWarWARHAMMER"},{n:"复体",v:"TheComplex"},{n:"战争机器:战术小队",v:"GearsTactics"},{n:"海绵宝宝:比奇堡的冒险",v:"BattleforBikini"},{n:"分离",v:"Disintegration"},{n:"奇妙探险队2",v:"CuriousExpedition2"},{n:"刺客信条:奥德赛",v:"Odyssey"},{n:"丧尸围城4",v:"DeadRising4"},{n:"星球大战:前线",v:"Battlefront"},{n:"Moonray",v:"Moonray"},{n:"灵魂旅人",v:"SpiritFarerlhlr"},{n:"面容",v:"Visage"},{n:"车祸现场模拟器",v:"Accident"},{n:"破门而入2:北方特遣队",v:"DoorKickers2"},{n:"俄罗斯方块效应:连接",v:"TetrisEffect"},{n:"SD高达G世纪:起源",v:"SDGundamG"},{n:"东方计划:不可思议的幻想乡",v:"TouHou"},{n:"Fate/EXTELLA",v:"FateEXTELLA"},{n:"临终:重生试炼",v:"DYINGReborn"},{n:"虚拟现实乐园",v:"VRWorlds"},{n:"苍翼默示录:神观之梦",v:"CentralFiction"},{n:"晚班",v:"LateShift"},{n:"子弹风暴",v:"Bulletstorm"},{n:"巡警",v:"BeatCop"},{n:"耻辱之日",v:"DayofInfamy"},{n:"狙击精英4",v:"SniperElite4"},{n:"热血物语:地下世界",v:"RiverCityRansom"},{n:"史诗战争模拟器",v:"BattleSimulator"},{n:"银河护卫队",v:"Guardians"},{n:"上古卷轴:传奇",v:"ScrollsLegends"},{n:"闪乱神乐:少女们的选择",v:"SenranKagura"},{n:"幽灵行动:荒野",v:"GhostReconWildland"},{n:"白色情人节",v:"WhiteDay"},{n:"誓死坚守",v:"UntilWeDie"},{n:"狂战传说",v:"TalesofBerseria"},{n:"双截龙4",v:"DoubleDragon4"},{n:"地下蚁国",v:"Undergrowth"},{n:"寻找天堂",v:"findparadise"},{n:"画中世界",v:"Gorogoa"},{n:"现代战争",v:"ModernCombat"},{n:"绯红结系",v:"SCARLETNEXUS"},{n:"罪恶装备:STRIVE",v:"GuiltyGear"},{n:"涅克罗蒙达:赏金猎人",v:"NHiredGun"},{n:"骑士精神2",v:"Chivalry2"},{n:"Rune Knights",v:"RuneKnights"},{n:"红至日2:幸存者",v:"TheRed2"},{n:"真女神转生3",v:"ShinMegami3"},{n:"速降王者",v:"Descenders"},{n:"工业崛起",v:"RiseIndustry"},{n:"前往中世纪",v:"GoMedieval"},{n:"Arid",v:"Arid"},{n:"伊始之地",v:"TerraNil"},{n:"进击的巨人2",v:"AttackonTitan2"},{n:"魔域之书",v:"Bookofdevil"},{n:"自由人:游击战争",v:"Freeman"},{n:"战国无双5",v:"SWarriors5"},{n:"不要喂食猴子",v:"NotFeedMonkeys"},{n:"古剑奇谭3",v:"GuJianqitan3"},{n:"剑士",v:"KenshiJS"},{n:"GRIS",v:"GRIS"},{n:"古剑奇谭:永夜",v:"gujianyongye"},{n:"永恒边缘",v:"EdgeEternity"},{n:"Below",v:"Below"},{n:"彩虹坠入",v:"IrisFall"},{n:"嗜血印",v:"BloodySpell"},{n:"兽人必须死3",v:"OrcsDie3"},{n:"狙击精英VR",v:"SniperEliteVR"},{n:"遗忘之城",v:"ForgotCity"},{n:"Last Stop",v:"LastStop"},{n:"边界之外",v:"OutofLine"},{n:"从军",v:"jointhearmy"},{n:"石炉",v:"Stonehearth"},{n:"狂热运输2",v:"TransportFever2"},{n:"机甲战士5",v:"MechWarrior5"},{n:"PICO PARK",v:"PICOPARK"},{n:"光明记忆:无限",v:"Brightmemory"},{n:"秘馆疑踪",v:"HeavenDust"},{n:"侠盗公司",v:"RogueCompany"},{n:"英雄传说:创之轨迹",v:"HajimariNOKiseki"},{n:"战地系列",v:"Battlefiel"},{n:"塞尔达传说:天空之剑HD",v:"SkywardSword"},{n:"尘埃异变",v:"GRIME"},{n:"异形:火力小队精英",v:"FireteamElite"},{n:"12分钟",v:"TwelveMinutes"},{n:"九十六号公路",v:"Road96"},{n:"FORECLOSED",v:"FORECLOSED"},{n:"RiMS Racing",v:"RiMSRacing"},{n:"钢铁之尾",v:"TailsofIron"},{n:"剑侠图",v:"JianXiaTu"},{n:"审判之逝",v:"Lostjudgment"},{n:"帝国神话",v:"mythofempires"},{n:"艾尔登法环",v:"ELDENRING"},{n:"极限竞速:地平线5",v:"ForzaHorizon5"},{n:"使命召唤系列",v:"CALLOFDUTYCOD"},{n:"网吧模拟器",v:"InternetCS"},{n:"The Anacrusis",v:"TheAnacrusis"},{n:"浩劫前夕",v:"TheDayBefore"},{n:"文字游戏",v:"WordGame"},{n:"消逝的光芒2",v:"DyingLight2"},{n:"无主之地3",v:"Borderlands3"},{n:"战神:诸神黄昏",v:"GodofWarRagnarok"},{n:"海上狼人杀",v:"DreadHunger"},{n:"侠乂行:浪迹天涯",v:"XIAYIXING"},{n:"最终幻想:起源",v:"STRANGEROFPARADISE"},{n:"HordeCore",v:"HordeCore"},{n:"双子星:盛气凌人",v:"YoungSouls"},{n:"Indies’ Lies",v:"IndiesLies"},{n:"Deck of Ashes",v:"DeckofAshes"},{n:"星空",v:"Starfield"},{n:"Ilysia",v:"Ilysia"},{n:"Project Q",v:"ProjectQ"},{n:"Pummel Party",v:"PummelParty"},{n:"Holomento",v:"Holomento"},{n:"Overprime",v:"Overprime"},{n:"森林之子",v:"SonsOfTheForest"},{n:"弈仙牌",v:"yixianpai"},{n:"夜族崛起",v:"VRising"},{n:"罗马复兴",v:"RomanRenaissance"},{n:"萤火突击",v:"LostLight"},{n:"High on Life",v:"HighonLife"},{n:"匹诺曹的谎言",v:"LiesofP"},{n:"Isonzo",v:"Isonzo"},{n:"瘟疫传说:安魂曲",v:"Requiem"},{n:"漂泊牧歌",v:"WanderingVillage"},{n:"塞尔达传说:王国之泪",v:"TEARSKINGDOM"},{n:"破碎线",v:"Shatterline"},{n:"卧龙:苍天陨落",v:"Wolong"},{n:"卡库远古封印",v:"KAKU"},{n:"原子之心",v:"AtomicHeart"},{n:"Warhaven",v:"Warhaven"},{n:"宝可梦:朱/紫",v:"ScarletandViolet"},{n:"Evercore Heroes",v:"EvercoreHeroes"},{n:"灵魂石幸存者",v:"SoulstoneSurvivors"},{n:"主机一起看",v:"zjyqk"},{n:"社交互动游戏",v:"SJHDYX"},{n:"轮回修仙路",v:"lhxxl"},{n:"Divine Knockout",v:"DivineKnockout"},{n:"至暗时刻",v:"DarkandDarker"},{n:"自杀小队:杀死正义联盟",v:"KTJL"},{n:"XDefiant",v:"XDefiant"},{n:"Warlander",v:"Warlander"},{n:"Scars Above",v:"ScarsAbove"},{n:"Pacific Drive",v:"PacificDrive"},{n:"最终幻想16",v:"FinalFantasyXVI"},{n:"街头霸王",v:"StreetFighter"},{n:"Tchia",v:"Tchia"},{n:"大侠立志传",v:"HerosAdventure"},{n:"最后纪元",v:"LastEpoch"},{n:"魔戒:咕噜",v:"Gollum"},{n:"Prison Life 2",v:"PrisonLife"},{n:"Innchanted",v:"Innchanted"},{n:"幻兽帕鲁",v:"Palworld"},{n:"Life by You",v:"LifebyYou"},{n:"Eresys",v:"Eresys"},{n:"Pax Dei",v:"PaxDei"},{n:"Teravit",v:"Teravit"},{n:"Caliber",v:"Caliber"},{n:"沙盒与副本:英勇之地",v:"HerosLand"},{n:"Coridden",v:"Coridden"},{n:"Unrecord",v:"Unrecord"},{n:"Deducto 2",v:"Deducto2"},{n:"装甲核心6:境界天火",v:"ArmoredCore"},{n:"Wayfinder",v:"Wayfinder"},{n:"迷瘴纪事",v:"MiasmaChronicles"},{n:"Minigame Madness",v:"MinigameMadness"},{n:"严阵以待",v:"ReadyorNot"},{n:"上古卷轴OL",v:"TheElderScrolls"},{n:"弹幕风暴",v:"dmfb"},{n:"学园构想家",v:"SchoolHomeroom"},{n:"弈仙牌手游",v:"YiXianm"},{n:"Jusant",v:"JUSANT"},{n:"潜水员戴夫",v:"DAVETHEDIVER"},{n:"GYLT",v:"GYLT"},{n:"索利斯堡",v:"FortSolis"},{n:"Towerborne",v:"Towerborne"},{n:"33 Immortals",v:"33Immortals"},{n:"Wildmender",v:"Wildmender"},{n:"How 2 Escape",v:"How2Escape"},{n:"碧蓝幻想:Relink",v:"Relink"},{n:"漫威蜘蛛侠2",v:"MarvelSpiderman2"},{n:"王权与自由",v:"ThroneandLiberty"},{n:"博德之门3",v:"BG3"},{n:"Eternights",v:"Eternights"},{n:"Project F",v:"ProjectF"},{n:"BaldMan Climbs Up",v:"BaldManClimbsUp"},{n:"FC24",v:"FC24"},{n:"NBA 2K24",v:"NBA2K24"},{n:"沉没之地",v:"Sunkenland"},{n:"七日世界",v:"qrsj"},{n:"雾锁王国",v:"wswg"}]}],syxx:[{key:"cateId",name:"分类",value:[{n:"元梦之星",v:"YMZX"},{n:"王者荣耀",v:"wzry"},{n:"LOL手游",v:"LOLM"},{n:"崩坏:星穹铁道",v:"bhxqtd"},{n:"和平精英",v:"hpjy"},{n:"暗区突围",v:"aqtw"},{n:"蛋仔派对",v:"dzpd"},{n:"高能英雄",v:"gnyx"},{n:"幻塔",v:"ht"},{n:"火影忍者",v:"hyrz"},{n:"COD手游",v:"smzhsy"},{n:"lol电竞经理",v:"EGAME"},{n:"DNF手游",v:"mdnf"},{n:"金铲铲之战",v:"JGAME"},{n:"天刀手游",v:"tdsy"},{n:"原神",v:"yuanshen"},{n:"航海王热血航线",v:"HHWRXHX"},{n:"逆水寒手游",v:"NSHM"},{n:"万国觉醒",v:"wgjx"},{n:"鸿图之下",v:"htzx"},{n:"欢乐麻将",v:"HLMJ"},{n:"王者模拟战",v:"wzrpg"},{n:"中国象棋",v:"ZGXQ"},{n:"天谕手游",v:"tysy"},{n:"巅峰坦克",v:"DFTK"},{n:"新游中心",v:"xyzx"},{n:"热门手游",v:"phone"},{n:"梦幻手游",v:"mhxy"},{n:"QQ飞车",v:"qqfcsy"},{n:"第五人格",v:"dwrg"},{n:"欢乐斗地主",v:"hlddz"},{n:"荒野乱斗",v:"hyld"},{n:"阴阳师",v:"yys"},{n:"狼人杀",v:"LRS"},{n:"JJ斗地主",v:"jj"},{n:"梦幻新诛仙",v:"mhxzx"},{n:"街霸对决",v:"jbdj"},{n:"机动都市阿尔法",v:"jddsaef"},{n:"一人之下",v:"yrzx"},{n:"多多自走棋",v:"zzq"},{n:"崩坏3",v:"bhxl"},{n:"风云岛行动",v:"fydxd"},{n:"云游戏",v:"cloudgame"},{n:"跑跑手游",v:"PPKDCSY"},{n:"率土之滨",v:"stzb"},{n:"灌篮高手",v:"glgs"},{n:"皇室战争",v:"hszz"},{n:"忍者必须死3",v:"rzbxs3"},{n:"神武4手游",v:"sw3"},{n:"梦幻模拟战",v:"mhmnz"},{n:"实况足球",v:"skzq"},{n:"剑与远征",v:"jyyz"},{n:"航海王:燃烧意志",v:"hhwrsyz"},{n:"球球大作战",v:"qqdzz"},{n:"英雄杀",v:"yxs"},{n:"魔域口袋版",v:"mykdb"},{n:"口袋新旅程",v:"KDXLC"},{n:"剑网3:指尖江湖",v:"jw3zjjh"},{n:"部落冲突",v:"blct"},{n:"剑与家园",v:"jyjy"},{n:"新笑傲江湖",v:"xxajh"},{n:"猫和老鼠",v:"mhls"},{n:"猎人手游",v:"lrlr"},{n:"明日之后",v:"mrzh"},{n:"影之诗",v:"yzs"},{n:"决战平安京",v:"jzpaj"},{n:"魂斗罗归来",v:"DLHGL"},{n:"贪吃蛇大作战",v:"tcsdzz"},{n:"圣斗士星矢",v:"sdsxs"},{n:"魔力宝贝手游",v:"mlbbsy"},{n:"哈利波特:魔法觉醒",v:"HarryPotter"},{n:"手游推广",v:"rmsy"},{n:"魔灵召唤",v:"mlzh"},{n:"香肠派对",v:"xcpd"},{n:"迷你世界",v:"MNSJ"},{n:"荒野行动",v:"hyxd"},{n:"大话西游2口袋版",v:"dhxy2kdb"},{n:"FC足球世界",v:"FCZQSJ"},{n:"街篮",v:"jl"},{n:"一起来捉妖",v:"yiqilaizhuoyao"},{n:"明日方舟",v:"mrfz"},{n:"自由幻想手游",v:"zyhx"},{n:"一梦江湖",v:"ymjh"},{n:"王牌战争:文明重启",v:"wmcq"},{n:"完美世界手游",v:"wmsjsy"},{n:"拳皇98OL",v:"kof98"},{n:"赛尔号",v:"srh"},{n:"猎魂觉醒",v:"lhjx"},{n:"仙境传说",v:"xjcs"},{n:"逃跑吧少年",v:"tpbsn"},{n:"石器时代",v:"sqsd"},{n:"英魂之刃口袋版",v:"yh"},{n:"拉结尔",v:"lje"},{n:"倩女幽魂手游",v:"qnyhsy"},{n:"决斗之城2",v:"jdzc2"},{n:"传奇手游",v:"cqsy"},{n:"欢乐升级",v:"hlsj"},{n:"雀魂",v:"Majsoul"},{n:"二次元手游",v:"ecysy"},{n:"天龙八部online",v:"tianlongbabuonline"},{n:"征途2手游",v:"zt2sy"},{n:"万王之王3D",v:"wwzw3D"},{n:"武林外传",v:"wlwz"},{n:"我叫MT4",v:"MT4"},{n:"元气骑士",v:"yuanqiqishi"},{n:"红警OL手游",v:"hjolsy"},{n:"植物大战僵尸手游",v:"ZWDZJS"},{n:"龙之谷手游",v:"lzgsy"},{n:"创造与魔法",v:"ccymf"},{n:"境界-死神激斗",v:"jjssjd"},{n:"奇迹觉醒",v:"qjjx"},{n:"光遇",v:"skygy"},{n:"游戏王:决斗链接",v:"yxwjdlj"},{n:"巅峰战舰",v:"dfzj"},{n:"绝世战魂",v:"jszh"},{n:"寻仙",v:"xunxian"},{n:"天天象棋",v:"ttxq"},{n:"王国纪元",v:"wgjy"},{n:"龙族幻想",v:"lzhx"},{n:"剑网3指尖对弈",v:"jwszjdy"},{n:"剑侠情缘2:剑歌行",v:"jianxiaqingyuan"},{n:"三国杀移动版",v:"SGSSY"},{n:"罗布乐思",v:"Roblox"},{n:"足球手游",v:"zqsy"},{n:"月圆之夜",v:"yyzy"},{n:"王牌战争",v:"wpzz"},{n:"秦时明月世界",v:"qsmysj"},{n:"独立手游",v:"dlsy"},{n:"神都夜行录",v:"sdyxl"},{n:"风之大陆",v:"fzdl"},{n:"金属对决",v:"jsdj"},{n:"轩辕剑龙舞云山",v:"xyjlwys"},{n:"微乐棋牌",v:"WLQP"},{n:"辐射:避难所Online",v:"fsbnsonline"},{n:"街篮2",v:"jl2"},{n:"极光计划",v:"jgjh"},{n:"不良人3",v:"blr3"},{n:"镇魔曲手游",v:"zmq"},{n:"传奇世界手游",v:"cqsjsy"},{n:"永恒纪元",v:"yhjy"},{n:"乱世王者",v:"lswz"},{n:"数码宝贝:相遇",v:"smbbxy"},{n:"仙剑4",v:"xjqxz4"},{n:"长安幻世绘",v:"cahsh"},{n:"篮球手游",v:"lqsy"},{n:"鬼泣-巅峰之战",v:"gqdfzz"},{n:"射击类手游",v:"qtsy"},{n:"命运歌姬",v:"mygj"},{n:"光明大陆",v:"gmdl"},{n:"暗黑不朽",v:"diabloimmortal"},{n:"新神魔大陆",v:"xsmdl"},{n:"公主连结Re:Dive",v:"gzlj"},{n:"三国志战略版",v:"sgzzlb"},{n:"天地劫:幽城再临",v:"tdj"},{n:"Disorder",v:"Disorder"},{n:"凹凸世界",v:"atsj"},{n:"云上城之歌",v:"ysczg"},{n:"五子棋",v:"wzq"},{n:"围棋",v:"wq"},{n:"梦想新大陆",v:"mxxdl"},{n:"三国志幻想大陆:国创加强版",v:"sgzhxdl"},{n:"全球行动",v:"qqxd"},{n:"诛仙手游",v:"zxsy"},{n:"妄想山海",v:"wxsh"},{n:"黎明觉醒:生机",v:"lmjx"},{n:"龙之谷2手游",v:"lzg2sy"},{n:"庆余年",v:"QYN"},{n:"我的侠客",v:"wdxk"},{n:"曙光英雄",v:"sgyx"},{n:"真三国无双霸",v:"zsgwsb"},{n:"大话西游手游",v:"dhxysy"},{n:"口袋进化",v:"kdjh"},{n:"开心消消乐",v:"kxxxl"},{n:"战争怒吼",v:"zznh"},{n:"忘川风华录",v:"wcfhl"},{n:"新剑侠情缘手游",v:"xjxqysy"},{n:"重生细胞",v:"csxb"},{n:"汉家江湖",v:"HJJH"},{n:"海岛奇兵",v:"hdqb"},{n:"钢铁力量2",v:"gtll2"},{n:"仙剑奇侠传九野",v:"xjqxzjy"},{n:"魔域手游",v:"mysy"},{n:"大唐无双手游",v:"dtwssy"},{n:"地铁跑酷",v:"dtpk"},{n:"战舰世界闪击战",v:"zjsjsjz"},{n:"狂暴之翼",v:"kbzy"},{n:"西游女儿国",v:"xyneg"},{n:"少年三国志",v:"snsgz"},{n:"钢琴师",v:"gqs"},{n:"横扫千军",v:"hsqj"},{n:"节奏大爆炸",v:"jzdbz"},{n:"喵斯快跑",v:"mskp"},{n:"双子",v:"sz"},{n:"梦想世界3手游",v:"mxsj3"},{n:"精灵之境",v:"jlzj"},{n:"镇魂街:武神躯",v:"zhjwsq"},{n:"斗罗大陆:斗神再临",v:"dldldszl"},{n:"斗罗大陆:武魂觉醒",v:"dldlwhjx"},{n:"斗罗大陆2绝世唐门",v:"dldl2jstm"},{n:"战神觉醒",v:"zsjx"},{n:"九州仙剑传H5",v:"jzxjzh5"},{n:"荣耀大天使",v:"rydts"},{n:"蓝月传奇",v:"lycq"},{n:"凡人修仙传挂机版H5",v:"frxxzgjbh5"},{n:"我的帝国H5",v:"wddgh5"},{n:"盗墓笔记",v:"dmbj"},{n:"剑与轮回",v:"jylh"},{n:"混沌起源",v:"hdqy"},{n:"大天使之剑",v:"dtszj"},{n:"战斗少女跑酷",v:"zdsnpk"},{n:"绝世仙王",v:"jsxw"},{n:"一刀传世",v:"ydcs"},{n:"斗罗大陆",v:"dldl"},{n:"破雪刃",v:"pxr"},{n:"JJ象棋",v:"jjxq"},{n:"天姬变",v:"tjb"},{n:"剑玲珑",v:"jll"},{n:"火线精英",v:"hxjy"},{n:"造梦西游OL",v:"zmxyol"},{n:"奥奇传说手游",v:"aqcssy"},{n:"战斗吧龙魂",v:"zdblh"},{n:"剑开仙门",v:"jkxm"},{n:"机甲爱丽丝",v:"jjals"},{n:"狼人对决",v:"lrdj"},{n:"最终幻想:勇气启示录 幻影战争",v:"hyzz"},{n:"贝比岛",v:"bbd"},{n:"葫芦娃兄弟",v:"hlwxd"},{n:"造梦西游4",v:"zmxy4"},{n:"比特小队",v:"btxd"},{n:"流言侦探",v:"lyzt"},{n:"少女前线",v:"snqx"},{n:"遇见",v:"yj"},{n:"霓虹深渊:无限",v:"nhsywx"},{n:"胡莱三国3",v:"hlsg3"},{n:"奥拉星",v:"alx"},{n:"先游云游戏",v:"Gamer"},{n:"绿茵信仰",v:"lyxy"},{n:"蜀山掌门",v:"sszm"},{n:"球球联盟",v:"qqlm"},{n:"碧蓝航线手游",v:"blhxsy"},{n:"300大作战",v:"300dzz"},{n:"第七史诗",v:"dqss"},{n:"宝可梦大集结",v:"PokemonUNITE"},{n:"无极仙途",v:"wjxt"},{n:"汉末霸业",v:"hmby"},{n:"EVE星战前夜:无烬星河",v:"evexzqywjxh"},{n:"少女前线2:追放",v:"sq2zf"},{n:"火力苏打(T3)",v:"T3"},{n:"植物大战僵尸2",v:"zwdzjs2"},{n:"球球英雄",v:"qqyx"},{n:"悠长假期",v:"ycjq"},{n:"无悔华夏",v:"whrhx"},{n:"猫之城",v:"mzc"},{n:"墨斗",v:"modou"},{n:"圣斗士星矢:正义传说",v:"sdsxszyz"},{n:"未定事件簿",v:"wdsjp"},{n:"白夜极光",v:"byjg"},{n:"斗罗大陆:魂师对决",v:"dldlhsdj"},{n:"古墓丽影传说:迷踪",v:"gmlycsmz"},{n:"放置与召唤",v:"fzyzh"},{n:"闪烁之光",v:"syzg"},{n:"老农种树",v:"lnzs"},{n:"三国演义:吞噬无界",v:"sgyytswj"},{n:"偶像梦幻祭2",v:"oxmhj2"},{n:"卡卡保皇",v:"kkbh"},{n:"灵猫传",v:"lmz"},{n:"绝对演绎",v:"jdyy"},{n:"剑侠世界3",v:"jxsj3"},{n:"召唤与合成2",v:"zhyhc2"},{n:"仙侠第一放置",v:"xxdyfz"},{n:"弓箭手大作战",v:"gjsdzz"},{n:"挨饿荒野",v:"aehy"},{n:"诺亚之心",v:"nyzx"},{n:"闪耀暖暖",v:"synn"},{n:"模拟城市:我是市长",v:"mncswssc"},{n:"重返帝国",v:"cfdg"},{n:"长安幻想",v:"cahx"},{n:"火炬之光:无限",v:"hjzgwx"},{n:"富豪闯三国",v:"fhcsg"},{n:"拂晓",v:"fx"},{n:"火影忍者:忍者新世代",v:"hyrzrzxsd"},{n:"滚动的天空",v:"gddtk"},{n:"新斗罗大陆",v:"xdldl"},{n:"登山赛车",v:"dssc"},{n:"荒野乱斗(腾讯版)",v:"hyldtxb"},{n:"小小勇者",v:"xxyz"},{n:"小冰冰传奇",v:"xbbcq"},{n:"三国战纪2手游",v:"sgzj2"},{n:"我的战舰",v:"wdzj"},{n:"我是大东家",v:"wsddj"},{n:"幸存者危城",v:"xczwc"},{n:"暗魔领主",v:"amlz"},{n:"冒险公社手游",v:"mxgs"},{n:"欧陆战争5:帝国",v:"olzz5dg"},{n:"纪念碑谷2",v:"jnbg2"},{n:"大航海探险物语",v:"dhhtxwy"},{n:"我在7年后等着你",v:"wz7nhdzn"},{n:"航海日记",v:"hhrj"},{n:"一拳超人:最强之男",v:"yqcrzqzn"},{n:"王国保卫战4",v:"wgbwz4"},{n:"半世界之旅",v:"bsjzl"},{n:"奥特曼宇宙英雄",v:"atmyzyx"},{n:"新三国杀",v:"xsgs"},{n:"奶块",v:"nk"},{n:"策魂三国",v:"chsg"},{n:"奥特曼系列OL",v:"atmxlol"},{n:"洪荒文明",v:"hhwm"},{n:"街头足球",v:"jtzq"},{n:"同人圣三国蜀汉传",v:"trssgshc"},{n:"我做夫人那些年",v:"wzfrnxn"},{n:"小小五千年",v:"xxwqn"},{n:"实况球会经理",v:"skqhjl"},{n:"时空猎人",v:"sklr"},{n:"星际逆战",v:"xjnz"},{n:"LoveLive! 学园偶像祭",v:"lovelivexyoxj"},{n:"黑色沙漠手游",v:"hesmsy"},{n:"魔力宝贝:旅人",v:"mlbblr"},{n:"盾之勇者成名录:浪潮",v:"dzyzcmllc"},{n:"魔力宝贝归来",v:"mlbbgl"},{n:"荣耀新三国",v:"ryxsg"},{n:"巅峰极速",v:"dfjs"},{n:"新盗墓笔记",v:"xdmbj"},{n:"卧龙吟2",v:"wly2"},{n:"武林闲侠",v:"wlxx"},{n:"淘米游戏",v:"tmyx"},{n:"暖雪",v:"warmsnow"},{n:"无期迷途",v:"wqmt"},{n:"逆光潜入",v:"ngqr"},{n:"CF手游",v:"CFSY"},{n:"新天龙八部手游",v:"xtlbbsy"},{n:"无神之界",v:"wszj"},{n:"尘白禁区",v:"cbjq"},{n:"传奇天下",v:"CQTX"},{n:"全民大灌篮",v:"qmdgl"},{n:"枪火重生手游",v:"GunfireReborn"},{n:"火影三国志",v:"g_hysg"},{n:"网易其它组",v:"g_wyqt"},{n:"三国战纪手游",v:"sgzjsy"},{n:"染·钟楼谜团",v:"BOTC"},{n:"绝区零",v:"jql"},{n:"魔兽弧光大作战",v:"warcraftrumble"},{n:"重返CODM",v:"RECODM"},{n:"综合手游",v:"zhsy"},{n:"IP游戏",v:"ipyx"},{n:"鸣潮",v:"cm"},{n:"棋牌游戏",v:"QPYX"},{n:"奥比岛:梦想国度",v:"abdmxgd"},{n:"铃兰之剑",v:"llzjwzhpdsj"},{n:"晶核",v:"jhcoa"},{n:"星之破晓",v:"dhpx"},{n:"赛尔计划",v:"srjh"},{n:"SLG综合",v:"SLG"},{n:"代号:伙伴",v:"DHGB"},{n:"天使之战",v:"tszz"},{n:"全明星街球派对",v:"hoopheroes"},{n:"合金弹头:觉醒",v:"MetalSlug"},{n:"白荆回廊",v:"BJHL"},{n:"三国志战棋版",v:"g_sgzzqb"},{n:"鹅鸭杀手游",v:"GooseDuck"},{n:"太空杀",v:"SuperSus"},{n:"天龙八部2:飞龙战天",v:"tlbb2flzt"},{n:"西行纪 燃魂",v:"xxjrh"},{n:"决胜巅峰",v:"jueshengdianfeng"},{n:"冒险岛:枫之传说",v:"MapleStory"},{n:"石器时代:觉醒",v:"sqsdjx"},{n:"星球:重启",v:"xqcq"},{n:"决战玛法",v:"jzmf"},{n:"二次元游戏",v:"ECYYX"},{n:"圣境之塔",v:"sjzt"},{n:"传说法师手游",v:"CSFSSY"},{n:"钢岚",v:"Mecharashi"},{n:"勇闯三国",v:"ycsg"},{n:"绯色回响",v:"fshxgf"},{n:"三国:谋定天下",v:"sgmdtx"}]}],kjwh:[{key:"cateId",name:"分类",value:[{n:"数码科技",v:"smkj"},{n:"纪录片",v:"jlp"},{n:"成年教育",v:"jiaoyu"},{n:"人文社科",v:"Humanities"}]}],yp:[{key:"cateId",name:"分类",value:[{n:"派对",v:"paidui"},{n:"心动FM.",v:"DIANT"},{n:"一起玩",v:"yiqiwan"}]}],voice:[{key:"cateId",name:"分类",value:[{n:"语音交友",v:"yyjy"},{n:"音乐之声",v:"yyzs"},{n:"连麦互动",v:"lianmaihudong"},{n:"娱乐开黑",v:"ylkh"}]}]},filter_def:{yl:{cateId:"yqk"},PCgame:{cateId:"LOL"},djry:{cateId:"TVgame"},syxx:{cateId:"wzry"},yz:{cateId:"yz"},kjwh:{cateId:"smkj"},yp:{cateId:"yiqiwan"},voice:{cateId:"yyzs"},znl:{cateId:"znl"}},class_name:"娱乐天地&网游竞技&单机热游&手游休闲&颜值&科技文化&语音互动&语音直播&正能量",class_url:"yl&PCgame&djry&syxx&yz&kjwh&yp&voice&znl",detailUrl:"https://m.douyu.com/fyid?dyshid=0-1c6d52c74b1e6bec7aa63a8e000617p1&dyshci=181",searchUrl:"/api/search/liveRoom?#did=10000000000000000000000000001501&limit=20&offset=0&sk=**;post",searchable:2,quickSearch:0,headers:{"User-Agent":"MOBILE_UA"},timeout:5e3,limit:8,play_parse:!0,lazy:"","推荐":"js:\n let d = [];\n let jo = JSON.parse(request(input)).data;\n jo.forEach((it,idex) => {\n let slist = jo[idex].list ;\n slist.forEach(it => {\n d.push({\n url: it.rid,\n title: it.roomName,\n img: it.roomSrc,\n desc: '👁' + it.hn + ' 🆙' + it.nickname,\n })\n });\n });\n setResult(d);\n ","一级":"js:\n let d = [];\n let jo = JSON.parse(request(input)).data.list;\n jo.forEach(it => {\n d.push({\n url: it.rid,\n title: it.roomName,\n img: it.roomSrc,\n desc: '👁' + it.hn + ' 🆙' + it.nickname,\n })\n });\n setResult(d);\n ",
|
||||
|
||||
二级:'*',
|
||||
|
||||
"搜索":"js:\n var d = [];\n let rurls = input.split(';')[0].split('#');\n let rurl = rurls[0];\n let params = rurls.length > 1 ?rurls[1]:'';\n let _fetch_params = JSON.parse(JSON.stringify(rule_fetch_params));\n let postData = {body:params};\n Object.assign(_fetch_params,postData);\n let jo = JSON.parse(post(rurl,_fetch_params)).data.list;\n jo.forEach(it => {\n d.push({\n url: it.roomId,\n title: it.roomName,\n img: it.roomSrc,\n desc: '👁' + it.hn + ' 🆙' + it.nickname,\n })\n });\n setResult(d);\n ",sniffer:1,isVideo:"js:\n log(input);\n if(/\\/huya/.test(input)) {\n input = true\n } else if(/\\.flv?|\\.m3u8?|\\.mp4?/.test(input)){\n input = true\n }else{\n input = false\n }\n "};
|
||||
+36
-37
@@ -1,38 +1,37 @@
|
||||
|
||||
var rule = {
|
||||
title:'有声小说吧',
|
||||
编码:'gb18030',
|
||||
host:'http://m.ysxs8.vip',
|
||||
url:'/downlist/fyclass_fypage.html',
|
||||
searchUrl:'/search.asp?page=fypage&searchword=**&searchtype=-1',
|
||||
searchable:2,
|
||||
quickSearch:0,
|
||||
headers:{
|
||||
'User-Agent':'MOBILE_UA'
|
||||
},
|
||||
timeout:5000,
|
||||
// homeUrl:'/fenlei/',
|
||||
// class_parse: '.pd-class:eq(0) dd;a&&Text;a&&href;.*/(.*?).html',
|
||||
class_name:'网络玄幻&恐怖悬疑&传统武侠&都市言情&官场刑侦&历史军事&探险盗墓&职场商战&明朝那些事儿&评书下载&相声戏曲&人物传记&广播剧&百家讲坛&外语读物&有声文学&儿童读物&管理营销',
|
||||
class_url:'r52&r17&r12&r13&r14&r15&r45&r81&r36&r3&r7&r16&r18&r32&r35&r41&r4&r6',
|
||||
play_parse:true,
|
||||
lazy:'',
|
||||
limit:6,
|
||||
// double:true,
|
||||
推荐:'.list-ul .list-li;.list-name&&Text;*;.module-slide-author&&Text;*',
|
||||
一级:'.book-ol&&li;h4&&Text;img&&data-original;.book-meta&&Text;a&&href',
|
||||
二级:{
|
||||
// title:'h2&&Text;.book-cell .book-rand-a:eq(2)&&Text',
|
||||
title:'h1&&Text;.book-cell .book-rand-a:eq(0)&&a&&Text',
|
||||
img:'.book img&&src',
|
||||
// desc:';;;;.book-des p&&Text',
|
||||
desc:';;;.book-rand-a:eq(2)&&Text;.book-des p&&Text',
|
||||
content:'.book-des--p&&Text',
|
||||
tabs:'.playlist-top&&h2',
|
||||
// lists:'js:pd=jsp.pd;let url=pd(html,".bookbutton&&a&&href");log(url);html=request(url);let v=pd(html,".booksite&&script&&Html");var document={};var VideoListJson;VideoListJson=eval(v.split("VideoListJson=")[1].split(",urlinfo")[0]);log(typeof VideoListJson);let list1=VideoListJson[0][1];LISTS=[list1];log(LISTS);',
|
||||
// 有声小说有防盗链,我服了(上面的列表数据正常拿到了,没法播放)
|
||||
// lists:'#playlist:eq(#id)&&ul&&li',
|
||||
lists:'#playlist ul li',
|
||||
},
|
||||
搜索:'*',
|
||||
var rule = {
|
||||
title:'有声小说吧',
|
||||
编码:'gb18030',
|
||||
host:'http://m.ysxs8.vip',
|
||||
url:'/downlist/fyclass_fypage.html',
|
||||
searchUrl:'/search.asp?page=fypage&searchword=**&searchtype=-1',
|
||||
searchable:2,
|
||||
quickSearch:0,
|
||||
headers:{
|
||||
'User-Agent':'MOBILE_UA'
|
||||
},
|
||||
timeout:5000,
|
||||
// homeUrl:'/fenlei/',
|
||||
// class_parse: '.pd-class:eq(0) dd;a&&Text;a&&href;.*/(.*?).html',
|
||||
class_name:'网络玄幻&恐怖悬疑&传统武侠&都市言情&官场刑侦&历史军事&探险盗墓&职场商战&明朝那些事儿&评书下载&相声戏曲&人物传记&广播剧&百家讲坛&外语读物&有声文学&儿童读物&管理营销',
|
||||
class_url:'r52&r17&r12&r13&r14&r15&r45&r81&r36&r3&r7&r16&r18&r32&r35&r41&r4&r6',
|
||||
play_parse:true,
|
||||
lazy:'',
|
||||
limit:6,
|
||||
// double:true,
|
||||
推荐:'.list-ul .list-li;.list-name&&Text;*;.module-slide-author&&Text;*',
|
||||
一级:'.book-ol&&li;h4&&Text;img&&data-original;.book-meta&&Text;a&&href',
|
||||
二级:{
|
||||
// title:'h2&&Text;.book-cell .book-rand-a:eq(2)&&Text',
|
||||
title:'h1&&Text;.book-cell .book-rand-a:eq(0)&&a&&Text',
|
||||
img:'.book img&&src',
|
||||
// desc:';;;;.book-des p&&Text',
|
||||
desc:';;;.book-rand-a:eq(2)&&Text;.book-des p&&Text',
|
||||
content:'.book-des--p&&Text',
|
||||
tabs:'.playlist-top&&h2',
|
||||
// lists:'js:pd=jsp.pd;let url=pd(html,".bookbutton&&a&&href");log(url);html=request(url);let v=pd(html,".booksite&&script&&Html");var document={};var VideoListJson;VideoListJson=eval(v.split("VideoListJson=")[1].split(",urlinfo")[0]);log(typeof VideoListJson);let list1=VideoListJson[0][1];LISTS=[list1];log(LISTS);',
|
||||
// 有声小说有防盗链,我服了(上面的列表数据正常拿到了,没法播放)
|
||||
// lists:'#playlist:eq(#id)&&ul&&li',
|
||||
lists:'#playlist ul li',
|
||||
},
|
||||
搜索:'*',
|
||||
}
|
||||
Reference in New Issue
Block a user