pre.js 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. var VODS = [];
  2. var $ = {};
  3. if (!String.prototype.includes) {
  4. String.prototype.includes = function (search, start) {
  5. if (typeof start !== 'number') {
  6. start = 0;
  7. }
  8. if (start + search.length > this.length) {
  9. return false;
  10. } else {
  11. return this.indexOf(search, start) !== -1;
  12. }
  13. };
  14. }
  15. if (!Array.prototype.includes) {
  16. Object.defineProperty(Array.prototype, 'includes', {
  17. value: function (searchElement, fromIndex) {
  18. if (this == null) {//this是空或者未定义,抛出错误
  19. throw new TypeError('"this" is null or not defined');
  20. }
  21. var o = Object(this);//将this转变成对象
  22. var len = o.length >>> 0;//无符号右移0位,获取对象length属性,如果未定义就会变成0
  23. if (len === 0) {//length为0直接返回false未找到目标值
  24. return false;
  25. }
  26. var n = fromIndex | 0;//查找起始索引
  27. var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);//计算正确起始索引,因为有可能是负值
  28. while (k < len) {//从起始索引处开始循环
  29. if (o[k] === searchElement) {//如果某一位置与寻找目标相等,返回true,找到了
  30. return true;
  31. }
  32. k++;
  33. }
  34. return false;//未找到,返回false
  35. }
  36. });
  37. }
  38. if (typeof String.prototype.startsWith != 'function') {
  39. String.prototype.startsWith = function (prefix){
  40. return this.slice(0, prefix.length) === prefix;
  41. };
  42. }
  43. if (typeof String.prototype.endsWith != 'function') {
  44. String.prototype.endsWith = function(suffix) {
  45. return this.indexOf(suffix, this.length - suffix.length) !== -1;
  46. };
  47. }
  48. Object.assign = function () {
  49. var target = arguments[0];
  50. for (var i = 1; i < arguments.length; i++) {
  51. var source = arguments[i];
  52. for (var key in source) {
  53. if (Object.prototype.hasOwnProperty.call(source, key)) {
  54. target[key] = source[key];
  55. }
  56. }
  57. }
  58. return target;
  59. };
  60. Object.prototype.myValues=function(obj){
  61. if(obj ==null) {
  62. throw new TypeError("Cannot convert undefined or null to object");
  63. }
  64. var res=[]
  65. for(var k in obj){
  66. if(obj.hasOwnProperty(k)){//需判断是否是本身的属性
  67. res.push(obj[k]);
  68. }
  69. }
  70. return res;
  71. }
  72. if (typeof Object.prototype.values != 'function') {
  73. Object.prototype.values=function(obj){
  74. if(obj ==null) {
  75. throw new TypeError("Cannot convert undefined or null to object");
  76. }
  77. var res=[]
  78. for(var k in obj){
  79. if(obj.hasOwnProperty(k)){//需判断是否是本身的属性
  80. res.push(obj[k]);
  81. }
  82. }
  83. return res;
  84. }
  85. }
  86. Array.prototype.join = function (emoji) {
  87. // emoji = emoji||',';
  88. emoji = emoji||'';
  89. let self = this;
  90. let str = "";
  91. let i = 0;
  92. if (!Array.isArray(self)) {throw String(self)+'is not Array'}
  93. if(self.length===0){return ''}
  94. if (self.length === 1){return String(self[0])}
  95. i = 1;
  96. str = this[0];
  97. for (; i < self.length; i++) {
  98. str += String(emoji)+String(self[i]);
  99. }
  100. return str;
  101. };
  102. Array.prototype.append = Array.prototype.push;
  103. String.prototype.strip = String.prototype.trim;
  104. function 是否正版(vipUrl){
  105. 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');
  106. return flag.test(vipUrl);
  107. }
  108. function urlDeal(vipUrl){
  109. if(!vipUrl){
  110. return ''
  111. }
  112. if(!是否正版(vipUrl)){
  113. return vipUrl
  114. }
  115. if(!/miguvideo/.test(vipUrl)){
  116. vipUrl=vipUrl.split('#')[0].split('?')[0];
  117. }
  118. return vipUrl
  119. }
  120. function setResult(d){
  121. if(!Array.isArray(d)){
  122. return []
  123. }
  124. d.forEach(function (it){
  125. let obj = {
  126. vod_id:it.url||'',
  127. vod_name: it.title||'',
  128. vod_remarks: it.desc||'',
  129. vod_content: it.content||'',
  130. vod_pic: it.pic_url||it.img||'',
  131. };
  132. let keys = Object.keys(it);
  133. if(keys.includes('tname')){
  134. obj.type_name = it.tname||'';
  135. }
  136. if(keys.includes('tid')){
  137. obj.type_id = it.tid||'';
  138. }
  139. if(keys.includes('year')){
  140. obj.vod_year = it.year||'';
  141. }
  142. if(keys.includes('actor')){
  143. obj.vod_actor = it.actor||'';
  144. }
  145. if(keys.includes('director')){
  146. obj.vod_director = it.director||'';
  147. }
  148. if(keys.includes('area')){
  149. obj.vod_area = it.area||'';
  150. }
  151. VODS.push(obj);
  152. });
  153. return VODS
  154. }
  155. function setResult2(res){
  156. VODS = res.list||[];
  157. return VODS
  158. }
  159. function setHomeResult(res){
  160. if(!res||typeof(res)!=='object'){
  161. return []
  162. }
  163. return setResult(res.list);
  164. }
  165. // 千万不要用for in 推荐 forEach (for in 会打乱顺序)
  166. //猫函数
  167. function maoss(jxurl, ref, key) {
  168. eval(getCryptoJS());
  169. try {
  170. var getVideoInfo = function (text) {
  171. return CryptoJS.AES.decrypt(text, key, {iv: iv, padding: CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8);
  172. };
  173. var token_key = key == undefined ? 'dvyYRQlnPRCMdQSe' : key;
  174. if (ref) {
  175. var html = request(jxurl, {
  176. headers: {
  177. 'Referer': ref
  178. }
  179. });
  180. } else {
  181. var html = request(jxurl);
  182. }
  183. // print(html);
  184. if (html.indexOf('&btwaf=') != -1) {
  185. html = request(jxurl + '&btwaf' + html.match(/&btwaf(.*?)"/)[1], {
  186. headers: {
  187. 'Referer': ref
  188. }
  189. })
  190. }
  191. var token_iv = html.split('_token = "')[1].split('"')[0];
  192. var key = CryptoJS.enc.Utf8.parse(token_key);
  193. var iv = CryptoJS.enc.Utf8.parse(token_iv);
  194. // log("iv:"+iv);
  195. // log(html);
  196. // print(key);
  197. // print(iv);
  198. eval(html.match(/var config = {[\s\S]*?}/)[0] + '');
  199. // config.url = config.url.replace(/,/g,'');
  200. // print(config.url);
  201. if (!config.url.startsWith('http')) {
  202. //config.url = decodeURIComponent(AES(config.url, key, iv));
  203. config.url = CryptoJS.AES.decrypt(config.url, key, {
  204. iv: iv,
  205. padding: CryptoJS.pad.Pkcs7
  206. }).toString(CryptoJS.enc.Utf8)
  207. }
  208. return config.url;
  209. } catch (e) {
  210. return '';
  211. }
  212. }
  213. function request(url,obj){
  214. // obj = obj||{'user-agent': MOBILE_UA};
  215. let new_obj;
  216. if(typeof(fetch_params)!=='undefined'){
  217. new_obj = obj?Object.assign(fetch_params,obj):fetch_params;
  218. }else{
  219. new_obj = obj||{}
  220. }
  221. if(!new_obj||!new_obj.headers){
  222. new_obj.headers = {};
  223. }
  224. if(!new_obj.headers['User-Agent']&&!new_obj.headers['user-agent']){
  225. new_obj.headers['User-Agent'] = MOBILE_UA;
  226. }
  227. // delete new_obj.headers['Referer'];
  228. // print(obj);
  229. // print(new_obj);
  230. if(typeof(fetch)!==undefined){
  231. let html = fetch(url,new_obj);
  232. if (/\?btwaf=/.test(html)) {//宝塔验证
  233. url=url.split('#')[0]+'?btwaf'+html.match(/btwaf(.*?)\"/)[1];
  234. log("宝塔验证跳转到:"+url);
  235. html = fetch(url, new_obj);
  236. }
  237. return html
  238. }
  239. return ''
  240. }
  241. function rc(url){// 系统已经有require方法了,再覆盖的话无法操作了
  242. res = eval(requireObj(url));
  243. // print(res);
  244. return res;
  245. // return eval.call(null, requireObj(url));
  246. }
  247. $.require = rc;
  248. function urlencode (str) {
  249. str = (str + '').toString();
  250. return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
  251. replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
  252. }