海角社区解析

🚀目前最稳定的海角免费解析🚀

ของเมื่อวันที่ 29-08-2024 ดู เวอร์ชันล่าสุด

  1. // ==UserScript==
  2. // @name 海角社区解析
  3. // @namespace https://github.com/J-thinker/ai-movie
  4. // @version v1.0.5
  5. // @author ak-sky
  6. // @description 🚀目前最稳定的海角免费解析🚀
  7. // @homepage https://github.com/J-thinker/ai-movie
  8. // @supportURL https://github.com/J-thinker/ai-movie
  9. // @run-at document-idle
  10. // @match https://www.hjcx.org/*
  11. // @match https://hjcx.org/*
  12. // @match https://www.hjcx.cc/*
  13. // @match https://hjcx.cc/*
  14. // @match https://www.haijiao.com/*
  15. // @license MIT
  16. // ==/UserScript==
  17.  
  18. // 环境竞争真恶劣啊,不断被友商举报。
  19.  
  20.  
  21. // The competitive environment is really fierce, and we are constantly reported by our competitors.
  22.  
  23.  
  24. "use strict";
  25. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  26. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  27. return new (P || (P = Promise))(function (resolve, reject) {
  28. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  29. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  30. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  31. step((generator = generator.apply(thisArg, _arguments || [])).next());
  32. });
  33. };
  34. var __generator = (this && this.__generator) || function (thisArg, body) {
  35. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  36. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  37. function verb(n) { return function (v) { return step([n, v]); }; }
  38. function step(op) {
  39. if (f) throw new TypeError("Generator is already executing.");
  40. while (g && (g = 0, op[0] && (_ = 0)), _) try {
  41. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  42. if (y = 0, t) op = [op[0] & 2, t.value];
  43. switch (op[0]) {
  44. case 0: case 1: t = op; break;
  45. case 4: _.label++; return { value: op[1], done: false };
  46. case 5: _.label++; y = op[1]; op = [0]; continue;
  47. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  48. default:
  49. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  50. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  51. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  52. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  53. if (t[2]) _.ops.pop();
  54. _.trys.pop(); continue;
  55. }
  56. op = body.call(thisArg, _);
  57. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  58. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  59. }
  60. };
  61. var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
  62. if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
  63. if (ar || !(i in from)) {
  64. if (!ar) ar = Array.prototype.slice.call(from, 0, i);
  65. ar[i] = from[i];
  66. }
  67. }
  68. return to.concat(ar || Array.prototype.slice.call(from));
  69. };
  70. Object.defineProperty(exports, "__esModule", { value: true });
  71. exports.getImageBase64Src = exports.downloadFile = exports.getVideoListByType = exports.getVideoTypeMenu = exports.getAllLabels = exports.getVideoSearchResult = exports.loadVideo = exports.getAESConfig = exports.parseHlsURL = exports.getHlsText = exports.getVideoInfo = void 0;
  72. /// <reference path="mogu.d.ts" />
  73. var crypto_js_1 = require("crypto-js");
  74. var hls_js_1 = require("hls.js");
  75. var baseUrl = 'https://api.koudailc.net';
  76. /** 获取视频信息 */
  77. var getVideoInfo = function (videoId) { return __awaiter(void 0, void 0, void 0, function () {
  78. var params, data;
  79. return __generator(this, function (_a) {
  80. switch (_a.label) {
  81. case 0:
  82. params = new URLSearchParams([['id', videoId.toString()]]).toString();
  83. console.log(baseUrl + '/api/vod/info?' + params);
  84. return [4 /*yield*/, fetch(baseUrl + '/api/vod/info?' + params).then(function (res) { return res.json(); })];
  85. case 1:
  86. data = _a.sent();
  87. return [2 /*return*/, data.data];
  88. }
  89. });
  90. }); };
  91. exports.getVideoInfo = getVideoInfo;
  92. /** 获取视频 M3U8 字符串 */
  93. var getHlsText = function (videoUrl, videoId) { return __awaiter(void 0, void 0, void 0, function () {
  94. var data, encrypted, aesConfig, decrypted;
  95. return __generator(this, function (_a) {
  96. switch (_a.label) {
  97. case 0: return [4 /*yield*/, fetch(videoUrl).then(function (res) { return res.arrayBuffer(); })];
  98. case 1:
  99. data = _a.sent();
  100. encrypted = crypto_js_1.lib.WordArray.create(data);
  101. aesConfig = (0, exports.getAESConfig)(videoId);
  102. decrypted = crypto_js_1.AES.decrypt({ ciphertext: encrypted }, aesConfig.key, {
  103. iv: aesConfig.iv,
  104. padding: crypto_js_1.pad.Pkcs7,
  105. mode: crypto_js_1.mode.CBC
  106. });
  107. return [2 /*return*/, decrypted.toString(crypto_js_1.enc.Utf8)];
  108. }
  109. });
  110. }); };
  111. exports.getHlsText = getHlsText;
  112. /** 解密视频地址并返回可播放的 Hls URL */
  113. var parseHlsURL = function (videoUrl, videoId) { return __awaiter(void 0, void 0, void 0, function () {
  114. var hlsText, blob;
  115. return __generator(this, function (_a) {
  116. switch (_a.label) {
  117. case 0: return [4 /*yield*/, (0, exports.getHlsText)(videoUrl, videoId)];
  118. case 1:
  119. hlsText = _a.sent();
  120. blob = new Blob([hlsText], { type: 'text/plain' });
  121. return [2 /*return*/, URL.createObjectURL(blob)];
  122. }
  123. });
  124. }); };
  125. exports.parseHlsURL = parseHlsURL;
  126. /** 获取 AES 配置信息 */
  127. var getAESConfig = function (videoId) {
  128. var hash = (0, crypto_js_1.MD5)((0, crypto_js_1.SHA1)(videoId.toString()).toString(crypto_js_1.enc.Hex));
  129. return { key: hash, iv: hash };
  130. };
  131. exports.getAESConfig = getAESConfig;
  132. /** 将视频载入到视频元素 */
  133. var loadVideo = function (videoId, element) { return __awaiter(void 0, void 0, void 0, function () {
  134. var hls, videoInfo, hlsUrl;
  135. return __generator(this, function (_a) {
  136. switch (_a.label) {
  137. case 0:
  138. hls = new hls_js_1.default();
  139. return [4 /*yield*/, (0, exports.getVideoInfo)(videoId)];
  140. case 1:
  141. videoInfo = _a.sent();
  142. return [4 /*yield*/, (0, exports.parseHlsURL)(videoInfo.play_url, videoInfo.id)];
  143. case 2:
  144. hlsUrl = _a.sent();
  145. hls.loadSource(hlsUrl);
  146. hls.attachMedia(element);
  147. return [2 /*return*/];
  148. }
  149. });
  150. }); };
  151. exports.loadVideo = loadVideo;
  152. /**
  153. * 获取视频搜索结果
  154. * @param keyword 搜索关键词
  155. * @param page 页码,起始值为 1
  156. * @param pageSize 返回记录条数,最大值为 20
  157. * @returns 搜索结果
  158. */
  159. var getVideoSearchResult = function (keyword_1) {
  160. var args_1 = [];
  161. for (var _i = 1; _i < arguments.length; _i++) {
  162. args_1[_i - 1] = arguments[_i];
  163. }
  164. return __awaiter(void 0, __spreadArray([keyword_1], args_1, true), void 0, function (keyword, page, pageSize) {
  165. var params, data;
  166. if (page === void 0) { page = 1; }
  167. if (pageSize === void 0) { pageSize = 20; }
  168. return __generator(this, function (_a) {
  169. switch (_a.label) {
  170. case 0:
  171. params = new URLSearchParams([['limit', pageSize.toString()], ['page', page.toString()], ['wd', keyword]]).toString();
  172. return [4 /*yield*/, fetch(baseUrl + '/api/vod/clever?' + params).then(function (res) { return res.json(); })];
  173. case 1:
  174. data = _a.sent();
  175. return [2 /*return*/, data.data.list];
  176. }
  177. });
  178. });
  179. };
  180. exports.getVideoSearchResult = getVideoSearchResult;
  181. /** 获取所有的标签 */
  182. var getAllLabels = function () { return __awaiter(void 0, void 0, void 0, function () {
  183. var data;
  184. return __generator(this, function (_a) {
  185. switch (_a.label) {
  186. case 0: return [4 /*yield*/, fetch(baseUrl + '/api/vodlabel/all').then(function (res) { return res.json(); })];
  187. case 1:
  188. data = _a.sent();
  189. return [2 /*return*/, data.data.list];
  190. }
  191. });
  192. }); };
  193. exports.getAllLabels = getAllLabels;
  194. /** 获取视频分类菜单 */
  195. var getVideoTypeMenu = function () { return __awaiter(void 0, void 0, void 0, function () {
  196. var data;
  197. return __generator(this, function (_a) {
  198. switch (_a.label) {
  199. case 0: return [4 /*yield*/, fetch(baseUrl + '/api/vod/type').then(function (res) { return res.json(); })];
  200. case 1:
  201. data = _a.sent();
  202. return [2 /*return*/, data.data.list];
  203. }
  204. });
  205. }); };
  206. exports.getVideoTypeMenu = getVideoTypeMenu;
  207. /**
  208. * 获取分类视频列表
  209. * @param typeIds 分类 ID 列表
  210. * @param options 配置项
  211. * @returns 视频列表
  212. */
  213. var getVideoListByType = function (typeIds_1) {
  214. var args_1 = [];
  215. for (var _i = 1; _i < arguments.length; _i++) {
  216. args_1[_i - 1] = arguments[_i];
  217. }
  218. return __awaiter(void 0, __spreadArray([typeIds_1], args_1, true), void 0, function (typeIds, options) {
  219. var params, data;
  220. var _a;
  221. if (options === void 0) { options = {}; }
  222. return __generator(this, function (_b) {
  223. switch (_b.label) {
  224. case 0:
  225. params = new URLSearchParams([
  226. ['types', typeIds.join(',')],
  227. ['limit', ((_a = options.pageSize) !== null && _a !== void 0 ? _a : 20).toString()],
  228. ['page', (options.page || 1).toString()],
  229. ['order', '-' + (options.order || 'id')],
  230. ]).toString();
  231. return [4 /*yield*/, fetch(baseUrl + '/api/vod/list?' + params).then(function (res) { return res.json(); })];
  232. case 1:
  233. data = _b.sent();
  234. return [2 /*return*/, data.data.list];
  235. }
  236. });
  237. });
  238. };
  239. exports.getVideoListByType = getVideoListByType;
  240. /** 下载文件 */
  241. var downloadFile = function (objectURL, filename) {
  242. var link = document.createElement('a');
  243. link.href = objectURL;
  244. link.download = filename;
  245. link.click();
  246. link.remove();
  247. };
  248. exports.downloadFile = downloadFile;
  249. /** 获取图片的 Base64 格式 src */
  250. var getImageBase64Src = function (imageUrl) { return __awaiter(void 0, void 0, void 0, function () {
  251. var data, encrypted, imageId, key, iv, decrypted;
  252. return __generator(this, function (_a) {
  253. switch (_a.label) {
  254. case 0: return [4 /*yield*/, fetch(imageUrl).then(function (res) { return res.arrayBuffer(); })];
  255. case 1:
  256. data = _a.sent();
  257. encrypted = crypto_js_1.lib.WordArray.create(data);
  258. imageId = imageUrl.match(/([^/]+)\.[^/]+$/)[1];
  259. console.log(imageId);
  260. key = (0, crypto_js_1.MD5)(imageId);
  261. iv = key;
  262. decrypted = crypto_js_1.AES.decrypt({ ciphertext: encrypted }, key, {
  263. iv: iv,
  264. padding: crypto_js_1.pad.Pkcs7,
  265. mode: crypto_js_1.mode.CBC
  266. });
  267. return [2 /*return*/, 'data:image/jpeg;base64,' + decrypted.toString(crypto_js_1.enc.Base64)];
  268. }
  269. });
  270. }); };
  271. exports.getImageBase64Src = getImageBase64Src;