LAction

Last Action

安装此脚本
作者推荐脚本

您可能也喜欢Dark Wiki

安装此脚本
  1. // ==UserScript==
  2. // @name LAction
  3. // @namespace zero.la.torn
  4. // @version 0.3
  5. // @description Last Action
  6. // @author -zero [2669774]
  7. // @match https://www.torn.com/*
  8. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  9. // @grant none
  10. // @license Apache 2.0
  11. // ==/UserScript==
  12.  
  13. // Made for Phillip_J_Fry [2184575].
  14. // DO NOT EDIT.
  15.  
  16.  
  17. const {fetch: origFetch} = window;
  18. window.fetch = async (...args) => {
  19. console.log("fetch called with args:", args);
  20.  
  21. const response = await origFetch(...args);
  22.  
  23. /* work with the cloned response in a separate promise
  24. chain -- could use the same chain with `await`. */
  25.  
  26. if (response.url.includes('page.php?sid=UserMiniProfile')){
  27. // console.log("REsponseL : "+response);
  28.  
  29. response
  30. .clone()
  31. .json()
  32. .then(function(body){
  33. var time = body.user.lastAction.seconds;
  34. insert(time);
  35.  
  36.  
  37. })
  38. .catch(err => console.error(err))
  39. ;
  40. }
  41.  
  42.  
  43.  
  44. return response;
  45. };
  46.  
  47. function convert(t){
  48. // console.log(t);
  49. var days = Math.floor(t/86400);
  50. t = t- 86400 * days;
  51. var hrs = Math.floor(t/3600);
  52. t = t - hrs*3600;
  53. var minutes = Math.floor(t/60);
  54. t = t - minutes *60;
  55.  
  56. var result = '';
  57. if (days){
  58. result += `${days} days `;
  59. }
  60. if (hrs){
  61. result += `${hrs} hours `;
  62. }
  63. if (minutes){
  64. result += `${minutes} minutes `;
  65. }
  66. result += `${t} seconds`;
  67. // console.log(result);
  68.  
  69. return result;
  70.  
  71. }
  72. function insert(t){
  73. // console.log(t);
  74. if ($('.icons',$('#profile-mini-root')).length > 0){
  75. if ($('.laction',$('#profile-mini-root')).length == 0){
  76. var tt = convert(t);
  77. var ldata = `<p class='laction' style='float:"right";'>Last Action: ${tt}</p>`;
  78. // console.log(ldata);
  79.  
  80. $('.icons',$('#profile-mini-root')).append(ldata);
  81. }
  82.  
  83. }
  84.  
  85. else{
  86. setTimeout(insert,300, t);
  87. }
  88. }

QingJ © 2025

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