Greasy Fork镜像 支持简体中文。

U2历史记录

查看种子历史记录

目前為 2022-07-19 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name U2历史记录
  3. // @namespace https://u2.dmhy.org/
  4. // @version 0.4.3
  5. // @description 查看种子历史记录
  6. // @author kysdm
  7. // @grant none
  8. // @match *://u2.dmhy.org/details.php?id=*
  9. // @match *://u2.dmhy.org/offers.php?id=*
  10. // @match *://u2.dmhy.org/forums.php?action=viewtopic*
  11. // @icon https://u2.dmhy.org/favicon.ico
  12. // @require https://cdnjs.cloudflare.com/ajax/libs/localforage/1.10.0/localforage.min.js
  13. // @require https://unpkg.com/thenby@1.3.4/thenBy.min.js
  14. // @license Apache-2.0
  15. // ==/UserScript==
  16.  
  17. /*
  18. 本脚本基于 Bamboo Green 界面风格进行修改
  19. /*
  20.  
  21. /*
  22. GreasyFork 地址
  23. https://gf.qytechs.cn/zh-CN/scripts/428545
  24. */
  25.  
  26. /*
  27. 使用说明
  28. https://u2.dmhy.org/forums.php?action=viewtopic&topicid=13495&page=p150133#pid150133
  29. */
  30.  
  31. /*
  32. 更新日志
  33. https://github.com/kysdm/u2_share/commits/main/u2share_history.user.js
  34. */
  35.  
  36. 'use strict';
  37.  
  38. // 声明全局变量
  39. var lang, torrent_id, db, user_id, topicid, key, token;
  40.  
  41. (async () => {
  42. // 初始化
  43. lang = new lang_init($('#locale_selection').val()); // 获取当前网页语言
  44. torrent_id = location.href.match(/\.php\?id=(\d{3,5})/i) || ['', '']; if (torrent_id[1] !== '') torrent_id = torrent_id[1]; // 当前种子ID
  45. topicid = location.href.match(/topicid=(\d+)/i) || ['', '']; if (topicid[1] !== '') topicid = topicid[1];
  46. user_id = $('#info_block').find('a:first').attr('href').match(/\.php\?id=(\d{3,5})/i) || ['', '']; if (user_id[1] !== '') user_id = user_id[1]; // 当前用户ID
  47. db = localforage.createInstance({ name: "history" });
  48. // key = await db.getItem('key');
  49. token = await db.getItem('token');
  50. if (token === null || token.length !== 96) { new auth(); return; };
  51. if (/\/(offers|details)\.php\?id=\d{3,5}/i.test(location.href) && $('#outer').find('h2').text().match(/错误|錯誤|Ошибка|error/i)) { torrentInfoHistoryReset(); torrentCommentHistoryReset(); }// 为已经删除的种子显示历史
  52. else if (/\/offers\.php\?id=\d{3,5}/i.test(location.href) && !/(cmtpage|offer_vote|vote)=(1|p)/i.test(location.href) && /off_details=1/i.test(location.href)) { torrentInfoHistory(); torrentCommentHistory(); } // 为正常种子显示历史
  53. else if (/\/details\.php\?id=\d{3,5}/i.test(location.href) && !/(cmtpage|offer_vote|vote)=(1|p)/i.test(location.href)) { torrentInfoHistory(); torrentCommentHistory(); }
  54. else if (/\/(offers|details)\.php\?id=\d{3,5}/i.test(location.href) && /cmtpage=1/i.test(location.href)) { torrentCommentHistory(); } // 为正常种子显示历史 <仅评论>
  55. else if (/\/forums\.php\?action=viewtopic/i.test(location.href) && $('#outer').find('h2').text().match(/错误|錯誤|Ошибка|error/i)) { forumCommentHistoryReset(); } // 为被删除的论坛帖子显示历史
  56. else if (/\/forums\.php\?action=viewtopic/i.test(location.href)) { forumCommentHistory(); }; // 为论坛帖子显示历史
  57. })();
  58.  
  59. function auth() {
  60.  
  61. $('#outer').html(`<h1 align="center">U2种子历史记录 自动鉴权工具</h1>
  62. <table border="0" align="center" cellspacing="0" cellpadding="5">
  63. <tbody>
  64. <tr>
  65. <td valign="top" width="500" align="center"><span style="word-break: break-all; word-wrap: break-word;">
  66. <bdo dir="ltr">点击开始按钮,将自动进行鉴权,提示完成请刷新界面。<br>(建议手动备份下个人说明)<br></bdo></span></td>
  67. </tr>
  68. <tr>
  69. <td valign="top" align="left"><span style="word-break: break-all; word-wrap: break-word;">
  70. <bdo id="auth_log" dir="ltr"></bdo></span></td>
  71. </tr>
  72. <tr>
  73. <td align="center">
  74. <button id="auth_token" class="codebuttons" style="font-size:11px;margin-right:3px;" type="button">开始鉴权</button>
  75. <button id="auth_token_d" class="codebuttons" style="font-size:11px;margin-right:3px;" type="button">已有TOKEN</button>
  76. </td>
  77. </tr>
  78. </tbody>
  79. </table>`);
  80.  
  81. $("#auth_token_d").click(async function () {
  82. let __token = window.prompt("请输入Token"); // 弹窗提示输入Token
  83. if (__token === null || __token.length === 0) return; // 没有任何输入时 无视本次操作
  84. else if (__token.length !== 96) {
  85. await outPutLog(`Token: ${__token}`);
  86. await outPutLog(`Token长度不正确`);
  87. return;
  88. } // TOKEN长度不正确时 无视本次操作
  89. else {
  90. await db.setItem('token', __token);
  91. await outPutLog(`Token: ${__token}`);
  92. await outPutLog('鉴权结束');
  93. };
  94. });
  95.  
  96. function getProfile() {
  97. return new Promise(async (resolve, reject) => {
  98. $.ajax({
  99. type: 'get',
  100. url: 'https://u2.dmhy.org/usercp.php?action=personal',
  101. cache: false,
  102. success: async r => {
  103. const usercp = $.parseHTML(r)
  104. // const profile = $(usercp).find('[name="info"]').text(); // 获取用户信息
  105. const profile = {
  106. "action": "personal",
  107. "type": "save",
  108. "acceptpms": $(usercp).find('[name="acceptpms"]:checked').val(), // 接受以下短讯
  109. // 如果不需要开启对应功能,则不发送该参数
  110. "deletepms": $(usercp).find('[name="deletepms"]').is(':checked') ? 'on' : '', // 回复后删除短讯
  111. "savepms": $(usercp).find('[name="savepms"]').is(':checked') ? 'on' : '', // 保存短讯至发件箱
  112. "commentpm": $(usercp).find('[name="commentpm"]').is(':checked') ? 'yes' : '', // 我发布的种子有新评论时通知我
  113. "atpm": $(usercp).find('[name="atpm"]').is(':checked') ? '1' : '',// 有人在群聊区@我时通知
  114. "quotepm": $(usercp).find('[name="quotepm"]').is(':checked') ? '1' : '',// 有人在论坛、种子评论或候选评论引用我时通知。
  115. // 如果不需要开启对应功能,则不发送该参数
  116. "country": $(usercp).find('[name="country"]').val(), // 国家/地区
  117. "download": $(usercp).find('[name="download"]').val(),// 下行带宽
  118. "upload": $(usercp).find('[name="upload"]').val(),// 上行带宽
  119. "isp": $(usercp).find('[name="isp"]').val(),// 互联网服务提供商
  120. "savatar": $(usercp).find('[name="savatar"]').val(), // 选择头像
  121. "avatar": $(usercp).find('[name="avatar"]').val(), // 自定义头像
  122. "info": $(usercp).find('[name="info"]').text() // 个人说明
  123. };
  124. let profileAuth = { ...profile }; // 复制
  125. profileAuth.info = `-----BEGIN API KEY-----\n${key}\n-----END API KEY-----\n\n${profile.info}`; // 在个人说明加入鉴权信息
  126. const p = profileAuth.info.replace(/\r\n/g, () => { return '<br>' }).replace(/\n/g, () => { return '<br>' }).replace(/\r/g, () => { return '<br>' });
  127. await outPutLog(`请检查准备写入个人说明的BBCODE是否正确<br><br><table class="spoiler" width="100%">
  128. <tbody>
  129. <tr>
  130. <td class="colhead">个人说明&nbsp;&nbsp;<button class="spoiler-button-show" style="">检查一下</button>
  131. <button id="auth_profile_check" class="spoiler-button-hide" style="display: none;">检查完成</button></td>
  132. </tr>
  133. <tr>
  134. <td><span class="spoiler-content" style="display: none;">${p}</span></td>
  135. </tr>
  136. </tbody>
  137. </table>`);
  138. await db.setItem('profile', profile); // 存储用户信息
  139. $("#auth_profile_check").click(async function (ev) {
  140. $(this).hide();
  141. $(this).siblings(".spoiler-button-show").show();
  142. $(this).parentsUntil(".spoiler").find("span.spoiler-content:first").hide();
  143. ev.preventDefault();
  144. return resolve(profileAuth);
  145. });
  146. },
  147. error: async d => {
  148. await outPutLog('获取个人说明BBCODE失败');
  149. await outPutLog(`错误信息: ${d.responseText}`);
  150. return reject(Error(d.responseText));
  151. },
  152. });
  153. });
  154. };
  155.  
  156. function postProfile(data) {
  157. return new Promise(async (resolve, reject) => {
  158. $.ajax({
  159. type: 'post',
  160. url: 'https://u2.dmhy.org/usercp.php',
  161. cache: false,
  162. contentType: "application/x-www-form-urlencoded",
  163. data: data,
  164. success: async r => {
  165. await outPutLog('修改个人说明BBCODE成功');
  166. return resolve(key);
  167. },
  168. error: async d => {
  169. await outPutLog('修改个人说明BBCODE失败');
  170. await outPutLog(`错误信息: ${d.responseText}`);
  171. return reject(Error(d.responseText));
  172. },
  173. });
  174. });
  175. };
  176.  
  177. function getAuthKey() {
  178. return new Promise(async (resolve, reject) => {
  179. $.ajax({
  180. type: 'post',
  181. url: 'https://u2.kysdm.com/api/v1/token',
  182. contentType: "application/json",
  183. dataType: 'json',
  184. // async: false,
  185. data: JSON.stringify({ "uid": user_id }),
  186. success: async function (d) {
  187. if (d.msg === 'success') {
  188. key = d.data.key
  189. db.setItem('key', key);
  190. await outPutLog('获取Key成功');
  191. await outPutLog(`Key: ${key}`);
  192. return resolve(key);
  193. } else {
  194. await outPutLog('获取Key失败');
  195. await outPutLog(`错误信息: ${JSON.stringify(d)}`);
  196. return reject(Error('获取Key失败'));
  197. };
  198. },
  199. error: async function (d) {
  200. await outPutLog('获取Key失败');
  201. await outPutLog(`错误信息: ${d.responseText}`);
  202. return reject(Error('获取Key失败'));
  203. },
  204. });
  205. });
  206. };
  207.  
  208. function getToken() {
  209. return new Promise(async (resolve, reject) => {
  210. $.ajax({
  211. type: 'post',
  212. url: 'https://u2.kysdm.com/api/v1/token',
  213. contentType: "application/json",
  214. dataType: 'json',
  215. data: JSON.stringify({ "uid": user_id, "key": key }),
  216. success: async function (d) {
  217. if (d.msg === 'success') {
  218. let __token = d.data.token
  219. await outPutLog('获取Token成功');
  220. await outPutLog(`Token: ${__token}`);
  221. await db.setItem('token', __token);
  222. return resolve(__token);
  223. } else {
  224. await outPutLog('获取Token失败');
  225. await outPutLog(`错误信息: ${JSON.stringify(d)}`);
  226. return reject(Error('获取Token失败'));
  227. };
  228. },
  229. error: async function (d) {
  230. await outPutLog('获取Token失败');
  231. await outPutLog(`错误信息: ${d.responseText}`);
  232. return reject(Error('获取Token失败'));
  233. },
  234. });
  235. });
  236. };
  237.  
  238. function outPutLog(text) {
  239. return new Promise(async (resolve, reject) => {
  240. const log = $('#auth_log').html();
  241. $('#auth_log').html(`${log}${getDateString()} - ${text}<br>`);
  242. resolve(await sleep(0));
  243. });
  244. };
  245.  
  246. async function sleep(interval) {
  247. return new Promise(resolve => {
  248. setTimeout(resolve, interval);
  249. })
  250. };
  251.  
  252. $("#auth_token").click(async function () {
  253. await outPutLog('鉴权开始');
  254. await outPutLog('获取鉴权所需的Key');
  255. getAuthKey()
  256. .then(async () => {
  257. await outPutLog('获取个人说明BBCODE');
  258. return getProfile();
  259. })
  260. .then(async data => {
  261. await outPutLog('修改个人说明BBCODE');
  262. await postProfile(data);
  263. })
  264. .then(async () => {
  265. await outPutLog('获取鉴权所需的Token');
  266. await getToken();
  267. })
  268. .then(async () => {
  269. await outPutLog('还原个人说明BBCODE');
  270. await postProfile(await db.getItem('profile'));
  271. })
  272. .catch(async err => {
  273. await outPutLog(err);
  274. })
  275. .finally(async () => {
  276. await outPutLog('鉴权结束');
  277. });
  278. });
  279. };
  280.  
  281. async function forumCommentHistoryReset() {
  282. const errorstr = $('#outer').find('td.text').text();
  283. // 正在努力加载中...
  284. $('#outer').find('td.text').html(errorstr + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>' + lang['history_text_loading'] + '</i>');
  285.  
  286. $.ajax({
  287. type: 'post',
  288. url: 'https://u2.kysdm.com/api/v1/comment',
  289. contentType: "application/json",
  290. dataType: 'json',
  291. data: JSON.stringify({ "uid": user_id, "token": token, "topicid": topicid, "type": "forum" }),
  292. success: function (d) {
  293. if (d.msg === 'success') {
  294. console.log('获取论坛评论成功');
  295. let __comment = d.data.comment[topicid].sort(firstBy((a, b) => a.pid - b.pid).thenBy((a, b) => b.self - a.self)); // 如果用self排序,消息顺序不正确,则改用编辑日期排序
  296.  
  297. if (__comment.length === 0) { // 没有评论 可以说不会出现这种情况
  298. console.log('没有历史记录.');
  299. $('#outer').find('td.text').html(errorstr + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + lang['history_text_empty'] + '</i>');
  300. return;
  301. };
  302.  
  303. // 计算pid出现次数
  304. let pidList = __comment.map(x => x.pid);
  305. let counts = new Object();
  306. pidList.forEach(x => counts[x] = counts[x] ? counts[x] + 1 : 1);
  307. const pidListSet = [...new Set(pidList)]; // 去重
  308.  
  309. // 还原网页
  310. $('#outer').html(`
  311. <table class="main" width="940" border="0" cellspacing="0" cellpadding="0">
  312. <tbody>
  313. <tr>
  314. <td class="embedded" align="center">
  315. <h1 align="center"><span id="top"></span></h1><br><br>
  316. </td>
  317. </tr>
  318. </tbody>
  319. </table>
  320. <table class="main" width="940" border="0" cellspacing="0" cellpadding="0">
  321. <tbody>
  322. <tr>
  323. <td class="embedded">
  324. <table width="100%" border="1" cellspacing="0" cellpadding="10">
  325. <tbody>
  326. <tr>
  327. <td id="comments" class="text">
  328. </td>
  329. </tr>
  330. </tbody>
  331. </table>
  332. </td>
  333. </tr>
  334. </tbody>
  335. </table>`
  336. );
  337.  
  338. // 还原标题
  339. $('span[id="top"]').html(__comment[0]['topics']);
  340.  
  341. __comment.forEach(x => {
  342. const bbcode_html = `<div style="margin-top: 8pt; margin-bottom: 8pt;">
  343. <table id="pid${x.pid}" border="0" cellspacing="0" cellpadding="0" width="100%">
  344. <tbody>
  345. <tr>
  346. <td class="embedded" width="99%">
  347. <a href="forums.php?action=viewtopic&amp;topicid=${x.topicid}&amp;page=p${x.pid}#pid${x.pid}">#${x.pid}</a>
  348. <!-- 论坛应该不能匿名发帖吧 -->
  349. <span class="nowrap"><a href="userdetails.php?id=${x.userid}"><b>
  350. <bdo dir="ltr">${x.username}</bdo></b></a></span>&nbsp;
  351. <time>${x.edit_time.replace('T', ' ')}</time>
  352. </td>
  353. <td class="embedded nowrap" width="1%">
  354. <font class="big">#<b>${pidListSet.findIndex((a) => a == x.pid) + 1}</b> 楼&nbsp;&nbsp;</font>
  355. <a href="#top"><img class="top" src="pic/trans.gif" alt="Top" title="${lang['back_to_top']}"></a>&nbsp;&nbsp;
  356. </td>
  357. </tr>
  358. </tbody>
  359. </table>
  360. </div>
  361. <table class="main-inner" border="1" cellspacing="0" cellpadding="5">
  362. <tbody>
  363. <tr>
  364. <td class="rowfollow" width="150" valign="top" align="left" style="padding: 0px">
  365. <img src="//u2.dmhy.org/pic/default_avatar.png" alt="avatar" width="150px">
  366. </td>
  367. <td class="rowfollow" valign="top"><br>
  368. <div class="post-body" id="pid${x.pid}body">
  369. <span style="word-break: break-all; word-wrap: break-word;"><bdo dir="ltr">
  370. ${(() => {
  371. if (x.action === 'edit') {
  372. return `${bbcode2html(x.bbcode)}</bdo></span>
  373. ${(() => {
  374. if ($('#locale_selection').val() === 'en_US') return `<p class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> at <time>${x.edit_time.replace('T', ' ')}</time>.</p><br><br>`;
  375. else if ($('#locale_selection').val() === 'ru_RU') return `<p class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> в <time>${x.edit_time.replace('T', ' ')}</time>.</p><br><br>`;
  376. else return `<p class="small">[<time>${x.edit_time.replace('T', ' ')}</time>] <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> ${lang['last_edited']} </p><br><br>`;
  377. })()}`;
  378. } else {
  379. return `${bbcode2html(x.bbcode)}<br><br></bdo></span>`;
  380. };
  381. })()}
  382. </div>
  383. </td>
  384. </tr>
  385. </tbody>
  386. </table>`
  387.  
  388. if (counts[x.pid] > 1) {
  389. console.log('有编辑记录 直接添加下拉菜单');
  390. // 插入下拉菜单基本框架
  391. if ($(`#history_comment${x.pid}_select`).length === 0) {
  392. $('#comments').append(bbcode_html); // 先插入整体框架
  393. console.log('添加下拉菜单基本框架');
  394. $(`[id="pid${x.pid}"]`).find('td:last').before(`<td class="embedded nowrap" width="1%"><select name="type" id="history_comment${x.pid}_select" style="margin-top: 1px;"></select>&nbsp;&nbsp;</td>`);
  395.  
  396. };
  397. // 向下拉菜单写入信息
  398. $(`#history_comment${x.pid}_select`).append(`<option value="${x.self}">${x.edit_time.replace('T', ' ')}
  399. ${(() => { return x.action === 'edit' ? ' E' : x.action === 'reply' ? ' R' : ' N' })()}
  400. ${(() => { return x.username === null && x.userid === null ? lang['anonymous_user'] : ` ${x.username}(${x.userid})` })()}
  401. </option>`)
  402. } else {
  403. $('#comments').append(bbcode_html);
  404. };
  405. });
  406.  
  407. $("[id^=history_comment]").change(function () { // 监听菜单选择
  408. let self = $(this).val();
  409. for (let i = 0, len = __comment.length; i < len; i++) {
  410. if (self != __comment[i].self) continue;
  411. let html;
  412. let x = __comment[i];
  413. if (x.action === 'edit') {
  414. html = `<span style="word-break: break-all; word-wrap: break-word;"><bdo dir="ltr">${bbcode2html(x.bbcode)}</bdo></span>
  415. ${(() => {
  416. if ($('#locale_selection').val() === 'en_US') return `<p><font class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> at <time>${x.edit_time.replace('T', ' ')}</time>.</font></p>`;
  417. else if ($('#locale_selection').val() === 'ru_RU') return `<p><font class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> в <time>${x.edit_time.replace('T', ' ')}</time>.</font></p>`;
  418. else return `<br><p><font class="small">[<time>${x.edit_time.replace('T', ' ')}</time>] <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> ${lang['last_edited']} </font></p>`;
  419. })()}`;
  420. } else {
  421. html = `<span style="word-break: break-all; word-wrap: break-word;"><bdo dir="ltr">${bbcode2html(x.bbcode)}</bdo></span>`;
  422. };
  423. $(this).parents('[id^=pid]').parent().next().find('.post-body').html(html);
  424. return;
  425. };
  426. });
  427.  
  428. } else {
  429. console.log('获取论坛评论错误');
  430. $('#outer').find('td.text').html(`${errorstr}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>${lang['history_text_error']}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id="apifailure" href="javascript:void(0);" style="color:#FF1212">${lang['reset_token']}</a></i>`);
  431. $("#apifailure").click(function () {
  432. let confirm = prompt("输入 YES 确认本次操作 (大写)");
  433. if (confirm === 'YES') {
  434. db.removeItem('key');
  435. db.removeItem('token');
  436. alert("成功");
  437. };
  438. });
  439. };
  440. },
  441. error: function (d) {
  442.  
  443. },
  444. });
  445. };
  446.  
  447. async function forumCommentHistory() {
  448. db = localforage.createInstance({ name: "history" });
  449.  
  450. $.ajax({
  451. type: 'post',
  452. url: 'https://u2.kysdm.com/api/v1/comment',
  453. contentType: "application/json",
  454. dataType: 'json',
  455. data: JSON.stringify({ "uid": user_id, "token": token, "topicid": topicid, "type": "forum" }),
  456. success: async function (d) {
  457. if (d.msg === 'success') {
  458. console.log('获取论坛评论成功');
  459. let __comment = d.data.comment[topicid].sort((a, b) => b.self - a.self);
  460. let pid_list = __comment.map(x => x.pid);
  461. let counts = new Object();
  462. pid_list.forEach(x => counts[x] = counts[x] ? counts[x] + 1 : 1);
  463.  
  464. let pid_list_unique = Array.from(new Set(pid_list)).sort((a, b) => a - b); // 去重排序
  465. console.log(pid_list_unique);
  466. let p = $('#outer').find('p[align="center"]:first').text().replace(/\n/g, '<br>');
  467. let pg = /(?<p>\d+)<br>$/i.exec(p);
  468. let page_total = Number(pg.groups.p); // 有多少页评论
  469. let page_now = Number($('#outer').find('p:first').find('.gray b:last').text());
  470. console.log(`现在在评论第 ${page_now} | ${page_total}`);
  471. var pid_each = await db.getItem('forum_pid_each') || 0;; // 每页最大显示楼层数量 <当数据库没有值时,pid_list_valid会是空值,>
  472.  
  473. let em = /page=(?<pu>\d+|last)/i.exec(location.search);
  474. if ((!em && page_total > 1) || (em && page_total > Number(em.groups.pu) + 1)) {
  475. // 评论完整填满一个页面时,计算单个页面最大显示评论数量
  476. // 后期改动最大显示评论数量的数值后,直接进入帖子最后一页可能会出现不属于当前页面的评论
  477. pid_each = $('table[id^=pid]').length;
  478. await db.setItem('forum_pid_each', pid_each);
  479. };
  480.  
  481. var pid_list_valid = pid_list_unique.slice(pid_each * page_now - pid_each, pid_each * page_now); // 截取属于当前页面的PID
  482. console.log(pid_list_valid);
  483.  
  484. __comment.forEach(x => {
  485. let del_tag = 1;
  486. $('[id^="pid"]').each(function () {
  487. let pid = $(this).find('[class="embedded"]').children('a').first().text().replace('#', ''); // 获取网页上每个评论的PID
  488. if (x.pid == pid) {
  489. del_tag = 0; // 标记网页上有对应的PID
  490. if (counts[pid] > 1) {
  491. if ($(`#history_comment${pid}_select`).length === 0) $(this).find('td:last').before(`<td class="embedded nowrap" width="1%"><select name="type" id="history_comment${x.pid}_select" style="margin-top: 1px;"></select>&nbsp;&nbsp;</td>`);
  492. $(`#history_comment${pid}_select`).append(`<option value="${x.self}">${x.edit_time.replace('T', ' ')}
  493. ${(() => { return x.action === 'edit' ? ' E' : x.action === 'reply' ? ' R' : ' N' })()}
  494. ${(() => { return x.username === null && x.userid === null ? lang['anonymous_user'] : ` ${x.username}(${x.userid})` })()}
  495. </option>`);
  496. };
  497. };
  498. });
  499.  
  500. if (del_tag === 1) {
  501. // console.log(`${x.pid} | 被删除`);
  502. if (!pid_list_valid.includes(x.pid)) return; // 不属于当前页面的PID直接跳出
  503. // 只看该作者 启用时,仅还原改用户的记录
  504. let em = /authorid=(?<authorid>\d{1,5})/i.exec(location.search);
  505. if (em && x.userid != em.groups.authorid) return true;
  506.  
  507. if ($('[id="pid10000000000"]').length === 0) {
  508. $('[id="outer"]').find('td.text:first').append(
  509. `<div style="margin-top: 8pt; margin-bottom: 8pt; display:none;">
  510. <table id="pid10000000000" border="0" cellspacing="0" cellpadding="0" width="100%">
  511. <tbody>
  512. <tr>
  513. <td class="embedded" width="99%">
  514. <a href="javascript:void(0);">#10000000000</a>
  515. </td>
  516. </tr>
  517. </tbody>
  518. </table>
  519. </div>`
  520. );
  521. };
  522.  
  523. $('[id^="pid"]').each(function () {
  524. let pid = $(this).find('[class="embedded"]').children('a').first().text().replace('#', ''); // 获取网页上每个评论的PID
  525.  
  526. if (x.pid < Number(pid)) {
  527.  
  528. const bbcode_html = `<div style="margin-top: 8pt; margin-bottom: 8pt;">
  529. <table id="pid${x.pid}" border="0" cellspacing="0" cellpadding="0" width="100%">
  530. <tbody>
  531. <tr>
  532. <td class="embedded" width="99%">
  533. <a href="forums.php?action=viewtopic&amp;topicid=${x.topicid}&amp;page=p${x.pid}#pid${x.pid}">#${x.pid}</a>
  534. <!-- 论坛应该不能匿名发帖吧 -->
  535. <span class="nowrap">
  536. <a href="userdetails.php?id=${x.userid}"><b>
  537. <bdo dir="ltr">${x.username}</bdo></b></a></span>&nbsp;
  538. <time>${x.edit_time.replace('T', ' ')}</time>
  539. </td>
  540. <td class="embedded nowrap" width="1%">
  541. <a href="#top"><img class="top" src="pic/trans.gif" alt="Top" title="${lang['back_to_top']}"></a>&nbsp;&nbsp;
  542. </td>
  543. </tr>
  544. </tbody>
  545. </table>
  546. </div>
  547. <table class="main-inner" border="1" cellspacing="0" cellpadding="5">
  548. <tbody>
  549. <tr>
  550. <td class="rowfollow" width="150" valign="top" align="left" style="padding: 0px">
  551. <img src="//u2.dmhy.org/pic/default_avatar.png" alt="avatar" width="150px">
  552. </td>
  553. <td class="rowfollow" valign="top"><br>
  554. <div class="post-body" id="pid${x.pid}body">
  555. <span style="word-break: break-all; word-wrap: break-word;"><bdo dir="ltr">
  556. ${(() => {
  557. if (x.action === 'edit') {
  558. return `${bbcode2html(x.bbcode)}</bdo></span>
  559. ${(() => {
  560. if ($('#locale_selection').val() === 'en_US') return `<p class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> at <time>${x.edit_time.replace('T', ' ')}</time>.</p><br><br>`;
  561. else if ($('#locale_selection').val() === 'ru_RU') return `<p class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> в <time>${x.edit_time.replace('T', ' ')}</time>.</p><br><br>`;
  562. else return `<p class="small">[<time>${x.edit_time.replace('T', ' ')}</time>] <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> ${lang['last_edited']} </p><br><br>`;
  563. })()}`;
  564. } else {
  565. return `${bbcode2html(x.bbcode)}<br><br></bdo></span>`;
  566. };
  567. })()}
  568. </div>
  569. </td>
  570. </tr>
  571. </tbody>
  572. </table>`
  573.  
  574. $(`[id="pid${pid}"]`).parent().before(bbcode_html);
  575.  
  576. if (counts[x.pid] > 1) {
  577. if ($(`#history_comment${x.pid}_select`).length === 0) $(`[id="pid${x.pid}"]`).find('td:last').before(`<td class="embedded nowrap" width="1%"><select name="type" id="history_comment${x.pid}_select"></td>`);
  578. $(`#history_comment${x.pid}_select`).append(`<option value="${x.self}">${x.edit_time.replace('T', ' ')}
  579. ${(() => { return x.action === 'edit' ? ' E' : x.action === 'reply' ? ' R' : ' N' })()}
  580. ${(() => { return x.username === null && x.userid === null ? lang['anonymous_user'] : ` ${x.username}(${x.userid})` })()}
  581. </option>`);
  582. };
  583.  
  584. return false;
  585. };
  586. });
  587.  
  588. };
  589. });
  590.  
  591. $("[id^=history_comment]").change(function () { // 监听菜单选择
  592. let self = $(this).val();
  593. for (let i = 0, len = __comment.length; i < len; i++) {
  594. if (self != __comment[i].self) continue;
  595. let html;
  596. let x = __comment[i];
  597. if (x.action === 'edit') {
  598. html = `<span style="word-break: break-all; word-wrap: break-word;"><bdo dir="ltr">${bbcode2html(x.bbcode)}</bdo></span>
  599. ${(() => {
  600. if ($('#locale_selection').val() === 'en_US') return `<p><font class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> at <time>${x.edit_time.replace('T', ' ')}</time>.</font></p>`;
  601. else if ($('#locale_selection').val() === 'ru_RU') return `<p><font class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> в <time>${x.edit_time.replace('T', ' ')}</time>.</font></p>`;
  602. else return `<br><p><font class="small">[<time>${x.edit_time.replace('T', ' ')}</time>] <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> ${lang['last_edited']} </font></p>`;
  603. })()}`;
  604. } else {
  605. html = `<span style="word-break: break-all; word-wrap: break-word;"><bdo dir="ltr">${bbcode2html(x.bbcode)}</bdo></span>`;
  606. };
  607. $(this).parents('[id^=pid]').parent().next().find('.post-body').html(html);
  608. return;
  609. };
  610. });
  611. } else {
  612. console.log('获取论坛评论错误');
  613. };
  614. },
  615. error: function (d) {
  616.  
  617. },
  618. });
  619. };
  620.  
  621. async function torrentCommentHistory() {
  622. $.ajax({
  623. type: 'post',
  624. url: 'https://u2.kysdm.com/api/v1/comment',
  625. contentType: "application/json",
  626. dataType: 'json',
  627. data: JSON.stringify({ "uid": user_id, "token": token, "torrent_id": torrent_id, "type": "torrent" }),
  628. success: function (d) {
  629. if (d.msg === 'success') {
  630. console.log('获取种子评论成功');
  631. let __comment = d.data.comment[torrent_id].sort((a, b) => b.self - a.self);
  632. let cid_list = __comment.map(x => x.cid);
  633. let counts = new Object();
  634. cid_list.forEach(x => counts[x] = counts[x] ? counts[x] + 1 : 1);
  635.  
  636. // let startcomments = $('#startcomments').text();
  637. if ($('[id^="cid"]').length === 0) {
  638. // 候选没有评论 || 通过的种子没有评论
  639. console.log('完全没有评论');
  640. var cid_list_valid = Array.from(new Set(cid_list));
  641. } else {
  642. // 有评论
  643. let x = $('#startcomments').nextAll('p:first').text();
  644. let pg = /(?<p>\d+)$/i.exec(x);
  645. let page_total = Math.ceil(pg.groups.p / 10); // 有多少页评论
  646. let cid_list_unique = Array.from(new Set(cid_list)).sort((a, b) => a - b); // 去重排序
  647. console.log(cid_list_unique);
  648. let page_now = $('#startcomments').nextAll('p:first').find('.gray:last').text();
  649. pg = /(?<p>\d+)$/i.exec(page_now);
  650. for (let i = 1; i <= page_total; i++) {
  651. if (Number(pg.groups.p) <= 10 * i) {
  652. console.log(`现在在评论第 ${i} 页`);
  653. var cid_list_valid = cid_list_unique.slice(10 * i - 10, 10 * i); // 截取属于当前页面的评论
  654. console.log(cid_list_valid);
  655. break;
  656. };
  657. };
  658. };
  659.  
  660. __comment.forEach(x => {
  661. let del_tag = 1;
  662. $('[id^="cid"]').each(function () {
  663. let cid = $(this).find('[class="embedded"]').children('a').attr('name');
  664. if (x.cid == cid) {
  665. del_tag = 0; // 标记网页上有对应的CID
  666. if (x.cid == cid && counts[cid] > 1) {
  667. if ($(`#history_comment${cid}_select`).length === 0) $(this).find('td:last').before(`<td class="embedded nowrap" width="1%"><select name="type" id="history_comment${cid}_select" ></select>&nbsp;&nbsp;</td>`);
  668. $(`#history_comment${cid}_select`).append(`<option value="${x.self}">${x.edit_time.replace('T', ' ')}
  669. ${(() => { return x.action === 'edit' ? ' E' : x.action === 'reply' ? ' R' : ' N' })()}
  670. ${(() => { return x.username === null && x.userid === null ? lang['anonymous_user'] : ` ${x.username}(${x.userid})` })()}
  671. </option>`);
  672. };
  673. };
  674. });
  675.  
  676. if (del_tag === 1) {
  677. // console.log(`${x.cid} | 被删除`);
  678. if (!cid_list_valid.includes(x.cid)) return; // 不属于当前页面的评论直接跳出
  679. if ($('[id^="cid"]').length === 0) {
  680. // 所有评论都被删除
  681. console.log('所有评论都被删除');
  682. $('#outer').find('table:last').hide();
  683. $('#outer').find('table:last').prevAll('br').remove();
  684. $('#startcomments').remove();
  685. $('#outer').find('table:last').before('<br><h1 id="startcomments" align="center">用户评论</h1>');
  686. $('#outer').find('table:last').after(`<br>
  687. <table class="main" width="940" border="0" cellspacing="0" cellpadding="0">
  688. <tbody>
  689. <tr>
  690. <td class="embedded">
  691. <table width="100%" border="1" cellspacing="0" cellpadding="10">
  692. <tbody>
  693. <tr>
  694. <td class="text">
  695. <div style="margin-top: 8pt; margin-bottom: 8pt; display:none;">
  696. <table id="cid1000000000" border="0" cellspacing="0" cellpadding="0" width="100%">
  697. <tbody>
  698. <tr>
  699. <td class="embedded" width="99%">
  700. <a href="javascript:void(0);" name="1000000000">#1000000000</a>
  701. </td>
  702. </tr>
  703. </tbody>
  704. </table>
  705. </div>
  706. </td>
  707. </tr>
  708. </tbody>
  709. </table>
  710. </td>
  711. </tr>
  712. </tbody>
  713. </table>`
  714. );
  715. } else if ($('[id="cid1000000000"]').length === 0) {
  716. $('#startcomments').nextAll('table.main:first').find('.text').append(
  717. `<div style="margin-top: 8pt; margin-bottom: 8pt; display:none;">
  718. <table id="cid1000000000" border="0" cellspacing="0" cellpadding="0" width="100%">
  719. <tbody>
  720. <tr>
  721. <td class="embedded" width="99%">
  722. <a href="javascript:void(0);" name="1000000000">#1000000000</a>
  723. </td>
  724. </tr>
  725. </tbody>
  726. </table>
  727. </div>`);
  728. };
  729.  
  730. $('[id^="cid"]').each(function () {
  731. let cid = $(this).find('[class="embedded"]').children('a').attr('name'); // 获取网页上每个评论的CID
  732.  
  733. if (x.cid < Number(cid)) {
  734. if (x.userid === null && x.username === null) {
  735. var userInfo = `<span style="color: gray">&nbsp;<i>${lang['anonymous']}</i>&nbsp;</span>`
  736. } else {
  737. var userInfo = `<span style="color: gray">&nbsp;<span class="nowrap"><a href="userdetails.php?id=${x.userid}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span>`
  738. }
  739.  
  740. const bbcode_html = `<div style="margin-top: 8pt; margin-bottom: 8pt;">
  741. <table id="cid${x.cid}" border="0" cellspacing="0" cellpadding="0" width="100%">
  742. <tbody>
  743. <tr>
  744. <td class="embedded" width="99%">
  745. <a href="${cidUrl(x.torrent_id, x.cid)}" name="${x.cid}">#${x.cid}</a>
  746. ${userInfo}
  747. <span style="color: gray">&nbsp;<time>${x.edit_time.replace('T', ' ')}</time></span></span>
  748. </td>
  749. <td class="embedded nowrap" width="1%">
  750. <a href="#top"><img class="top" src="pic/trans.gif" alt="Top" title="Top"></a>&nbsp;&nbsp;
  751. </td>
  752. </tr>
  753. </tbody>
  754. </table>
  755. </div>
  756. <table class="main-inner" width="100%" border="0" cellspacing="0" cellpadding="5">
  757. <tbody>
  758. <tr>
  759. <td class="rowfollow" width="150" valign="top" style="padding: 0">
  760. <img src="//u2.dmhy.org/pic/default_avatar.png" alt="avatar" width="150px"></td>
  761. <td class="rowfollow" valign="top"><br>
  762. ${(() => {
  763. if (x.action === 'edit') {
  764. return `<span style="word-break: break-all; word-wrap: break-word;"><bdo dir="ltr">${bbcode2html(x.bbcode)}</bdo></span>
  765. ${(() => {
  766. if ($('#locale_selection').val() === 'en_US') return `<p class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> at <time>${x.edit_time.replace('T', ' ')}</time>.</p><br><br>`;
  767. else if ($('#locale_selection').val() === 'ru_RU') return `<p class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> в <time>${x.edit_time.replace('T', ' ')}</time>.</p><br><br>`;
  768. else return `<p class="small">[<time>${x.edit_time.replace('T', ' ')}</time>] <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> ${lang['last_edited']} </p><br><br>`;
  769. })()}`;
  770. } else {
  771. return `<span style="word-break: break-all; word-wrap: break-word;"><bdo dir="ltr">${bbcode2html(x.bbcode)}<br><br></bdo></span>`;
  772. };
  773. })()}
  774. </td>
  775. </tr>
  776. </tbody>
  777. </table>`;
  778.  
  779. $(`[id="cid${cid}"]`).parent().before(bbcode_html); // 先插入整体框架
  780.  
  781. if (counts[x.cid] > 1) {
  782. console.log('有编辑记录 直接添加下拉菜单');
  783. // 插入下拉菜单基本框架
  784. if ($(`#history_comment${x.cid}_select`).length === 0) {
  785. console.log('添加下拉菜单基本框架');
  786. $(`[id="cid${x.cid}"]`).find('td:last').before(`<td class="embedded nowrap" width="1%"><select name="type" id="history_comment${x.cid}_select" ></select>&nbsp;&nbsp;</td>`);
  787. };
  788. // 向下拉菜单写入信息
  789. $(`#history_comment${x.cid}_select`).append(`<option value="${x.self}">${x.edit_time.replace('T', ' ')}
  790. ${(() => { return x.action === 'edit' ? ' E' : x.action === 'reply' ? ' R' : ' N' })()}
  791. ${(() => { return x.username === null && x.userid === null ? lang['anonymous_user'] : ` ${x.username}(${x.userid})` })()}
  792. </option>`);
  793. };
  794.  
  795. return false;
  796. };
  797.  
  798. });
  799. };
  800.  
  801. });
  802.  
  803. $("[id^=history_comment]").change(function () { // 监听菜单选择
  804. let self = $(this).val();
  805.  
  806. for (let i = 0, len = __comment.length; i < len; i++) {
  807. if (self != __comment[i].self) continue;
  808. let html;
  809. let x = __comment[i];
  810. if (x.action === 'edit') {
  811. html = `<br>
  812. <span style="word-break: break-all; word-wrap: break-word;">
  813. <bdo dir="ltr">${bbcode2html(x.bbcode)}</bdo>
  814. </span>
  815. ${(() => {
  816. if ($('#locale_selection').val() === 'en_US') return `<p class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> at <time>${x.edit_time.replace('T', ' ')}</time>.</p>`;
  817. else if ($('#locale_selection').val() === 'ru_RU') return `<p class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> в <time>${x.edit_time.replace('T', ' ')}</time>.</p>`;
  818. else return `<br><p class="small">[<time>${x.edit_time.replace('T', ' ')}</time>] <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> ${lang['last_edited']} </p>`;
  819. })()}`;
  820.  
  821. } else {
  822. html = `<br>
  823. <span style="word-break: break-all; word-wrap: break-word;">
  824. <bdo dir="ltr">${bbcode2html(x.bbcode)}</bdo>
  825. </span>`;
  826. };
  827. $(this).parents('[id^=cid]').parent().next().find('[class="rowfollow"]:last').html(html);
  828. return;
  829. };
  830. });
  831.  
  832. } else {
  833. console.log('获取种子评论错误');
  834. };
  835. },
  836. error: function (d) {
  837.  
  838. },
  839. });
  840. };
  841.  
  842.  
  843. async function torrentInfoHistory() {
  844. if ($('h3').length === 1) { // 插入 select 基本框架
  845. const right = ($('#outer').width() - $('h3').next().width()) / 2 + 5; // 计算偏移量
  846. $('#top').after('<div id="hsty" style="position: relative;"><div id="history" style="position: absolute; right:' + right + 'px; margin-top: 4px;"><select name="type" id="history_select"></div></div>');
  847. $(window).resize(function () { $('#history').css("right", ($('#outer').width() - $('h3').next().width()) / 2 + 5); });
  848. } else {
  849. const right = ($('#outer').width() - $('#top').next().width()) / 2 + 5; // 计算偏移量
  850. $('#top').after('<div id="history" style="position: relative; float: right; margin-bottom: 10px; margin-right: ' + right + 'px"><select name="type" id="history_select"></div>');
  851. $(window).resize(function () { $('#history').css("margin-right", ($('#outer').width() - $('#history').next().width()) / 2 + 5 + 'px'); });
  852. };
  853.  
  854. $("#history_select").append("<option>" + lang['history_select_loading'] + "</option>");
  855.  
  856. const __json = await getapi(); // 从 API 获取数据
  857.  
  858. if (__json.msg !== 'success') { // 加载失败时
  859. console.log('获取历史记录失败.');
  860. $("#history_select").empty(); // 插入前先清空 option
  861. $("#history_select").append('<option value="80000">' + lang['history_select_error'] + '</option>'); // 希望你不要看到这个 (ノДT)
  862. $("#history_select").append(`<option value="90000">${lang['reset_token']}</option>`); // 删除本地授权信息
  863. $("#history_select").change(function () { // 监听菜单选择
  864. let self = Number($(this).val());
  865. if (self === 90000) {
  866. let confirm = prompt("输入 YES 确认本次操作 (大写)");
  867. if (confirm === 'YES') {
  868. db.removeItem('key');
  869. db.removeItem('token');
  870. $('#history_select').val(80000); // 将焦点设置到 80000
  871. $('#history_select').change(); // 手动触发列表更改事件
  872. alert("成功");
  873. } else {
  874. $('#history_select').val(80000); // 将焦点设置到 80000
  875. $('#history_select').change(); // 手动触发列表更改事件
  876. };
  877. };
  878. });
  879. return;
  880. };
  881.  
  882. console.log('获取历史记录成功.');
  883. let history_data = __json.data.history;
  884.  
  885. $("#history_select").empty(); // 插入前先清空 option
  886. for (let i = 0, len = history_data.length; i < len; i++) { // 循环插入到选择列表中
  887. $("#history_select").append("<option value='" + history_data[i].self + "'>"
  888. + history_data[i].get_time.replace('T', ' ')
  889. + (() => { return history_data[i].self === 0 ? ' N' : history_data[i].offer === 1 ? ' H' : ' T' })()
  890. + (() => {
  891. if (history_data[i].self === 0) return lang['current_time']
  892. else if (history_data[i].edited_name === null && history_data[i].edited_id === null) return ''
  893. else if (history_data[i].edited_name === 'Anonymous' && history_data[i].edited_id === null) return lang['anonymous_user']
  894. else if (history_data[i].edited_name !== null && history_data[i].edited_id !== null) return ' ' + history_data[i].edited_name + '(' + history_data[i].edited_id + ')'
  895. else return ' @BUG@'
  896. })()
  897. + "</option>");
  898. };
  899.  
  900. // 草 为什么会这样呢 明明原来很整齐的
  901. $("#history_select").change(function () { // 监听菜单选择
  902. let self = Number($(this).val());
  903. for (let i = 0, len = history_data.length; i < len; i++) {
  904. if (self !== history_data[i].self) continue;
  905. history_data[i].banned === 1 ? $('#top').html(history_data[i].title + '&nbsp;&nbsp;&nbsp; <b>[<font class="striking">' + lang['banned'] + '</font>]</b>') : $('#top').text(history_data[i].title);
  906. // 检查副标题一栏是否存在
  907. if ($("td[class='rowhead nowrap']:contains(" + lang['subtitle'] + ")").length === 0 && history_data[i].subtitle !== null) {
  908. $("td[class='rowhead nowrap']:contains(" + lang['uploaded'] + ")").parent().before('<tr><td class="rowhead nowrap" valign="top" align="right">' + lang['subtitle'] + '</td><td class="rowfollow" valign="top" align="left"></td></tr>');
  909. }
  910. else if ($("td[class='rowhead nowrap']:contains(" + lang['subtitle'] + ")").length === 1 && history_data[i].subtitle === null) {
  911. $("td[class='rowhead nowrap']:contains(" + lang['subtitle'] + ")").parent().remove();
  912. };
  913. $("td[class='rowhead nowrap']:contains(" + lang['subtitle'] + ")").next().text(history_data[i].subtitle); // 副标题
  914. $("td[class='rowhead nowrap']:contains(" + lang['description'] + ")").last().next().html('<span style="word-break: break-all; word-wrap: break-word;"><bdo dir="ltr">' + bbcode2html(history_data[i].description_info) + '</bdo></span>'); // 描述
  915. if ($('h3').length === 1) { // 已经通过候选的种子
  916. $("td[class='rowhead nowrap']:contains(" + lang['uploaded'] + ")").next().html(((p) => {
  917. if (p.uploader_id === null && p.uploader_name === '匿名') return '<i>' + lang['anonymous'] + '</i>'; // 匿名发布
  918. if (p.uploader_id === null && p.uploader_name !== '匿名') return p.uploader_name; // 自定义署名 不带UID
  919. if (p.uploader_id !== null && p.uploader_name !== '匿名') return '<a href="userdetails.php?id=' + p.uploader_id + '"><b>' + p.uploader_name + '</b></a>'; // 正常显示 || 自定义署名 带UID
  920. })(history_data[i])); // 发布人
  921. $("td[class='rowhead nowrap']:contains(" + lang['basic_info'] + ")").next().html('<b>' + lang['uploaded_at'] + ':</b> ' + history_data[i].uploaded_at.replace('T', ' ')
  922. + (() => { if (history_data[i].torrent_size) { return '&nbsp;&nbsp;&nbsp;<b>' + lang['size'] + ':</b>&nbsp;' + convert(history_data[i].torrent_size) } else { return ''; } })()
  923. + '&nbsp;&nbsp;&nbsp;<b>' + lang['category'] + ':</b> ' + history_data[i].category)
  924. } else { // 还在候选的种子
  925. $("td[class='rowhead nowrap']:contains(" + lang['basic_info'] + ")").next().html('<b>' + lang['submitted_by'] + '</b>:&nbsp;'
  926. + ((p) => {
  927. if (p.uploader_id === null && p.uploader_name === '匿名') return '<i>' + lang['anonymous'] + '</i>'; // 匿名发布
  928. if (p.uploader_id !== null && p.uploader_name !== '匿名') return '<a href="userdetails.php?id=' + p.uploader_id + '"><b>' + p.uploader_name + '</b></a>'; // 正常显示
  929. })(history_data[i])
  930. + '&nbsp;&nbsp;&nbsp;<b>' + lang['submitted_at'] + '</b>:&nbsp;<time>'
  931. + history_data[i].uploaded_at.replace('T', ' ')
  932. + '</time>&nbsp;&nbsp;&nbsp;<b>'
  933. + (() => { if (history_data[i].torrent_size) { return `${lang['size']}</b>:&nbsp;${convert(history_data[i].torrent_size)}&nbsp;&nbsp;&nbsp;<b>` } else { return ''; } })()
  934. + lang['category'] + '</b>:&nbsp;'
  935. + history_data[i].category
  936. );
  937. };
  938. };
  939. });
  940. };
  941.  
  942. async function torrentCommentHistoryReset() {
  943.  
  944. const callback = (mutations, observer) => {
  945. mutations.forEach(function (mutation) {
  946. if (mutation.addedNodes.length === 0) return;
  947.  
  948. console.log('检测到种子页面已经完成加载');
  949. observer.disconnect(); // 停止监听
  950.  
  951. $('#description').after(`<br><br><h1 align="center" id="startcomments" style="font-weight:normal; font-style: italic">正在加载用户评论...</h1><br>`);
  952. $.ajax({
  953. type: 'post',
  954. url: 'https://u2.kysdm.com/api/v1/comment',
  955. contentType: "application/json",
  956. dataType: 'json',
  957. data: JSON.stringify({ "uid": user_id, "token": token, "torrent_id": torrent_id, "type": "torrent" }),
  958. success: function (d) {
  959. if (d.msg !== 'success') { console.log('获取种子评论错误'); }
  960. else {
  961. console.log('获取种子评论成功');
  962. let __comment = d.data.comment[torrent_id].sort(firstBy((a, b) => a.cid - b.cid).thenBy((a, b) => b.self - a.self)); // 如果用self排序,消息顺序不正确,则改用编辑日期排序
  963. if (__comment.length === 0) { // 没有评论
  964. $('#startcomments').text('没有评论');
  965. $('#startcomments').removeAttr("style");
  966. return;
  967. } else {
  968. $('#startcomments').text('用户评论');
  969. $('#startcomments').removeAttr("style");
  970. };
  971.  
  972. let cidList = __comment.map(x => x.cid);
  973. let counts = new Object();
  974. cidList.forEach(x => counts[x] = counts[x] ? counts[x] + 1 : 1);
  975.  
  976. $('#startcomments').after(`<br>
  977. <table class="main" width="940" border="0" cellspacing="0" cellpadding="0">
  978. <tbody>
  979. <tr>
  980. <td class="embedded">
  981. <table width="100%" border="1" cellspacing="0" cellpadding="10">
  982. <tbody>
  983. <tr>
  984. <td id="comments" class="text"></td>
  985. </tr>
  986. </tbody>
  987. </table>
  988. </td>
  989. </tr>
  990. </tbody>
  991. </table>`
  992. );
  993.  
  994. __comment.forEach(x => {
  995. if (x.userid === null && x.username === null) {
  996. var userInfo = `<span style="color: gray">&nbsp;<i>${lang['anonymous']}</i>&nbsp;</span>`
  997. } else {
  998. var userInfo = `<span style="color: gray">&nbsp;<span class="nowrap"><a href="userdetails.php?id=${x.userid}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span>`
  999. }
  1000.  
  1001. const bbcode_html = `<div style="margin-top: 8pt; margin-bottom: 8pt;">
  1002. <table id="cid${x.cid}" border="0" cellspacing="0" cellpadding="0" width="100%">
  1003. <tbody>
  1004. <tr>
  1005. <td class="embedded" width="99%">
  1006. <a href="${cidUrl(x.torrent_id, x.cid)}" name="${x.cid}">#${x.cid}</a>
  1007. ${userInfo}
  1008. <span style="color: gray">&nbsp;<time>${x.edit_time.replace('T', ' ')}</time></span></span>
  1009. </td>
  1010. <td class="embedded nowrap" width="1%">
  1011. <a href="#top"><img class="top" src="pic/trans.gif" alt="Top" title="Top"></a>&nbsp;&nbsp;
  1012. </td>
  1013. </tr>
  1014. </tbody>
  1015. </table>
  1016. </div>
  1017. <table class="main-inner" width="100%" border="0" cellspacing="0" cellpadding="5">
  1018. <tbody>
  1019. <tr>
  1020. <td class="rowfollow" width="150" valign="top" style="padding: 0">
  1021. <img src="//u2.dmhy.org/pic/default_avatar.png" alt="avatar" width="150px"></td>
  1022. <td class="rowfollow" valign="top"><br>
  1023. ${(() => {
  1024. if (x.action === 'edit') {
  1025. return `<span style="word-break: break-all; word-wrap: break-word;"><bdo dir="ltr">${bbcode2html(x.bbcode)}</bdo></span>
  1026. ${(() => {
  1027. if ($('#locale_selection').val() === 'en_US') return `<p class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> at <time>${x.edit_time.replace('T', ' ')}</time>.</p><br><br>`;
  1028. else if ($('#locale_selection').val() === 'ru_RU') return `<p class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> в <time>${x.edit_time.replace('T', ' ')}</time>.</p><br><br>`;
  1029. else return `<p class="small">[<time>${x.edit_time.replace('T', ' ')}</time>] <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> ${lang['last_edited']} </p><br><br>`;
  1030. })()}`;
  1031. } else {
  1032. return `<span style="word-break: break-all; word-wrap: break-word;"><bdo dir="ltr">${bbcode2html(x.bbcode)}<br><br></bdo></span>`;
  1033. };
  1034. })()}
  1035. </td>
  1036. </tr>
  1037. </tbody>
  1038. </table>`;
  1039.  
  1040. if (counts[x.cid] > 1) {
  1041. console.log('有编辑记录 直接添加下拉菜单');
  1042. // 插入下拉菜单基本框架
  1043. if ($(`#history_comment${x.cid}_select`).length === 0) {
  1044. $('#comments').append(bbcode_html); // 先插入整体框架
  1045. console.log('添加下拉菜单基本框架');
  1046. $(`[id="cid${x.cid}"]`).find('[class="embedded nowrap"]').before(`<div id="hsty" style="position: relative;">
  1047. <div id="history_comment" style="position: absolute; right:10px; margin-top: -2px;">
  1048. <select name="type" id="history_comment${x.cid}_select">
  1049. </div>
  1050. </div>`);
  1051. };
  1052. // 向下拉菜单写入信息
  1053. $(`#history_comment${x.cid}_select`).append(`<option value="${x.self}">${x.edit_time.replace('T', ' ')}
  1054. ${(() => { return x.action === 'edit' ? ' E' : x.action === 'reply' ? ' R' : ' N' })()}
  1055. ${(() => { return x.username === null && x.userid === null ? lang['anonymous_user'] : ` ${x.username}(${x.userid})` })()}
  1056. </option>`)
  1057. } else {
  1058. $('#comments').append(bbcode_html);
  1059. };
  1060. });
  1061.  
  1062. $("[id^=history_comment]").change(function () { // 监听菜单选择
  1063. let self = $(this).val();
  1064. for (let i = 0, len = __comment.length; i < len; i++) {
  1065. if (self != __comment[i].self) continue;
  1066. let html;
  1067. let x = __comment[i];
  1068. if (x.action === 'edit') {
  1069. html = `<br>
  1070. <span style="word-break: break-all; word-wrap: break-word;">
  1071. <bdo dir="ltr">${bbcode2html(x.bbcode)}</bdo>
  1072. </span>
  1073. ${(() => {
  1074. if ($('#locale_selection').val() === 'en_US') return `<p class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> at <time>${x.edit_time.replace('T', ' ')}</time>.</p><br><br>`;
  1075. else if ($('#locale_selection').val() === 'ru_RU') return `<p class="small">${lang['last_edited']} <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> в <time>${x.edit_time.replace('T', ' ')}</time>.</p><br><br>`;
  1076. else return `<br><p class="small">[<time>${x.edit_time.replace('T', ' ')}</time>] <span class="nowrap"><a href="userdetails.php?id=${x.user_id}"><b><bdo dir="ltr">${x.username}</bdo></b></a></span> ${lang['last_edited']} </p><br><br>`;
  1077. })()}`;
  1078. } else {
  1079. html = `<br>
  1080. <span style="word-break: break-all; word-wrap: break-word;">
  1081. <bdo dir="ltr">${bbcode2html(x.bbcode)}<br><br></bdo>
  1082. </span>`;
  1083. };
  1084. $(this).parents('[id^=cid]').parent().next().find('[class="rowfollow"]:last').html(html);
  1085. return;
  1086. };
  1087. });
  1088. };
  1089. },
  1090. error: function (d) {
  1091. },
  1092. });
  1093. })
  1094. };
  1095.  
  1096. const MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
  1097. const element = document.getElementById("outer");
  1098. var observer = new MutationObserver(callback);
  1099. observer.observe(element, { childList: true });
  1100. };
  1101.  
  1102. async function torrentInfoHistoryReset() {
  1103. const errorstr = $('#outer').find('td.text').text();
  1104. // 正在努力加载中...
  1105. $('#outer').find('td.text').html(errorstr + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>' + lang['history_text_loading'] + '</i>');
  1106.  
  1107. const __json = await getapi(); // 从 API 获取数据
  1108.  
  1109. if (__json.msg !== 'success') { // 加载失败时
  1110. console.log('获取历史记录失败.');
  1111. $('#outer').find('td.text').html(`${errorstr}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<i>${lang['history_text_error']}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a id="apifailure" href="javascript:void(0);" style="color:#FF1212">${lang['reset_token']}</a></i>`);
  1112. $("#apifailure").click(function () {
  1113. let confirm = prompt("输入 YES 确认本次操作 (大写)");
  1114. if (confirm === 'YES') {
  1115. db.removeItem('key');
  1116. db.removeItem('token');
  1117. alert("成功");
  1118. };
  1119. });
  1120.  
  1121. return;
  1122. } else if (__json.data.history.length === 0) { // 获取成功 但没有历史记录时
  1123. console.log('没有历史记录.');
  1124. $('#outer').find('td.text').html(errorstr + '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' + lang['history_text_empty'] + '</i>');
  1125. return;
  1126. };
  1127.  
  1128. console.log('获取历史记录成功.');
  1129. let history_data = __json.data.history;
  1130. // let gdListObj = JSON.parse(localStorage.getItem("u2_gd_list")); // 读取谷歌备份列表
  1131. // 还原网页
  1132. $('#outer').html('<h1 align="center" id="top">'
  1133. + (() => { return history_data[0].banned === 1 ? history_data[0].title + '&nbsp;&nbsp;&nbsp; <b>[<font class="striking">' + lang['banned'] + '</font>]</b>' : history_data[0].title; })()
  1134. + '</h1>'
  1135. + '<div id="hsty" style="position: relative;"><div id="history" style="position: absolute; right:75px; margin-top: 4px;">'
  1136. + '<select name="type" id="history_select" style="visibility: visible;"></select></div></div>'
  1137. + '<h3>(#' + torrent_id + ')</h3>'
  1138. + '<table id="description" width="90%" min-width="940px" cellspacing="0" cellpadding="5"><tbody><tr><td class="rowhead" width="13%">' + lang['torrent_title'] + '</td>'
  1139. + '<td class="rowfollow" width="87%" align="left">'
  1140. + '<b>[U2].' + history_data[0].torrent_name + '.torrent</b></td></tr>'
  1141. + (() => { return history_data[0].subtitle ? '<tr><td class="rowhead nowrap" valign="top" align="right">' + lang['subtitle'] + '</td><td class="rowfollow" valign="top" align="left">' + history_data[0].subtitle + '</td></tr></td></tr>' : '' })()
  1142. + '<tr><td class="rowhead nowrap" valign="top" align="right">' + lang['basic_info'] + '</td>'
  1143. + '<td class="rowfollow" valign="top" align="left"><b>' + lang['submitted_by'] + '</b>:&nbsp;'
  1144. + ((p) => {
  1145. if (p.uploader_id === null && p.uploader_name === '匿名') return '<i>' + lang['anonymous'] + '</i>'; // 匿名发布
  1146. if (p.uploader_id !== null && p.uploader_name !== '匿名') return '<a href="userdetails.php?id=' + p.uploader_id + '"><b>' + p.uploader_name + '</b></a>'; // 正常显示
  1147. })(history_data[0])
  1148. + '&nbsp;&nbsp;&nbsp;<b>' + lang['submitted_at'] + '</b>:&nbsp;<time>' + history_data[0].uploaded_at.replace('T', ' ')
  1149. + '</time>'
  1150. + (() => { if (history_data[0].torrent_size) { return '&nbsp;&nbsp;&nbsp;<b>大小:</b>&nbsp;' + convert(history_data[0].torrent_size) } else { return ''; } })()
  1151. + '&nbsp;&nbsp;&nbsp;<b>' + lang['category'] + '</b>:&nbsp;' + history_data[0].category
  1152. // + (() => {
  1153. // const r = '&nbsp;&nbsp;&nbsp;<b>' + lang['google_backup'] + '</b>:&nbsp;'
  1154. // if (gdListObj === null) return ``; // 列表不存在时,直接返回
  1155. // const gdList = gdListObj.list; // 载入种子列表
  1156. // let d = gdList.findIndex((value) => value == Number(torrent_id)); // 查找数据库中是否有备份,没有返回-1
  1157. // if (d === -1) return r + `×`; // 没有备份时
  1158. // return `${r}<a href="sendmessage.php?receiver=45940#${torrent_id}" target="_blank" title="${lang['google_send']}">√</a>`
  1159. // })()
  1160. + '</td></tr>'
  1161. + '<tr><td class="rowhead nowrap" valign="top" align="right">'
  1162. + '<a href="javascript: klappe_news(\'descr\')"><span class="nowrap">'
  1163. + '<img class="minus" src="pic/trans.gif" alt="Show/Hide" id="picdescr" title="' + lang['show_or_hide'] + '"> ' + lang['description'] + '</span></a></td>'
  1164. + '<td class="rowfollow" valign="top" align="left">'
  1165. + '<div id="kdescr"><span style="word-break: break-all; word-wrap: break-word;"><bdo dir="ltr">'
  1166. + bbcode2html(history_data[0].description_info) + '</bdo></span></div></td></tr><tr>'
  1167. + '<td class="rowhead nowrap" valign="top" align="right">' + lang['torrent_info'] + '</td>'
  1168. + `<td id="file_tree" class="rowfollow" valign="top" align="left"></td></tr></tbody></table></td></tr></tbody></table><br><br></br>`
  1169. );
  1170.  
  1171. const putFileTree = (__json) => {
  1172. // 插入ID
  1173. let counter = 0;
  1174. const InsertSeq = (data) => {
  1175. for (key in data) {
  1176. data[key]['id'] = counter;
  1177. counter++;
  1178. if (data[key]['type'] == 'directory') InsertSeq(data[key]['children']);
  1179. };
  1180. return data;
  1181. };
  1182. // 获取文件ID
  1183. const getFile = (data) => {
  1184. let a = []
  1185. for (key in data) {
  1186. if (data[key]['type'] == 'file') a.push(data[key]['id']);
  1187. };
  1188. a = a.concat(getDirectory(data));
  1189. return a;
  1190. };
  1191. // 获取文件夹ID
  1192. const getDirectory = (data, directory = []) => {
  1193. for (key in data) {
  1194. if (data[key]['type'] == 'directory') directory.push(data[key]['id']);
  1195. };
  1196. return directory;
  1197. };
  1198. // 获取文件体积
  1199. const getSize = (data, size = 0) => {
  1200. // console.log(data);
  1201. for (key in data) {
  1202. if (data[key]['type'] == 'file') {
  1203. size = size + data[key]['length'];
  1204. } else {
  1205. size = getSize(data[key]['children'], size);
  1206. };
  1207. }
  1208. return size;
  1209. };
  1210. // 遍历JSON
  1211. const tree = (j, i) => {
  1212. for (let key in j) {
  1213. // console.log(j);
  1214. // console.log(j['key']);
  1215. if (j[key]['type'] == 'directory') {
  1216. let children = j[key]['children'];
  1217. let f_id_sh = getFile(children); // 获取文件夹需要的id
  1218. let f_size = convert(getSize(children)) // 文件夹大小
  1219. if (f_id === 0) {
  1220. f_html = f_html + `<tr id="f_id_0" tag="closed"><td class="rowfollow"><a href="javascript:void(0)" onclick="showorhide([${f_id_sh}],0)" class="faqlink">${key}</a></td><td class="rowfollow dir_size" align="right">[${f_size}]</td></tr>`;
  1221. } else {
  1222. f_html = f_html + `<tr id="f_id_${f_id}" style="display: none;" tag="closed"><td class="rowfollow">${space.repeat(i)}<a href="javascript:void(0)" onclick="showorhide([${f_id_sh}],${f_id})" class="faqlink">${key}</a></td><td class="rowfollow dir_size" align="right">[${f_size}]</td></tr>`;
  1223. };
  1224. f_id++;
  1225. tree(children, i + 1);
  1226. }
  1227. else {
  1228. if (f_id === 0) {
  1229. // 单文件种子
  1230. f_html = f_html + `<tr id="f_id_${f_id}"><td class="rowfollow">${space.repeat(i)}${key}</td><td class="rowfollow" align="right">${convert(j[key]['length'])}</td></tr>`;
  1231. } else {
  1232. f_html = f_html + `<tr id="f_id_${f_id}" style="display: none;"><td class="rowfollow">${space.repeat(i)}${key}</td><td class="rowfollow" align="right">${convert(j[key]['length'])}</td></tr>`;
  1233. };
  1234. f_id++;
  1235. };
  1236. };
  1237. };
  1238.  
  1239. // let __json = history_data[0].torrent_tree;
  1240. if (__json === null) {
  1241. // console.log('tree 为空');
  1242. $('#file_tree').html(
  1243. `<table>
  1244. <tbody>
  1245. <tr>
  1246. <td class="no_border_wide"><b>${lang['files']}</b>: ${history_data[0].torrent_files_qty}<br></td>
  1247. <td class="no_border_wide"><b>${lang['info_hash']}:</b>&nbsp;${history_data[0].torrent_hash}</td>
  1248. </tr>
  1249. </tbody>
  1250. </table>`
  1251. );
  1252. return;
  1253. };
  1254. __json = stringify(__json, function (a, b) {
  1255. // 对keys排序
  1256. if (typeof (a.value) !== 'object' || typeof (b.value) !== 'object') return 0;
  1257. if (a.value.type === 'directory' && b.value.type === 'file') {
  1258. return -1;
  1259. } else if (a.value.type === 'file' && b.value.type === 'directory') {
  1260. return 1;
  1261. } else {
  1262. return a.key.toLowerCase() < b.key.toLowerCase() ? -1 : 1;
  1263. };
  1264. });
  1265. __json = JSON.parse(__json);
  1266. __json = InsertSeq(__json);
  1267. // console.log(__json);
  1268. let f_id = 0; // 元素id
  1269. let f_html = ''; // 文件列表
  1270. const space = '&nbsp;&nbsp;&nbsp;&nbsp;'; // 缩进
  1271. tree(__json, 0);
  1272. // $('#filelist').find('tr').after(f_html);
  1273. $('#file_tree').html(
  1274. `<table>
  1275. <tbody>
  1276. <tr>
  1277. <td class="no_border_wide"><b>${lang['files']}</b>: ${history_data[0].torrent_files_qty}<br>
  1278. <span id="showfl" style="display: inline;">
  1279. <a href="javascript: viewfilelist()">[查看列表]</a>
  1280. </span>
  1281. <span id="hidefl" style="display: none;">
  1282. <a href="javascript: hidefilelist()">[隐藏列表]</a>
  1283. </span>
  1284. ${(() => {
  1285. return f_id > 1
  1286. ? `<span id="expandall" style="display: none;"><a href="javascript: expandall(true)">[全部展开]</a></span>
  1287. <span id="closeall" style="display: none;"><a href="javascript: expandall(false)">[全部关闭]</a></span>`
  1288. : ''
  1289. })()}
  1290. </td>
  1291. <td class="no_border_wide"><b>${lang['info_hash']}:</b>&nbsp;${history_data[0].torrent_hash}</td>
  1292. </tr>
  1293. </tbody>
  1294. </table>
  1295. <span id="filelist" style="display: none;">
  1296. <style>
  1297. .dir_size {
  1298. color: gray;
  1299. white-space: nowrap;
  1300. }
  1301. </style>
  1302. <table border="1" cellspacing="0" cellpadding="5">
  1303. <tbody>
  1304. <tr>
  1305. <td class="colhead">路径</td>
  1306. <td class="colhead" align="center"><img class="size" src="pic/trans.gif" alt="size"></td>
  1307. </tr>
  1308. ${f_html}
  1309. </tbody>
  1310. </table>
  1311. </span>`
  1312. );
  1313. };
  1314. putFileTree(history_data[0].torrent_tree); // 运行一次,生成列表
  1315.  
  1316. for (let i = 0, len = history_data.length; i < len; i++) { // 循环插入到选择列表中
  1317. $("#history_select").append("<option value='" + history_data[i].self + "'>"
  1318. + history_data[i].get_time.replace('T', ' ')
  1319. + (() => { return history_data[i].self === 0 ? ' N' : history_data[i].offer === 1 ? ' H' : ' T' })()
  1320. + (() => {
  1321. if (history_data[i].self === 0) return lang['current_time']
  1322. else if (history_data[i].edited_name === null && history_data[i].edited_id === null) return ''
  1323. else if (history_data[i].edited_name === 'Anonymous' && history_data[i].edited_id === null) return lang['anonymous_user']
  1324. else if (history_data[i].edited_name !== null && history_data[i].edited_id !== null) return ' ' + history_data[i].edited_name + '(' + history_data[i].edited_id + ')'
  1325. else return ' @BUG@'
  1326. })()
  1327. + "</option>");
  1328. };
  1329.  
  1330. $("#history_select").change(function () { // 监听菜单选择
  1331. let self = Number($(this).val());
  1332. for (let i = 0, len = history_data.length; i < len; i++) {
  1333. if (self !== history_data[i].self) continue;
  1334. history_data[i].banned === 1 ? $('#top').html(history_data[i].title + '&nbsp;&nbsp;&nbsp; <b>[<font class="striking">' + lang['banned'] + '</font>]</b>') : $('#top').text(history_data[i].title);
  1335. // 检查副标题一栏是否存在
  1336. if ($("td[class='rowhead nowrap']:contains(" + lang['subtitle'] + ")").length === 0 && history_data[i].subtitle !== null) {
  1337. $("td[class='rowhead nowrap']:contains(" + lang['uploaded'] + ")").parent().before('<tr><td class="rowhead nowrap" valign="top" align="right">' + lang['subtitle'] + '</td><td class="rowfollow" valign="top" align="left"></td></tr>');
  1338. }
  1339. else if ($("td[class='rowhead nowrap']:contains(" + lang['subtitle'] + ")").length === 1 && history_data[i].subtitle === null) {
  1340. $("td[class='rowhead nowrap']:contains(" + lang['subtitle'] + ")").parent().remove();
  1341. };
  1342. $("td[class='rowhead nowrap']:contains(" + lang['subtitle'] + ")").next().text(history_data[i].subtitle); // 副标题
  1343. $("td[class='rowhead nowrap']:contains(" + lang['description'] + ")").last().next().html('<span style="word-break: break-all; word-wrap: break-word;"><bdo dir="ltr">' + bbcode2html(history_data[i].description_info) + '</bdo></span>'); // 描述
  1344. $("td[class='rowhead nowrap']:contains(" + lang['basic_info'] + ")").next().html('<b>' + lang['submitted_by'] + '</b>:&nbsp;'
  1345. + ((p) => {
  1346. if (p.uploader_id === null && p.uploader_name === '匿名') return '<i>' + lang['anonymous'] + '</i>'; // 匿名发布
  1347. if (p.uploader_id !== null && p.uploader_name !== '匿名') return '<a href="userdetails.php?id=' + p.uploader_id + '"><b>' + p.uploader_name + '</b></a>'; // 正常显示
  1348. })(history_data[i])
  1349. + '&nbsp;&nbsp;&nbsp;<b>' + lang['submitted_at'] + '</b>:&nbsp;<time>' + history_data[i].uploaded_at.replace('T', ' ')
  1350. + '</time>'
  1351. + (() => { if (history_data[i].torrent_size) { return '&nbsp;&nbsp;&nbsp;<b>' + lang['size'] + ':</b>&nbsp;' + convert(history_data[i].torrent_size) } else { return ''; } })()
  1352. + '&nbsp;&nbsp;&nbsp;<b>' + lang['category'] + '</b>:&nbsp;' + history_data[i].category
  1353. );
  1354. putFileTree(history_data[i].torrent_tree);
  1355. };
  1356. });
  1357. };
  1358.  
  1359.  
  1360. function bbcode2html(bbcodestr) {
  1361. const f_reg = new RegExp("^\"?\"?$|^(?:&quot;)?(?:&quot;)?$");
  1362.  
  1363. var tempCode = new Array();
  1364. var tempCodeCount = 0;
  1365.  
  1366. function addTempCode(value) {
  1367. tempCode[tempCodeCount] = value;
  1368. let returnstr = "<tempCode_" + tempCodeCount + ">";
  1369. tempCodeCount++;
  1370. return returnstr;
  1371. }
  1372.  
  1373. const escape_reg = new RegExp("[&\"\'<>]", "g");
  1374. bbcodestr = bbcodestr.replace(escape_reg, function (s, x) {
  1375. switch (s) {
  1376. case '&':
  1377. return '&amp;';
  1378. case '"':
  1379. return '&quot;';
  1380. case "'":
  1381. return '&#039;';
  1382. case '<':
  1383. return '&lt;';
  1384. case '>':
  1385. return '&gt;';
  1386. default:
  1387. return s;
  1388. }
  1389. });
  1390.  
  1391. bbcodestr = bbcodestr.replace(/ /g, () => { return ' &nbsp;' });
  1392. bbcodestr = bbcodestr.replace(/\r\n/g, () => { return '<br>' });
  1393. bbcodestr = bbcodestr.replace(/\n/g, () => { return '<br>' });
  1394. bbcodestr = bbcodestr.replace(/\r/g, () => { return '<br>' });
  1395.  
  1396. // info/code 标签
  1397. const info_reg = new RegExp("\\[(mediainfo|info|code)\\](.+?)\\[\\/(\\1)\\]", "gis");
  1398. bbcodestr = bbcodestr.replace(info_reg, function (s, x, y) {
  1399. switch (x) {
  1400. case 'info':
  1401. return addTempCode('<fieldset class="codemain" style="background-color: transparent; word-break: break-all"><legend><b><span style="color: blue">'
  1402. + lang['info'] + '</span></b></legend>' + y + '</fieldset>');
  1403. case 'mediainfo':
  1404. return addTempCode('<fieldset class="codemain" style="background-color: transparent; word-break: break-all"><legend><b><span style="color: red">'
  1405. + lang['mediainfo'] + '</span></b></legend>' + y + '</fieldset>');
  1406. case 'code':
  1407. return addTempCode(`<br><div class="codetop">${lang['code']}</div><div class="codemain">${y}</div><br />`);
  1408. default:
  1409. return s;
  1410. }
  1411. });
  1412.  
  1413. // 超链接 (绝对)
  1414. bbcodestr = bbcodestr.replace(/\[url=((?:https?|ftp|gopher|news|telnet|mms|rtsp):\/\/((?!&lt;|&gt;|\s|"|>|'|<|\(|\)|\[|\]).)+)\](.+?)\[\/url\]/gis, function (s, x, y, z) {
  1415. return addTempCode('<a class="faqlink" rel="nofollow noopener noreferer" href="' + x + '">' + z + '</a>');
  1416. });
  1417.  
  1418. bbcodestr = bbcodestr.replace(/\[url\]((?:https?|ftp|gopher|news|telnet|mms|rtsp):\/\/((?!&lt;|&gt;|\s|"|>|'|<|\(|\)|\[|\]).)+)\[\/url\]/gis, function (s, x) {
  1419. return addTempCode('<a class="faqlink" rel="nofollow noopener noreferer" href="' + x + '">' + x + '</a>')
  1420. });
  1421.  
  1422. // 超链接 (相对)
  1423. bbcodestr = bbcodestr.replace(/\[url=(((?!&lt;|&gt;|\s|"|>|'|<|\(|\)|\[|\]).)+)\](.+?)\[\/url\]/gis, function (s, x, y, z) {
  1424. return addTempCode('<a class="faqlink" rel="nofollow noopener noreferer" href="' + x + '">' + z + '</a>');
  1425. });
  1426.  
  1427. bbcodestr = bbcodestr.replace(/\[url\](((?!&lt;|&gt;|\s|"|>|'|<|\(|\)|\[|\]).)+)\[\/url\]/gis, function (s, x) {
  1428. return addTempCode('<a class="faqlink" rel="nofollow noopener noreferer" href="' + x + '">' + x + '</a>')
  1429. });
  1430.  
  1431. // 单个标签 不带参
  1432. const o_reg = new RegExp("\\[(\\*|siteurl|site)\\]", "gi");
  1433. bbcodestr = bbcodestr.replace(o_reg, function (s, x, y) {
  1434. switch (x) {
  1435. case '*':
  1436. return '<img class="listicon listitem" src="pic/trans.gif" alt="list">';
  1437. case 'site':
  1438. return 'U2分享園@動漫花園';
  1439. case 'siteurl':
  1440. return 'https://u2.dmhy.org';
  1441. default:
  1442. return s;
  1443. }
  1444. });
  1445.  
  1446. // 成对标签 带参
  1447. const d_reg = new RegExp("\\[(rt|font)=([^\\]]+)\\](.*?)\\[(/\\1)\\]", "gis");
  1448. while (d_reg.test(bbcodestr)) {
  1449. bbcodestr = bbcodestr.replace(d_reg, function (s, w, x, y, z) {
  1450. switch (w) {
  1451. case 'rt':
  1452. if (f_reg.test(x)) {
  1453. return '[' + addTempCode('p3F#oW2@cEn_JHstp-&37DgD' + w) + '=' + x + ']'
  1454. + y + '[' + addTempCode('p3F#oW2@cEn_JHstp-&37DgD' + z) + ']'
  1455. }
  1456. else {
  1457. return addTempCode('<ruby>' + y + '<rp>(</rp><rt>' + x.replace(/^(?:&quot;)?(.*?)(?:&quot;)?$/, "$1") + '</rt><rp>)</rp></ruby>');
  1458. }
  1459. case 'font':
  1460. if (f_reg.test(x)) {
  1461. return '[' + addTempCode('p3F#oW2@cEn_JHstp-&37DgD' + w) + '=' + x + ']'
  1462. + y + '[' + addTempCode('p3F#oW2@cEn_JHstp-&37DgD' + z) + ']';
  1463. }
  1464. else {
  1465. return '<span style="font-family: ' + x.replace(/^(?:&quot;)?(.*?)(?:&quot;)?$/, "$1") + '">' + y + '</span>';
  1466. }
  1467. default:
  1468. return s;
  1469. }
  1470. })
  1471. };
  1472.  
  1473. // 成对标签 不带参
  1474. const a_reg = new RegExp("\\[(pre|b|i|u|s)\\](.*?)\\[/(\\1)\\]", "gs");
  1475. while (a_reg.test(bbcodestr)) {
  1476. bbcodestr = bbcodestr.replace(a_reg, function (s, x, y, z) {
  1477. switch (x) {
  1478. case 'b':
  1479. return '<b>' + y + '</b>';
  1480. case 'i':
  1481. return '<em>' + y + '</em>';
  1482. case 'u':
  1483. return '<u>' + y + '</u>';
  1484. case 's':
  1485. return '<s>' + y + '</s>';
  1486. case 'pre':
  1487. return '<pre>' + y + '</pre>';
  1488. default:
  1489. return s;
  1490. }
  1491. })
  1492. };
  1493.  
  1494. // 颜色
  1495. const color_reg = new RegExp("\\[color=(?:&quot;)?([#0-9a-z]{1,15}|[a-z]+?)(?:&quot;)?\\](.*?)\\[/color\\]", "gis");
  1496. while (color_reg.test(bbcodestr)) {
  1497. bbcodestr = bbcodestr.replace(color_reg, function (s, x, y) {
  1498. return '<span style="color: ' + x + '">' + y + '</span>';
  1499. })
  1500. };
  1501.  
  1502. // 文字大小
  1503. const size_reg = new RegExp("\\[size=(?:&quot;)?([1-7])(?:&quot;)?\\](.*?)\\[/size\\]", "gis");
  1504. while (size_reg.test(bbcodestr)) {
  1505. bbcodestr = bbcodestr.replace(size_reg, function (s, x, y) {
  1506. return '<font size="' + x + '">' + y + '</font>';
  1507. })
  1508. };
  1509.  
  1510. // 图片
  1511. bbcodestr = bbcodestr.replace(/\[(img|imglnk)\]([^\]]+)\[\/(?:\1)\]/gi, function (s, x, y) {
  1512. if (/^((?!&lt;|&gt;|"|>|'|<|;|\(|\)|\[|\]|#).)+\.(?:png|jpg|jpeg|gif|svg|bmp)$/i.test(y)) {
  1513. // url 以 .png 之类结尾
  1514. switch (x) {
  1515. case 'img':
  1516. return addTempCode('<img alt="image" src="' + y + '" style="height: auto; width: auto; max-width: 100%;">');
  1517. case 'imglnk':
  1518. return addTempCode('<a class="faqlink" rel="nofollow noopener noreferer" href="' + y + '"><img alt="image" src="'
  1519. + y + '" style="height: auto; width: auto; max-width: 100%;"></a>');
  1520. };
  1521. };
  1522. return addTempCode(s);
  1523. });
  1524.  
  1525. bbcodestr = bbcodestr.replace(/\[img=([^\]]+)\]/gi, function (s, x) {
  1526. if (/^((?!&lt;|&gt;|"|>|'|<|;|\(|\)|\[|\]|#).)+\.(?:png|jpg|jpeg|gif|svg|bmp)$/i.test(x)) {
  1527. // url 以 .png 之类结尾
  1528. return addTempCode('<img alt="image" src="' + x + '" style="height: auto; width: auto; max-width: 100%;">');
  1529. };
  1530. return s;
  1531. });
  1532.  
  1533. // 没有bbcode包裹的超链接
  1534. bbcodestr = bbcodestr.replace(/((?:https?|ftp|gopher|news|telnet|mms|rtsp):\/\/((?!&lt;|&gt;|\s|"|>|'|<|\(|\)|\[|\]).)+)/gi, function (s, x) {
  1535. return '<a class="faqlink" rel="nofollow noopener noreferer" href="' + s + '">' + s + '</a>';
  1536. });
  1537.  
  1538. // 引用
  1539. const quote_reg1 = new RegExp("\\[quote\\](.*?)\\[/quote\\]", "gsi");
  1540. while (quote_reg1.test(bbcodestr)) {
  1541. bbcodestr = bbcodestr.replace(quote_reg1, function (s, x) {
  1542. return '<fieldset><legend>' + lang['quote'] + '</legend>' + x + '</fieldset>';
  1543. });
  1544. };
  1545. const quote_reg2 = new RegExp("\\[quote=([^\\[\\]]*)\\](.*?)\\[/quote\\]", "gsi");
  1546. while (quote_reg2.test(bbcodestr)) {
  1547. bbcodestr = bbcodestr.replace(quote_reg2, function (s, x, y) {
  1548. if (f_reg.test(x)) {
  1549. return '<fieldset><legend>' + lang['quote'] + '</legend>' + y + '</fieldset>';
  1550. }
  1551. else {
  1552. return '<fieldset><legend>' + lang['quote'] + ': ' + x.replace(/^(?:&quot;)?(.*?)(?:&quot;)?$/, "$1") + '</legend>' + y + '</fieldset>';
  1553. }
  1554. });
  1555. };
  1556.  
  1557. // spoiler
  1558. const spoiler_reg1 = new RegExp("\\[spoiler\\](.*?)\\[/spoiler\\]", "gsi");
  1559. const spoiler_reg2 = new RegExp("\\[spoiler=([^\\]]+)\\](.*?)\\[/spoiler\\]", "gsi");
  1560. while (spoiler_reg1.test(bbcodestr)) {
  1561. bbcodestr = bbcodestr.replace(spoiler_reg1, function (s, x) {
  1562. return '<table class="spoiler" width="100%"><tbody><tr><td class="colhead">'
  1563. + lang['spoiler'] + '&nbsp;&nbsp;'
  1564. + '<button class="spoiler-button-show">' + lang['spoiler_button_1'] + '</button>'
  1565. + '<button class="spoiler-button-hide" style="display: none;">' + lang['spoiler_button_2'] + '</button>'
  1566. + '</td></tr><tr><td><span class="spoiler-content">'
  1567. + x + '</span></td></tr></tbody></table>';
  1568. });
  1569. };
  1570. while (spoiler_reg2.test(bbcodestr)) {
  1571. bbcodestr = bbcodestr.replace(spoiler_reg2, function (s, x, y) {
  1572. if (f_reg.test(x)) {
  1573. return '<table class="spoiler" width="100%"><tbody><tr><td class="colhead">'
  1574. + lang['spoiler'] + '&nbsp;&nbsp;'
  1575. + '<button class="spoiler-button-show">' + lang['spoiler_button_1'] + '</button>'
  1576. + '<button class="spoiler-button-hide" style="display: none;">' + lang['spoiler_button_2'] + '</button>'
  1577. + '</td></tr><tr><td><span class="spoiler-content">'
  1578. + y + '</span></td></tr></tbody></table>';
  1579. }
  1580. else {
  1581. return '<table class="spoiler" width="100%"><tbody><tr><td class="colhead">'
  1582. + x.replace(/^(?:&quot;)?(.*?)(?:&quot;)?$/, "$1") + '&nbsp;&nbsp;'
  1583. + '<button class="spoiler-button-show">' + lang['spoiler_button_1'] + '</button>'
  1584. + '<button class="spoiler-button-hide" style="display: none;">' + lang['spoiler_button_2'] + '</button>'
  1585. + '</td></tr><tr><td><span class="spoiler-content">'
  1586. + y + '</span></td></tr></tbody></table>';
  1587. }
  1588. });
  1589. };
  1590.  
  1591. // 表情
  1592. const em_reg = new RegExp("\\[(em[1-9][0-9]*)\\]", "gi");
  1593. bbcodestr = bbcodestr.replace(em_reg, function (s, x) {
  1594. switch (x) {
  1595. case (x.match(/^em[1-9][0-9]*/i) || {}).input:
  1596. return '<img src="pic/smilies/' + x.replace("em", "") + '.gif" alt="[' + x + ']">';
  1597. default:
  1598. return s;
  1599. }
  1600. })
  1601.  
  1602. for (let i = 0, len = tempCode.length; i < len; i++) {
  1603. // console.log(i + " : " + tempCode[i]);
  1604. bbcodestr = bbcodestr.replace("<tempCode_" + i + ">", tempCode[i]);
  1605. }
  1606.  
  1607. bbcodestr = bbcodestr.replace(/p3F#oW2@cEn_JHstp-&37DgD/g, "");
  1608.  
  1609. if (/(<br>)$/.test(bbcodestr)) { bbcodestr = bbcodestr + '<br>' };
  1610.  
  1611. var htmlobj = $.parseHTML('<div>' + bbcodestr + '</div>');
  1612.  
  1613. $(htmlobj).children('fieldset').children('fieldset').children('fieldset').children('fieldset').each(function () {
  1614. $(this).html($(this).html().replace(/(^<legend>[^<]*?<\/legend>)(.*)/i, function (s, x, y) {
  1615. return x + '<table class="spoiler" width="100%"><tbody>'
  1616. + '<tr><td class="colhead">' + lang['auto_fold'] + '&nbsp;&nbsp;'
  1617. + '<button class="spoiler-button-show">' + lang['spoiler_button_1'] + '</button>'
  1618. + '<button class="spoiler-button-hide" style="display: none;">' + lang['spoiler_button_2'] + '</button>'
  1619. + '</td></tr><tr><td><span class="spoiler-content">'
  1620. + y + '</span></td></tr></tbody></table>';
  1621. }))
  1622. });
  1623.  
  1624. return $(htmlobj).html();
  1625. };
  1626.  
  1627.  
  1628. function getapi() {
  1629. return new Promise((resolve, reject) => {
  1630. // https://www.w3school.com.cn/jquery/ajax_ajax.asp
  1631. $.ajax({
  1632. type: 'get',
  1633. url: 'https://u2.kysdm.com/api/v1/history?token=' + token + '&maximum=50&uid=' + user_id + '&torrent=' + torrent_id,
  1634. contentType: 'application/json',
  1635. dataType: 'json',
  1636. cache: true,
  1637. success: r => resolve(r),
  1638. error: r => {
  1639. console.log('发生错误,HTTP状态码[' + r.status + ']。');
  1640. reject(r.status)
  1641. },
  1642. });
  1643. }).catch(() => { return { "state": "404", "msg": "failure", "data": { "history": [] } }; });
  1644. };
  1645.  
  1646.  
  1647. function lang_init(lang) {
  1648. const lang_json = {
  1649. "zh_CN": {
  1650. "quote": "引用",
  1651. "info": "发布信息",
  1652. "mediainfo": "媒体信息",
  1653. "code": "代码",
  1654. "spoiler": "警告!下列文字很可能泄露剧情,请谨慎选择是否观看。",
  1655. "spoiler_button_1": "我就是手贱",
  1656. "spoiler_button_2": "我真是手贱",
  1657. "main_title": "主标题",
  1658. "rt_text": "请输入上标",
  1659. "main_body": "请输入正文",
  1660. "main_body_prefix": "请输入标题",
  1661. "url_name": "请输入网址名称",
  1662. "url_link": "请输入网址链接",
  1663. "select_type": "请选择分类...",
  1664. "preview": "预览",
  1665. "auto_fold": "过深引用自动折叠",
  1666. "subtitle": "副标题",
  1667. "uploaded": "发布人",
  1668. "basic_info": "基本信息",
  1669. "description": "描述",
  1670. "history_select_loading": "正在努力加载中...",
  1671. "history_select_error": "加载失败啦 (ノДT)",
  1672. "anonymous": "匿名",
  1673. "uploaded_at": "发布时间",
  1674. "size": "大小",
  1675. "category": "类型",
  1676. "submitted_by": "提供者",
  1677. "submitted_at": "提交时间",
  1678. "history_text_loading": "~~正在检查历史数据中~~",
  1679. "history_text_error": "加载失败啦 (ノДT) %%",
  1680. "history_text_empty": "半条历史记录都没有 (ノДT) @@",
  1681. "torrent_title": "种子标题",
  1682. "torrent_info": "种子信息",
  1683. "files": "文件数",
  1684. "info_hash": "种子散列值",
  1685. "show_or_hide": "显示&nbsp;/&nbsp;隐藏",
  1686. "KiB": " KiB",
  1687. "MiB": " MiB",
  1688. "GiB": " GiB",
  1689. "TiB": " TiB",
  1690. "current_time": " 当前时间",
  1691. "anonymous_user": " 匿名用户",
  1692. "banned": "已屏蔽",
  1693. "google_backup": "谷歌备份",
  1694. "google_send": "发送请求",
  1695. "last_edited": "最后编辑",
  1696. "back_to_top": "返回顶部",
  1697. "reset_token": "重置Token (・_・)ヾ",
  1698. },
  1699. "zh_TW": {
  1700. "quote": "引用",
  1701. "info": "發佈訊息",
  1702. "mediainfo": "媒體訊息",
  1703. "code": "代碼",
  1704. "spoiler": "警告!下列文字很可能洩露劇情,請謹慎選擇是否觀看。",
  1705. "spoiler_button_1": "我就是手賤",
  1706. "spoiler_button_2": "我真是手賤",
  1707. "main_title": "主標題",
  1708. "rt_text": "請輸入上標",
  1709. "main_body": "請輸入正文",
  1710. "main_body_prefix": "請輸入標題",
  1711. "url_name": "請輸入網址名稱",
  1712. "url_link": "請輸入網址連結",
  1713. "select_type": "請選擇分類...",
  1714. "preview": "預覽",
  1715. "auto_fold": "過深引用自動摺疊",
  1716. "subtitle": "副標題",
  1717. "uploaded": "發布人",
  1718. "basic_info": "基本訊息",
  1719. "description": "描述",
  1720. "history_select_loading": "正在努力載入中...",
  1721. "history_select_error": "載入失敗啦 (ノДT)",
  1722. "anonymous": "匿名",
  1723. "uploaded_at": "發布時間",
  1724. "size": "大小",
  1725. "category": "類型",
  1726. "submitted_by": "提供者",
  1727. "submitted_at": "提交時間",
  1728. "history_text_loading": "~~正在檢查歷史數據中~~",
  1729. "history_text_error": "載入失敗啦 (ノДT) %%",
  1730. "history_text_empty": "半條歷史記錄都沒有 (ノДT) @@",
  1731. "torrent_title": "種子標題",
  1732. "torrent_info": "種子訊息",
  1733. "files": "文件數",
  1734. "info_hash": "種子散列值",
  1735. "show_or_hide": "顯示&nbsp;/&nbsp;隱藏",
  1736. "KiB": " KiB",
  1737. "MiB": " MiB",
  1738. "GiB": " GiB",
  1739. "TiB": " TiB",
  1740. "current_time": " 當前時間",
  1741. "anonymous_user": " 匿名用戶",
  1742. "banned": "已屏蔽",
  1743. "google_backup": "Google備份",
  1744. "google_send": "發送請求",
  1745. "last_edited": "最後編輯",
  1746. "back_to_top": "返回頂部",
  1747. "reset_token": "重設Token (・_・)ヾ",
  1748. },
  1749. "zh_HK": {
  1750. "quote": "引用",
  1751. "info": "發佈訊息",
  1752. "mediainfo": "媒體訊息",
  1753. "code": "代碼",
  1754. "spoiler": "警告!下列文字很可能洩露劇情,請謹慎選擇是否觀看。",
  1755. "spoiler_button_1": "我就是手賤",
  1756. "spoiler_button_2": "我真是手賤",
  1757. "main_title": "主標題",
  1758. "rt_text": "請輸入上標",
  1759. "main_body": "請輸入正文",
  1760. "main_body_prefix": "請輸入標題",
  1761. "url_name": "請輸入網址名稱",
  1762. "url_link": "請輸入網址鏈接",
  1763. "select_type": "請選擇分類...",
  1764. "preview": "預覽",
  1765. "auto_fold": "過深引用自動摺疊",
  1766. "subtitle": "副標題",
  1767. "uploaded": "發布人",
  1768. "basic_info": "基本訊息",
  1769. "description": "描述",
  1770. "history_select_loading": "正在努力加載中...",
  1771. "history_select_error": "加載失敗啦 (ノДT)",
  1772. "anonymous": "匿名",
  1773. "uploaded_at": "發佈時間",
  1774. "size": "大小",
  1775. "category": "類型",
  1776. "submitted_by": "提供者",
  1777. "submitted_at": "提交時間",
  1778. "history_text_loading": "~~正在檢查歷史數據中~~",
  1779. "history_text_error": "加載失敗啦 (ノДT) %%",
  1780. "history_text_empty": "半條歷史記錄都沒有 (ノДT) @@",
  1781. "torrent_title": "種子標題",
  1782. "torrent_info": "種子訊息",
  1783. "files": "文件數",
  1784. "info_hash": "種子散列值",
  1785. "show_or_hide": "顯示&nbsp;/&nbsp;隱藏",
  1786. "KiB": " KiB",
  1787. "MiB": " MiB",
  1788. "GiB": " GiB",
  1789. "TiB": " TiB",
  1790. "current_time": " 當前時間",
  1791. "anonymous_user": " 匿名用戶",
  1792. "banned": "已屏蔽",
  1793. "google_backup": "Google備份",
  1794. "google_send": "發送請求",
  1795. "last_edited": "最後編輯",
  1796. "back_to_top": "返回頂部",
  1797. "reset_token": "重置Token (・_・)ヾ",
  1798. },
  1799. "en_US": {
  1800. "quote": "Quote",
  1801. "info": "Infobox",
  1802. "mediainfo": "Media Info",
  1803. "code": "CODE",
  1804. "spoiler": "Warning! This section contains spoiler!",
  1805. "spoiler_button_1": "I agree to view this.",
  1806. "spoiler_button_2": "Hide this.",
  1807. "main_title": "Main Title",
  1808. "rt_text": "Please enter superscript",
  1809. "main_body": "Please enter the text",
  1810. "main_body_prefix": "Please enter a title",
  1811. "url_name": "Please enter the URL name",
  1812. "url_link": "Please enter the URL link",
  1813. "select_type": "Please select a type.",
  1814. "preview": "Preview",
  1815. "auto_fold": "Over quote auto fold",
  1816. "subtitle": "Small Description",
  1817. "uploaded": "Uploader",
  1818. "basic_info": "Basic Info",
  1819. "description": "Description",
  1820. "history_select_loading": "Trying to load now ...",
  1821. "history_select_error": "Load failure (ノДT)",
  1822. "anonymous": "Anonymous",
  1823. "uploaded_at": "Uploaded at",
  1824. "size": "Size",
  1825. "category": "Category",
  1826. "submitted_by": "Submitted by",
  1827. "submitted_at": "Submitted at",
  1828. "history_text_loading": "~~Checking historical data now~~",
  1829. "history_text_error": "Load failure (ノДT) %%",
  1830. "history_text_empty": "Half of the history is missing (ノДT) @@",
  1831. "torrent_title": "Torrent Title",
  1832. "torrent_info": "Torrent Info",
  1833. "files": "Files",
  1834. "info_hash": "Info hash",
  1835. "show_or_hide": "Show&nbsp;or&nbsp;Hide",
  1836. "KiB": " KiB",
  1837. "MiB": " MiB",
  1838. "GiB": " GiB",
  1839. "TiB": " TiB",
  1840. "current_time": " CurrentTime",
  1841. "anonymous_user": " AnonymousUser",
  1842. "banned": "Banned",
  1843. "google_backup": "Google Backup",
  1844. "google_send": "Send request",
  1845. "last_edited": "Last edited by",
  1846. "back_to_top": "Back to top",
  1847. "reset_token": "Reset Token (・_・)ヾ",
  1848. },
  1849. "ru_RU": {
  1850. "quote": "Цитата",
  1851. "info": "Отправленные",
  1852. "mediainfo": "Данные о Медиа",
  1853. "code": "CODE",
  1854. "spoiler": "Предупреждение! Данный раздел содержит СПОЙЛЕРЫ!",
  1855. "spoiler_button_1": "I agree to view this.",
  1856. "spoiler_button_2": "Hide this.",
  1857. "main_title": "Основное название",
  1858. "rt_text": "Пожалуйста, введите надстрочный индекс",
  1859. "main_body": "Пожалуйста, введите текст",
  1860. "main_body_prefix": "Пожалуйста, введите название",
  1861. "url_name": "Пожалуйста, введите имя URL",
  1862. "url_link": "Пожалуйста, введите URL-ссылку",
  1863. "select_type": "выберите тип ...",
  1864. "preview": "Предварительный просмотр",
  1865. "auto_fold": "Автоматическое складывание для более глубоких ссылок",
  1866. "subtitle": "Краткое Описание",
  1867. "uploaded": "Загрузил",
  1868. "basic_info": "Базовая инф.",
  1869. "description": "Описание",
  1870. "history_select_loading": "Пытаюсь загрузить сейчас ...",
  1871. "history_select_error": "Отказ нагрузки (ノДT)",
  1872. "anonymous": "Анонимно",
  1873. "uploaded_at": "Загружен",
  1874. "size": "Размер",
  1875. "category": "Категория",
  1876. "submitted_by": "Разместивший Запрос",
  1877. "submitted_at": "Дата размещения",
  1878. "history_text_loading": "~~Проверка исторических данных сейчас~~",
  1879. "history_text_error": "Отказ нагрузки (ノДT) %%",
  1880. "history_text_empty": "Половина истории отсутствует (ノДT) @@",
  1881. "torrent_title": "Имя торрента",
  1882. "torrent_info": "Информация о торренте ",
  1883. "files": "Файлов в торренте",
  1884. "info_hash": "Информация о ХЕШЕ",
  1885. "show_or_hide": "Показать&nbsp;/&nbsp;Скрыть",
  1886. "KiB": " KiБ",
  1887. "MiB": " MiБ",
  1888. "GiB": " GiБ",
  1889. "TiB": " TiБ",
  1890. "current_time": " Текущее время",
  1891. "anonymous_user": " Анонимный пользователь",
  1892. "banned": "Забанен",
  1893. "google_backup": "Резервное копирование Google",
  1894. "google_send": "послать запрос",
  1895. "last_edited": "Последний раз редактировалось",
  1896. "back_to_top": "На главную",
  1897. "reset_token": "Токен сброса (・_・)ヾ",
  1898. }
  1899. };
  1900. return lang_json[lang];
  1901. };
  1902.  
  1903. // 当前时间 字符串格式
  1904. function getDateString() {
  1905. function zero(obj) { return obj < 10 ? '0' + obj : obj };
  1906. const time = new Date();
  1907. return time.getFullYear().toString() + '-' + zero(time.getMonth() + 1).toString() + '-' + zero(time.getDate()).toString()
  1908. + ' ' + zero(time.getHours()) + ':' + zero(time.getMinutes()) + ':' + zero(time.getSeconds())
  1909. };
  1910.  
  1911. function convert(s) {
  1912. if (s / 1024 < 1024) return (s / 1024).toFixed(3) + lang['KiB']
  1913. if (s / 1024 / 1024 < 1024) return (s / 1024 / 1024).toFixed(3) + lang['MiB']
  1914. if (s / 1024 / 1024 / 1024 < 1024) return (s / 1024 / 1024 / 1024).toFixed(3) + lang['GiB']
  1915. if (s / 1024 / 1024 / 1024 / 1024 < 1024) return (s / 1024 / 1024 / 1024 / 1024).toFixed(3) + lang['TiB']
  1916. };
  1917.  
  1918. // 生成种子评论cid定位url
  1919. const cidUrl = (t, c) => {
  1920. if (/\/offers\.php/i.test(location.href)) {
  1921. return `offers.php?id=${t}&off_details=1#cid${c}`
  1922. } else if (/\/details\.php/i.test(location.href))
  1923. return `details.php?id=${t}#cid${c}`
  1924. else {
  1925. return '/'
  1926. };
  1927. };
  1928.  
  1929. // 对JSON进行排序
  1930. // https://github.com/substack/json-stable-stringify
  1931. const stringify = function (obj, opts) {
  1932. if (!opts) opts = {};
  1933. if (typeof opts === 'function') opts = { cmp: opts };
  1934. var space = opts.space || '';
  1935. if (typeof space === 'number') space = Array(space + 1).join(' ');
  1936. var cycles = (typeof opts.cycles === 'boolean') ? opts.cycles : false;
  1937. var replacer = opts.replacer || function (key, value) { return value; };
  1938.  
  1939. var cmp = opts.cmp && (function (f) {
  1940. return function (node) {
  1941. return function (a, b) {
  1942. var aobj = { key: a, value: node[a] };
  1943. var bobj = { key: b, value: node[b] };
  1944. return f(aobj, bobj);
  1945. };
  1946. };
  1947. })(opts.cmp);
  1948.  
  1949. var seen = [];
  1950. return (function stringify(parent, key, node, level) {
  1951. var indent = space ? ('\n' + new Array(level + 1).join(space)) : '';
  1952. var colonSeparator = space ? ': ' : ':';
  1953.  
  1954. if (node && node.toJSON && typeof node.toJSON === 'function') {
  1955. node = node.toJSON();
  1956. }
  1957.  
  1958. node = replacer.call(parent, key, node);
  1959.  
  1960. if (node === undefined) {
  1961. return;
  1962. }
  1963. if (typeof node !== 'object' || node === null) {
  1964. return JSON.stringify(node);
  1965. }
  1966. if (isArray(node)) {
  1967. var out = [];
  1968. for (var i = 0; i < node.length; i++) {
  1969. var item = stringify(node, i, node[i], level + 1) || JSON.stringify(null);
  1970. out.push(indent + space + item);
  1971. }
  1972. return '[' + out.join(',') + indent + ']';
  1973. }
  1974. else {
  1975. if (seen.indexOf(node) !== -1) {
  1976. if (cycles) return JSON.stringify('__cycle__');
  1977. throw new TypeError('Converting circular structure to JSON');
  1978. }
  1979. else seen.push(node);
  1980.  
  1981. var keys = objectKeys(node).sort(cmp && cmp(node));
  1982. var out = [];
  1983. for (var i = 0; i < keys.length; i++) {
  1984. var key = keys[i];
  1985. var value = stringify(node, key, node[key], level + 1);
  1986.  
  1987. if (!value) continue;
  1988.  
  1989. var keyValue = JSON.stringify(key)
  1990. + colonSeparator
  1991. + value;
  1992. ;
  1993. out.push(indent + space + keyValue);
  1994. }
  1995. seen.splice(seen.indexOf(node), 1);
  1996. return '{' + out.join(',') + indent + '}';
  1997. }
  1998. })({ '': obj }, '', obj, 0);
  1999. };
  2000.  
  2001. const isArray = Array.isArray || function (x) {
  2002. return {}.toString.call(x) === '[object Array]';
  2003. };
  2004.  
  2005. const objectKeys = Object.keys || function (obj) {
  2006. var has = Object.prototype.hasOwnProperty || function () { return true };
  2007. var keys = [];
  2008. for (var key in obj) {
  2009. if (has.call(obj, key)) keys.push(key);
  2010. }
  2011. return keys;
  2012. };

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址