Pet Preview

Show a picture of your default pet on all pages

目前为 2023-09-28 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Pet Preview
  3. // @namespace https://www.marapets.com/
  4. // @version 0.1
  5. // @description Show a picture of your default pet on all pages
  6. // @author Lily Skye
  7. // @match *://*.marapets.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=marapets.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12. (function(global) {
  13.  
  14. function factory() {
  15. var modules = {
  16. /* --- src/pet-preview.tsx --- */
  17. "src/pet-preview.tsx": (function (exports, _kame_require_, module, __filename, __dirname, _kame_dynamic_import_) {
  18. "use strict";
  19.  
  20. Object.defineProperty(exports, "__esModule", {
  21. value: true
  22. });
  23. const _interop_require_wildcard = _kame_require_("node_modules/@swc/helpers/cjs/_interop_require_wildcard.cjs");
  24. const _jsxdom = /*#__PURE__*/_interop_require_wildcard._(_kame_require_("node_modules/@suchipi/jsxdom/dist/jsxdom.umd.js"));
  25. // Our compiler is configured to output 'React.createElement', so aliasing this
  26. // to 'React' makes everything work properly
  27. const React = _jsxdom;
  28. (async function () {
  29. if (location.href.match(/index\.php/)) {
  30. console.info("Pet Preview UserScript: Caching pet image and link...");
  31. // We're on the homepage! Scrape the default pet and save it to localStorage.
  32. const defaultPetLink = document.querySelector(`a[href^="pets.php?id="]`);
  33. const defaultPetImg = document.querySelector("img.defaultpet");
  34. const linkHref = defaultPetLink?.getAttribute("href");
  35. const imgSrc = defaultPetImg?.getAttribute("src");
  36. if (linkHref == null) {
  37. console.error("Pet Preview UserScript: Could not find default pet link");
  38. }
  39. if (imgSrc == null) {
  40. console.error("Pet Preview UserScript: Could not find default pet image");
  41. }
  42. // the '1' is the schema version
  43. localStorage.__userscript_suchipi_pet_preview_1 = JSON.stringify({
  44. linkHref,
  45. imgSrc
  46. });
  47. }
  48. const savedJson = localStorage.__userscript_suchipi_pet_preview_1;
  49. if (typeof savedJson !== "string") {
  50. console.warn("Pet Preview UserScript: Pet not cached yet. Click the 'Marapets' logo to cache it!");
  51. }
  52. const {
  53. linkHref,
  54. imgSrc
  55. } = JSON.parse(savedJson);
  56. let eltoAppend = null;
  57. if (linkHref != null && imgSrc != null) {
  58. eltoAppend = /*#__PURE__*/React.createElement("a", {
  59. href: linkHref
  60. }, /*#__PURE__*/React.createElement("img", {
  61. className: "defaultpet",
  62. style: {
  63. width: "75px",
  64. height: "75px",
  65. position: "fixed",
  66. top: "30px",
  67. zIndex: "1"
  68. },
  69. src: imgSrc
  70. }));
  71. } else if (imgSrc != null) {
  72. eltoAppend = /*#__PURE__*/React.createElement("img", {
  73. className: "defaultpet",
  74. style: {
  75. width: "75px",
  76. height: "75px",
  77. position: "fixed",
  78. top: "30px",
  79. zIndex: "1"
  80. },
  81. src: imgSrc
  82. });
  83. }
  84. if (eltoAppend != null) {
  85. document.body.appendChild(eltoAppend);
  86. }
  87. })();
  88. }),
  89. /* --- node_modules/@swc/helpers/cjs/_interop_require_wildcard.cjs --- */
  90. "node_modules/@swc/helpers/cjs/_interop_require_wildcard.cjs": (function (exports, _kame_require_, module, __filename, __dirname, _kame_dynamic_import_) {
  91. "use strict";
  92.  
  93. function _getRequireWildcardCache(nodeInterop) {
  94. if (typeof WeakMap !== "function") return null;
  95. var cacheBabelInterop = new WeakMap();
  96. var cacheNodeInterop = new WeakMap();
  97. return (_getRequireWildcardCache = function (nodeInterop) {
  98. return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
  99. })(nodeInterop);
  100. }
  101. exports._ = exports._interop_require_wildcard = _interop_require_wildcard;
  102. function _interop_require_wildcard(obj, nodeInterop) {
  103. if (!nodeInterop && obj && obj.__esModule) return obj;
  104. if (obj === null || typeof obj !== "object" && typeof obj !== "function") return {
  105. default: obj
  106. };
  107. var cache = _getRequireWildcardCache(nodeInterop);
  108. if (cache && cache.has(obj)) return cache.get(obj);
  109. var newObj = {};
  110. var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
  111. for (var key in obj) {
  112. if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
  113. var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
  114. if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc);else newObj[key] = obj[key];
  115. }
  116. }
  117. newObj.default = obj;
  118. if (cache) cache.set(obj, newObj);
  119. return newObj;
  120. }
  121. }),
  122. /* --- node_modules/@suchipi/jsxdom/dist/jsxdom.umd.js --- */
  123. "node_modules/@suchipi/jsxdom/dist/jsxdom.umd.js": (function (exports, _kame_require_, module, __filename, __dirname, _kame_dynamic_import_) {
  124. (function (e, l) {
  125. typeof exports == "object" && typeof module != "undefined" ? l(exports) : typeof define == "function" && define.amd ? define(["exports"], l) : (e = typeof globalThis != "undefined" ? globalThis : e || self, l(e.JSXDOM = {}));
  126. })(this, function (e) {
  127. "use strict";
  128.  
  129. var h = Object.getOwnPropertySymbols;
  130. var g = Object.prototype.hasOwnProperty,
  131. E = Object.prototype.propertyIsEnumerable;
  132. var p = (e, l) => {
  133. var f = {};
  134. for (var n in e) g.call(e, n) && l.indexOf(n) < 0 && (f[n] = e[n]);
  135. if (e != null && h) for (var n of h(e)) l.indexOf(n) < 0 && E.call(e, n) && (f[n] = e[n]);
  136. return f;
  137. };
  138. const l = Symbol("REF"),
  139. f = (...t) => ({
  140. [l]: !0,
  141. current: t.length > 0 ? t[0] : null
  142. }),
  143. n = (t, c) => {
  144. if (typeof t != "string") return document.createDocumentFragment();
  145. const F = c,
  146. {
  147. style: u,
  148. ref: o,
  149. namespaceURI: r,
  150. children: s,
  151. tagName: d
  152. } = F,
  153. a = p(F, ["style", "ref", "namespaceURI", "children", "tagName"]);
  154. let i;
  155. return r ? i = document.createElementNS(r, t) : i = document.createElement(t), u != null && Object.assign(i.style, u), o != null && (typeof o == "function" ? o(i) : o.current = i), Object.assign(i, a), i;
  156. };
  157. let m = n;
  158. const N = t => {
  159. m = t;
  160. },
  161. y = (t, ...c) => {
  162. let u = null,
  163. o = null;
  164. typeof c[0] == "object" && c[0] != null ? c[0] instanceof Node ? o = c : (u = c[0], o = c.slice(1)) : o = c, o = o.flat(1 / 0);
  165. const r = u || {};
  166. if (r.children = o, t === DocumentFragment || typeof t == "string") {
  167. const s = m(t, r);
  168. for (const d of o) if (d != null) if (typeof d == "object") s.appendChild(d);else {
  169. const a = document.createTextNode(String(d));
  170. s.appendChild(a);
  171. }
  172. return s;
  173. } else return t(r);
  174. },
  175. b = y,
  176. j = DocumentFragment;
  177. e.Fragment = j, e.createElement = b, e.defaultNodeFactory = n, e.jsx = y, e.ref = f, e.setNodeFactory = N, Object.defineProperties(e, {
  178. __esModule: {
  179. value: !0
  180. },
  181. [Symbol.toStringTag]: {
  182. value: "Module"
  183. }
  184. });
  185. });
  186. })
  187. /* --- end of modules --- */};
  188.  
  189. var __kame__ = {
  190. basedir: typeof __dirname === 'string' ? __dirname : "",
  191. cache: {},
  192. runModule: function runModule(name, isMain) {
  193. var exports = {};
  194. var module = {
  195. id: name,
  196. exports: exports,
  197. };
  198.  
  199. __kame__.cache[name] = module;
  200.  
  201. var _kame_require_ = function require(id) {
  202. if (__kame__.cache[id]) {
  203. return __kame__.cache[id].exports;
  204. } else {
  205. __kame__.runModule(id, false);
  206. return __kame__.cache[id].exports;
  207. }
  208. };
  209. _kame_require_.cache = __kame__.cache;
  210.  
  211. if (isMain) {
  212. _kame_require_.main = module;
  213. }
  214.  
  215. var __filename = __kame__.basedir + "/" + name;
  216. var __dirname = __kame__.basedir + "/" + name.split("/").slice(0, -1).join("/");
  217.  
  218.  
  219. __kame__.modules[name](exports, _kame_require_, module, __filename, __dirname );
  220. return module.exports;
  221. },
  222. modules: modules,
  223. };
  224.  
  225.  
  226.  
  227. return __kame__.runModule("src/pet-preview.tsx", true);
  228. }
  229.  
  230. if (typeof exports === 'object' && typeof module !== 'undefined') {
  231. module.exports = factory();
  232. } else if (typeof define === 'function' && define.amd) {
  233. define([], factory);
  234. } else {
  235. factory()
  236. }
  237.  
  238. })(
  239. typeof global !== "undefined" ? global :
  240. typeof window !== "undefined" ? window :
  241. typeof self !== "undefined" ? self :
  242. typeof this === "object" ? this :
  243. new Function("return this")()
  244. );

QingJ © 2025

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