TankTrouble Development Library

Shared library for TankTrouble userscript development

目前为 2023-12-13 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.gf.qytechs.cn/scripts/482092/1294933/TankTrouble%20Development%20Library.js

  1. // ==UserScript==
  2. // @name TankTrouble Development Library
  3. // @author commander
  4. // @namespace https://github.com/asger-finding
  5. // @version 0.0.2
  6. // @license GPL-3.0
  7. // @description Shared library for TankTrouble userscript development
  8. // @match *://*.tanktrouble.com/*
  9. // @grant none
  10. // @run-at document-start
  11. // @noframes
  12. // ==/UserScript==
  13.  
  14. /* jshint esversion: 8 */
  15.  
  16. /**
  17. * Fires when the document is readyState `interactive` or `complete`
  18. * @returns Promise that resolves upon content loaded
  19. */
  20. const contentLoaded = () => new Promise(promiseResolve => {
  21. if (document.readyState === 'interactive' || document.readyState === 'complete') promiseResolve();
  22. else document.addEventListener('DOMContentLoaded', () => promiseResolve());
  23. });
  24.  
  25. /**
  26. * Fires when the `main()` function is done on TankTrouble.
  27. * @returns Promise that resolves upon content initialized
  28. */
  29. const contentInitalized = () => new Promise(promiseResolve => {
  30. contentLoaded().then(() => {
  31. const contentInitHook = Content.init;
  32. Reflect.defineProperty(Content, 'init', {
  33. /**
  34. * Resolve after Content.init call finishes
  35. *
  36. * @param args Arguments to pass
  37. */
  38. value: (...args) => {
  39. contentInitHook(...args);
  40.  
  41. promiseResolve();
  42. }
  43. });
  44. });
  45. });

QingJ © 2025

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