NpmjsUISetting

npm_UI布局优化

  1. // ==UserScript==
  2. // @name NpmjsUISetting
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.7
  5. // @description npm_UI布局优化
  6. // @author Enjoy
  7. // @icon https://foruda.gitee.com/avatar/1698283059572409586/4867929_enjoy_li_1698283059.png!avatar200
  8. // @include *://www.npmjs.com/package/*
  9. // @exclude *localhost*
  10. // @grant GM_addElement
  11. // @grant GM_addStyle
  12. // @grant GM_setClipboard
  13. // @license GPL License
  14. // ==/UserScript==
  15.  
  16. /******/ (() => { // webpackBootstrap
  17. /******/ var __webpack_modules__ = ({
  18.  
  19. /***/ 342:
  20. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  21.  
  22. var _typeof = (__webpack_require__(882)["default"]);
  23. function _regeneratorRuntime() {
  24. "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  25. module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
  26. return e;
  27. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  28. var t,
  29. e = {},
  30. r = Object.prototype,
  31. n = r.hasOwnProperty,
  32. o = Object.defineProperty || function (t, e, r) {
  33. t[e] = r.value;
  34. },
  35. i = "function" == typeof Symbol ? Symbol : {},
  36. a = i.iterator || "@@iterator",
  37. c = i.asyncIterator || "@@asyncIterator",
  38. u = i.toStringTag || "@@toStringTag";
  39. function define(t, e, r) {
  40. return Object.defineProperty(t, e, {
  41. value: r,
  42. enumerable: !0,
  43. configurable: !0,
  44. writable: !0
  45. }), t[e];
  46. }
  47. try {
  48. define({}, "");
  49. } catch (t) {
  50. define = function define(t, e, r) {
  51. return t[e] = r;
  52. };
  53. }
  54. function wrap(t, e, r, n) {
  55. var i = e && e.prototype instanceof Generator ? e : Generator,
  56. a = Object.create(i.prototype),
  57. c = new Context(n || []);
  58. return o(a, "_invoke", {
  59. value: makeInvokeMethod(t, r, c)
  60. }), a;
  61. }
  62. function tryCatch(t, e, r) {
  63. try {
  64. return {
  65. type: "normal",
  66. arg: t.call(e, r)
  67. };
  68. } catch (t) {
  69. return {
  70. type: "throw",
  71. arg: t
  72. };
  73. }
  74. }
  75. e.wrap = wrap;
  76. var h = "suspendedStart",
  77. l = "suspendedYield",
  78. f = "executing",
  79. s = "completed",
  80. y = {};
  81. function Generator() {}
  82. function GeneratorFunction() {}
  83. function GeneratorFunctionPrototype() {}
  84. var p = {};
  85. define(p, a, function () {
  86. return this;
  87. });
  88. var d = Object.getPrototypeOf,
  89. v = d && d(d(values([])));
  90. v && v !== r && n.call(v, a) && (p = v);
  91. var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
  92. function defineIteratorMethods(t) {
  93. ["next", "throw", "return"].forEach(function (e) {
  94. define(t, e, function (t) {
  95. return this._invoke(e, t);
  96. });
  97. });
  98. }
  99. function AsyncIterator(t, e) {
  100. function invoke(r, o, i, a) {
  101. var c = tryCatch(t[r], t, o);
  102. if ("throw" !== c.type) {
  103. var u = c.arg,
  104. h = u.value;
  105. return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
  106. invoke("next", t, i, a);
  107. }, function (t) {
  108. invoke("throw", t, i, a);
  109. }) : e.resolve(h).then(function (t) {
  110. u.value = t, i(u);
  111. }, function (t) {
  112. return invoke("throw", t, i, a);
  113. });
  114. }
  115. a(c.arg);
  116. }
  117. var r;
  118. o(this, "_invoke", {
  119. value: function value(t, n) {
  120. function callInvokeWithMethodAndArg() {
  121. return new e(function (e, r) {
  122. invoke(t, n, e, r);
  123. });
  124. }
  125. return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  126. }
  127. });
  128. }
  129. function makeInvokeMethod(e, r, n) {
  130. var o = h;
  131. return function (i, a) {
  132. if (o === f) throw Error("Generator is already running");
  133. if (o === s) {
  134. if ("throw" === i) throw a;
  135. return {
  136. value: t,
  137. done: !0
  138. };
  139. }
  140. for (n.method = i, n.arg = a;;) {
  141. var c = n.delegate;
  142. if (c) {
  143. var u = maybeInvokeDelegate(c, n);
  144. if (u) {
  145. if (u === y) continue;
  146. return u;
  147. }
  148. }
  149. if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
  150. if (o === h) throw o = s, n.arg;
  151. n.dispatchException(n.arg);
  152. } else "return" === n.method && n.abrupt("return", n.arg);
  153. o = f;
  154. var p = tryCatch(e, r, n);
  155. if ("normal" === p.type) {
  156. if (o = n.done ? s : l, p.arg === y) continue;
  157. return {
  158. value: p.arg,
  159. done: n.done
  160. };
  161. }
  162. "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
  163. }
  164. };
  165. }
  166. function maybeInvokeDelegate(e, r) {
  167. var n = r.method,
  168. o = e.iterator[n];
  169. if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
  170. var i = tryCatch(o, e.iterator, r.arg);
  171. if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
  172. var a = i.arg;
  173. return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
  174. }
  175. function pushTryEntry(t) {
  176. var e = {
  177. tryLoc: t[0]
  178. };
  179. 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
  180. }
  181. function resetTryEntry(t) {
  182. var e = t.completion || {};
  183. e.type = "normal", delete e.arg, t.completion = e;
  184. }
  185. function Context(t) {
  186. this.tryEntries = [{
  187. tryLoc: "root"
  188. }], t.forEach(pushTryEntry, this), this.reset(!0);
  189. }
  190. function values(e) {
  191. if (e || "" === e) {
  192. var r = e[a];
  193. if (r) return r.call(e);
  194. if ("function" == typeof e.next) return e;
  195. if (!isNaN(e.length)) {
  196. var o = -1,
  197. i = function next() {
  198. for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
  199. return next.value = t, next.done = !0, next;
  200. };
  201. return i.next = i;
  202. }
  203. }
  204. throw new TypeError(_typeof(e) + " is not iterable");
  205. }
  206. return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
  207. value: GeneratorFunctionPrototype,
  208. configurable: !0
  209. }), o(GeneratorFunctionPrototype, "constructor", {
  210. value: GeneratorFunction,
  211. configurable: !0
  212. }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
  213. var e = "function" == typeof t && t.constructor;
  214. return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
  215. }, e.mark = function (t) {
  216. return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
  217. }, e.awrap = function (t) {
  218. return {
  219. __await: t
  220. };
  221. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
  222. return this;
  223. }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
  224. void 0 === i && (i = Promise);
  225. var a = new AsyncIterator(wrap(t, r, n, o), i);
  226. return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
  227. return t.done ? t.value : a.next();
  228. });
  229. }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
  230. return this;
  231. }), define(g, "toString", function () {
  232. return "[object Generator]";
  233. }), e.keys = function (t) {
  234. var e = Object(t),
  235. r = [];
  236. for (var n in e) r.push(n);
  237. return r.reverse(), function next() {
  238. for (; r.length;) {
  239. var t = r.pop();
  240. if (t in e) return next.value = t, next.done = !1, next;
  241. }
  242. return next.done = !0, next;
  243. };
  244. }, e.values = values, Context.prototype = {
  245. constructor: Context,
  246. reset: function reset(e) {
  247. if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
  248. },
  249. stop: function stop() {
  250. this.done = !0;
  251. var t = this.tryEntries[0].completion;
  252. if ("throw" === t.type) throw t.arg;
  253. return this.rval;
  254. },
  255. dispatchException: function dispatchException(e) {
  256. if (this.done) throw e;
  257. var r = this;
  258. function handle(n, o) {
  259. return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
  260. }
  261. for (var o = this.tryEntries.length - 1; o >= 0; --o) {
  262. var i = this.tryEntries[o],
  263. a = i.completion;
  264. if ("root" === i.tryLoc) return handle("end");
  265. if (i.tryLoc <= this.prev) {
  266. var c = n.call(i, "catchLoc"),
  267. u = n.call(i, "finallyLoc");
  268. if (c && u) {
  269. if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
  270. if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
  271. } else if (c) {
  272. if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
  273. } else {
  274. if (!u) throw Error("try statement without catch or finally");
  275. if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
  276. }
  277. }
  278. }
  279. },
  280. abrupt: function abrupt(t, e) {
  281. for (var r = this.tryEntries.length - 1; r >= 0; --r) {
  282. var o = this.tryEntries[r];
  283. if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
  284. var i = o;
  285. break;
  286. }
  287. }
  288. i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
  289. var a = i ? i.completion : {};
  290. return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
  291. },
  292. complete: function complete(t, e) {
  293. if ("throw" === t.type) throw t.arg;
  294. return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
  295. },
  296. finish: function finish(t) {
  297. for (var e = this.tryEntries.length - 1; e >= 0; --e) {
  298. var r = this.tryEntries[e];
  299. if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
  300. }
  301. },
  302. "catch": function _catch(t) {
  303. for (var e = this.tryEntries.length - 1; e >= 0; --e) {
  304. var r = this.tryEntries[e];
  305. if (r.tryLoc === t) {
  306. var n = r.completion;
  307. if ("throw" === n.type) {
  308. var o = n.arg;
  309. resetTryEntry(r);
  310. }
  311. return o;
  312. }
  313. }
  314. throw Error("illegal catch attempt");
  315. },
  316. delegateYield: function delegateYield(e, r, n) {
  317. return this.delegate = {
  318. iterator: values(e),
  319. resultName: r,
  320. nextLoc: n
  321. }, "next" === this.method && (this.arg = t), y;
  322. }
  323. }, e;
  324. }
  325. module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
  326.  
  327. /***/ }),
  328.  
  329. /***/ 882:
  330. /***/ ((module) => {
  331.  
  332. function _typeof(o) {
  333. "@babel/helpers - typeof";
  334.  
  335. return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
  336. return typeof o;
  337. } : function (o) {
  338. return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
  339. }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
  340. }
  341. module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
  342.  
  343. /***/ }),
  344.  
  345. /***/ 501:
  346. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  347.  
  348. // TODO(Babel 8): Remove this file.
  349.  
  350. var runtime = __webpack_require__(342)();
  351. module.exports = runtime;
  352.  
  353. // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
  354. try {
  355. regeneratorRuntime = runtime;
  356. } catch (accidentalStrictMode) {
  357. if (typeof globalThis === "object") {
  358. globalThis.regeneratorRuntime = runtime;
  359. } else {
  360. Function("r", "regeneratorRuntime = r")(runtime);
  361. }
  362. }
  363.  
  364.  
  365. /***/ })
  366.  
  367. /******/ });
  368. /************************************************************************/
  369. /******/ // The module cache
  370. /******/ var __webpack_module_cache__ = {};
  371. /******/
  372. /******/ // The require function
  373. /******/ function __webpack_require__(moduleId) {
  374. /******/ // Check if module is in cache
  375. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  376. /******/ if (cachedModule !== undefined) {
  377. /******/ return cachedModule.exports;
  378. /******/ }
  379. /******/ // Create a new module (and put it into the cache)
  380. /******/ var module = __webpack_module_cache__[moduleId] = {
  381. /******/ // no module.id needed
  382. /******/ // no module.loaded needed
  383. /******/ exports: {}
  384. /******/ };
  385. /******/
  386. /******/ // Execute the module function
  387. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  388. /******/
  389. /******/ // Return the exports of the module
  390. /******/ return module.exports;
  391. /******/ }
  392. /******/
  393. /************************************************************************/
  394. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  395. (() => {
  396. "use strict";
  397.  
  398. // EXTERNAL MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/regenerator/index.js
  399. var regenerator = __webpack_require__(501);
  400. ;// CONCATENATED MODULE: ./tools/GM.js
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407. function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
  408. function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
  409. /** @描述 函数文档 https://www.tampermonkey.net/documentation.php#api:GM_addElement */
  410.  
  411. /**
  412. * @description 创建element
  413. * @export
  414. * @param {*} tag
  415. * @param {*} [options={}]
  416. * @param {*} [win=window]
  417. * @returns {*}
  418. */
  419. function createElement(tag) {
  420. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  421. var win = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window;
  422. if (!win.GM_createElement) {
  423. win.GM_createElement = GM_createElement;
  424. }
  425. return GM_createElement(tag, options);
  426. /**
  427. * @param {*} tag
  428. * @param {*} options {
  429. * idPrefix = `enjoy_${ENV_CRX}_${tag}`,
  430. * el = 'html',
  431. * autoInsert = true,
  432. * randomType = 'single',
  433. * id = '',
  434. * addPrefix = true,
  435. * insertType = tag === 'style' ? 'appendChild' : 'prepend',
  436. * }
  437. * @returns {*} dom
  438. */
  439. function GM_createElement(tag, options) {
  440. var _options$idPrefix = options.idPrefix,
  441. idPrefix = _options$idPrefix === void 0 ? "enjoy_".concat("NpmjsUISetting", "_").concat(tag, "_") : _options$idPrefix,
  442. _options$el = options.el,
  443. el = _options$el === void 0 ? 'html' : _options$el,
  444. _options$autoInsert = options.autoInsert,
  445. autoInsert = _options$autoInsert === void 0 ? true : _options$autoInsert,
  446. _options$randomType = options.randomType,
  447. randomType = _options$randomType === void 0 ? 'single' : _options$randomType,
  448. _options$id = options.id,
  449. id = _options$id === void 0 ? '' : _options$id,
  450. _options$addPrefix = options.addPrefix,
  451. addPrefix = _options$addPrefix === void 0 ? true : _options$addPrefix,
  452. _options$insertType = options.insertType,
  453. insertType = _options$insertType === void 0 ? tag === 'style' ? 'appendChild' : 'prepend' : _options$insertType;
  454. if (addPrefix) {
  455. id = "".concat(idPrefix).concat(id);
  456. }
  457. if (randomType !== 'single') {
  458. id = "".concat(id, "_").concat(Math.floor(Math.random() * 1000));
  459. }
  460. options.id = id;
  461. var dom = document.querySelector("#".concat(id));
  462. if (!dom) {
  463. dom = document.createElement(tag);
  464. }
  465. for (var key in options) {
  466. if (Object.hasOwnProperty.call(options, key) && key !== 'el') {
  467. dom[key] = options[key];
  468. }
  469. }
  470. if (autoInsert) {
  471. if (typeof el === 'string') {
  472. el = document.querySelector(el);
  473. }
  474.  
  475. //insertType prepend | appendChild
  476. el[insertType](dom);
  477. }
  478. return dom;
  479. }
  480. }
  481.  
  482. /** @描述 是否匹配到目标url */
  483. function isMatched() {
  484. var urls = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  485. var currentUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : location.href;
  486. if (typeof urls === 'string') {
  487. urls = [urls];
  488. }
  489. return !!urls.find(function (regUrl) {
  490. return new RegExp(regUrl).test(currentUrl);
  491. });
  492. }
  493. function prependMetaUF8() {
  494. return document.querySelector('meta[charset="UTF-8"]') || createElement('meta', {
  495. charset: 'utf-8'
  496. });
  497. }
  498.  
  499. /**
  500. * @description doCopy 复制文本到剪贴板
  501. * @export
  502. * @param {*} text
  503. */
  504. function doCopy(text) {
  505. var _navigator;
  506. if (!text) return console.warn('doCopy 参数为空');
  507. if (document.hasFocus() && (_navigator = navigator) !== null && _navigator !== void 0 && (_navigator = _navigator.clipboard) !== null && _navigator !== void 0 && _navigator.writeText) {
  508. // localhost、127.0.0.1或者https中才能正常使用
  509. // 读取剪贴板
  510. // navigator.clipboard.readText().then((clipText) => {console.log('clipText=',clipText)})
  511.  
  512. // 写入剪贴板
  513. navigator.clipboard.writeText(text)["catch"](function (err) {
  514. return console.error("clipboard.writeText\uFF1A".concat(err));
  515. });
  516. return;
  517. }
  518. var textarea = document.createElement('textarea');
  519. document.body.appendChild(textarea);
  520. textarea.value = text;
  521. textarea.select();
  522. document.execCommand('Copy');
  523. setTimeout(function () {
  524. textarea.remove();
  525. }, 1000);
  526. }
  527.  
  528. /**
  529. * 检测element元素的可见性,即 非display:none
  530. * @param {*} element
  531. * @returns {*} {Boolean}
  532. */
  533. function checkVisibility(element) {
  534. if (element.checkVisibility) {
  535. return element.checkVisibility();
  536. }
  537. return !!element.offsetParent;
  538. }
  539. /**
  540. * @description 创建element的提示
  541. * @export
  542. * @param {*} [options={}]
  543. * @returns {*}
  544. */
  545. function createElementTipFn() {
  546. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  547. var _options$setTimeoutSt = options.setTimeoutStep,
  548. setTimeoutStep = _options$setTimeoutSt === void 0 ? 1000 : _options$setTimeoutSt,
  549. _options$backgroundCo = options.backgroundColors,
  550. backgroundColors = _options$backgroundCo === void 0 ? {
  551. warn: 'rgb(181 156 51 / 60%)',
  552. success: 'rgb(3 113 3 / 60%)',
  553. error: 'rgb(165 2 2 / 60%)',
  554. info: 'rgb(67 62 62 / 60%)'
  555. } : _options$backgroundCo,
  556. _options$color = options.color,
  557. color = _options$color === void 0 ? '#ffffff' : _options$color,
  558. _options$opacity = options.opacity,
  559. opacity = _options$opacity === void 0 ? 1 : _options$opacity;
  560. var setTimeoutStamp = 0;
  561. return function createElementTip() {
  562. var configs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  563. var content = configs.content,
  564. e = configs.e,
  565. _configs$type = configs.type,
  566. type = _configs$type === void 0 ? 'info' : _configs$type,
  567. _configs$tagType = configs.tagType,
  568. tagType = _configs$tagType === void 0 ? 'span' : _configs$tagType;
  569. if (!content) return;
  570. console.log("content => %O ", content);
  571. clearTimeout(setTimeoutStamp);
  572. var contentDom = createElement(tagType, {
  573. id: 'createElementTip',
  574. innerText: content,
  575. style: "\n font-size:14px;\n font-weight:600;\n color:".concat(color, ";\n position: fixed;\n left: ").concat(numbericalInterval(e.clientX - 46), "px;\n top: ").concat(numbericalInterval(e.clientY - 35, [5, window.innerHeight - 35]), "px;\n background-color:").concat(backgroundColors[type], ";\n opacity: ").concat(opacity, ";\n border-radius: 4px;\n padding: 4px 8px;\n box-shadow:0 0 5px 0 rgb(255 255 255 / 60%) inset;\n pointer-event:none;\n z-index:").concat((Math.floor(Date.now() / 1000) + '').slice(-5), ";\n\t\t\t\t\t\tdisplay:inline-block;\n ")
  576. });
  577. setTimeoutStamp = setTimeout(function () {
  578. // contentDom.remove()
  579. contentDom.style.display = 'none';
  580. }, setTimeoutStep);
  581. };
  582. }
  583. /**
  584. * @description dom是否可编辑
  585. * @param {*} [dom=document.activeElement]
  586. * @returns {*} {boolean}
  587. */
  588.  
  589. function isContentEditableOfDOM() {
  590. var dom = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.activeElement;
  591. if (dom.tagName === 'INPUT' || dom.tagName === 'TEXTAREA') {
  592. return !dom.disabled;
  593. } else {
  594. return !!findParentElement(dom, function (dom) {
  595. return dom.contentEditable === 'true';
  596. }, null);
  597. }
  598. }
  599.  
  600. /**
  601. * @description 数字区间
  602. * @param {*} val
  603. * @param {*} [interval=[10, window.innerWidth]]
  604. * @returns {*}
  605. */
  606. function numbericalInterval(val) {
  607. var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [5, window.innerWidth - 130];
  608. var indexStart = interval[0];
  609. var indexEnd = interval[1];
  610. if (val < indexStart) return indexStart;
  611. if (val > indexEnd) return indexEnd;
  612. return val;
  613. }
  614.  
  615. /**
  616. * @description 可滚动的dom
  617. * @param {*} dom
  618. * @returns {*}
  619. */
  620. function findHasScrollbarDom(dom) {
  621. if (!(dom instanceof HTMLElement)) {
  622. console.warn("\u53EF\u6EDA\u52A8\u7684dom\u51FD\u6570 findHasScrollbarDom:\u53C2\u6570dom\u5FC5\u987B\u4E3Aelement\u5143\u7D20 ");
  623. return void 0;
  624. }
  625. while (dom) {
  626. if (dom.offsetHeight < dom.scrollHeight && !(window.getComputedStyle(dom).overflowY == 'visible' || window.getComputedStyle(dom).overflowY == 'hidden')) {
  627. break;
  628. }
  629. dom = dom.parentElement;
  630. }
  631. if (!dom || dom === document.body) {
  632. // 始终是 documentElement等同于window
  633. dom = document.documentElement;
  634. }
  635. console.warn("\u9875\u9762\u6EDA\u52A8\u5143\u7D20\u7684tagName: ", dom.tagName.toLocaleLowerCase(), 'dom.className:', dom.className);
  636. return dom;
  637. }
  638.  
  639. /**
  640. * @description 获取方法配置
  641. * @param {string} [key='']
  642. * @param {*} [defaultOpt={ includedUrls: [] }]
  643. * @returns {*} {Object}
  644. **/
  645. function getSettingFromLocalStorage() {
  646. var fileName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  647. var defaultOpt = arguments.length > 1 ? arguments[1] : undefined;
  648. var mergedSettingOpt = _objectSpread({
  649. runType: '0',
  650. includedUrls: [],
  651. excludeUrls: []
  652. }, defaultOpt);
  653. var fullSettingKey = "enjoy_setting";
  654. var storageData = localStorage.getItem(fullSettingKey);
  655. var fullSettings = storageData ? JSON.parse(storageData) : {};
  656. var SETTING = _objectSpread(_objectSpread({}, mergedSettingOpt), fullSettings === null || fullSettings === void 0 ? void 0 : fullSettings[fileName]);
  657. fullSettings[fileName] = SETTING;
  658. fullSettings.runTypeDest = undefined;
  659. fullSettings.instructions = "\n\u4E00\u3001\u5339\u914D\u89C4\u5219\u4F18\u5148\u7EA7\uFF1Aruntype > * > excludedUrls > includedUrls\n\u4E8C\u3001runType\u662F\u9488\u5BF9\u5728\u5F53\u524D\u57DF\u540D\u89C4\u5219\uFF1A0(\u9ED8\u8BA4\u6267\u884C\u5339\u914D\u89C4\u5219)\uFF1B1(\u5F3A\u5236\u6267\u884C,\u5373\u8DF3\u8FC7\u5339\u914D\u89C4\u5219)\uFF1B2(\u4E0D\u6267\u884C)\n";
  660. localStorage.setItem(fullSettingKey, JSON.stringify(fullSettings || {}, null, 2));
  661. return SETTING;
  662. }
  663.  
  664. /**
  665. * @description 是否执行该方法
  666. * @param {*} [settingOpt={}]
  667. * @returns {*} {Boolean}
  668. */
  669. function isExcutableBySetting() {
  670. var settingOpt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  671. var runType = settingOpt.runType,
  672. _settingOpt$excludeUr = settingOpt.excludeUrls,
  673. excludeUrls = _settingOpt$excludeUr === void 0 ? [] : _settingOpt$excludeUr,
  674. _settingOpt$includedU = settingOpt.includedUrls,
  675. includedUrls = _settingOpt$includedU === void 0 ? [] : _settingOpt$includedU;
  676. if (runType == '1') return true;
  677. if (runType == '2') return false;
  678. var HREF = location.href;
  679. if (excludeUrls !== null && excludeUrls !== void 0 && excludeUrls.length && isMatched(excludeUrls, HREF)) {
  680. return false;
  681. }
  682. if ((includedUrls === null || includedUrls === void 0 ? void 0 : includedUrls.length) === 0) return true;
  683. var findOne = isMatched(includedUrls, HREF);
  684. return !!findOne;
  685. }
  686.  
  687. /**
  688. * @description 是否不执行
  689. * @param {String} fileName
  690. * @param {Object} settingOpt { excludeUrls: [ ],feature:"feature",includedUrls: [ ],name: "name",runType: "0",}
  691. * @returns {Boolean}
  692. */
  693. function codeIsNotExcutable(fileName, settingOpt) {
  694. try {
  695. // logSettingOptWithColor()
  696. var setting = getSettingFromLocalStorage(fileName, settingOpt);
  697. return _objectSpread({
  698. notExcutable: !isExcutableBySetting(setting)
  699. }, setting);
  700. } catch (error) {
  701. // base64路径下,禁用storage
  702. console.error(error);
  703. return _objectSpread({
  704. notExcutable: true
  705. }, settingOpt);
  706. }
  707. }
  708.  
  709. /**
  710. * @description 彩色打印
  711. * @param {string} [key='enjoy_setting']
  712. */
  713. function logSettingOptWithColor(key) {
  714. var dataKey = 'is-log-of-enjoy';
  715. if (true) return;
  716. // if (document.body.getAttribute(dataKey)) return
  717. document.body.setAttribute(dataKey, '1');
  718.  
  719. // clearTimeout(window.EnjoyColorLogTimer || 0)
  720. window.EnjoyColorLogTimer = setTimeout(function () {
  721. var _key;
  722. (_key = key) !== null && _key !== void 0 ? _key : key = 'enjoy_setting';
  723. var SETTINGS = JSON.parse(localStorage[key] || '{}');
  724. console.log("%c\uD83D\uDC47 ".concat(key, " \u8BBE\u7F6E\u53C2\u6570\uFF1A"), 'background:#4e0ab780;color:#fff;', '\n', SETTINGS, "\n\nkeyNameList:", Object.keys(SETTINGS));
  725. console.log("%c\uD83D\uDC47\u81EA\u5B9A\u4E49\u914D\u7F6E\uFF0C\u4EE3\u7801\u5982\u4E0B\uFF1A", 'background:#4e0ab747;color:#fff;', "\n\u5F53\u524D\u57DF\u540D\u4E0B\u662F\u5426\u8FD0\u884C\u76F8\u5E94\u51FD\u6570,", "\n\u8BBE\u7F6ErunType(1\u3001\u5F3A\u5236\u8FD0\u884C\uFF1B2\u3001\u4E0D\u8FD0\u884C)\u3002", '\n\n', modifyRuntype.toString(), "\nmodifyRuntype('keyName',2)");
  726. }, 3 * 1000);
  727. }
  728. /**
  729. * @description 修改运行机制
  730. * @export
  731. * @param {string} keyName
  732. * @param {0|1|2} runType
  733. */
  734. function modifyRuntype(keyName, runType) {
  735. var keyOfSETTINGS = 'enjoy_setting';
  736. var SETTINGS = JSON.parse(localStorage.getItem(keyOfSETTINGS) || '{}');
  737. if (!SETTINGS[keyName]) return;
  738. SETTINGS[keyName].runType = runType || 2;
  739. localStorage.setItem(keyOfSETTINGS, JSON.stringify(SETTINGS, null, 2));
  740. }
  741.  
  742. /**
  743. * @description 查找特定条件的父级元素
  744. * @export
  745. * @param {Element} dom
  746. * @param {Function} callback
  747. * @param {Element} [defaultVal=document.documentElement]
  748. * @returns {Element}
  749. */
  750. function findParentElement(dom, callback) {
  751. var defaultVal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : document.documentElement;
  752. if (!(dom instanceof HTMLElement)) {
  753. console.warn("\u67E5\u627E\u7279\u5B9A\u6761\u4EF6\u7684\u7236\u7EA7\u5143\u7D20\u51FD\u6570 findParentElement:\u53C2\u6570dom\u5FC5\u987B\u4E3Aelement\u5143\u7D20 ");
  754. return void 0;
  755. }
  756. while (dom) {
  757. if (callback(dom)) {
  758. break;
  759. }
  760. dom = dom.parentElement;
  761. }
  762. if (!dom || dom === document.body) {
  763. // 始终是 documentElement等同于window
  764. dom = defaultVal;
  765. }
  766. return dom;
  767. }
  768.  
  769. /** 原生横向滚动条 吸附 页面底部 */
  770. var StickyHorizontalNativeScrollBar = /*#__PURE__*/(/* unused pure expression or super */ null && (_createClass(function StickyHorizontalNativeScrollBar() {
  771. var _this = this;
  772. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  773. _classCallCheck(this, StickyHorizontalNativeScrollBar);
  774. /** 创建滚轴组件元素 */
  775. _defineProperty(this, "createScrollbar", function () {
  776. var style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  777. if (_this.scrollbar) return _this.scrollbar;
  778. var timer = Date.now();
  779. _this.thumbId = "thumb".concat(timer);
  780. _this.scrollbarId = "scrollbar".concat(timer);
  781. _this.scrollbar = document.createElement('div');
  782. _this.scrollbar.setAttribute('id', _this.scrollbarId);
  783. _this.scrollbar.innerHTML = "\n\t\t\t<style>\n\t\t\t\t#".concat(_this.scrollbarId, " {\n\t\t\t\t\tposition: sticky;\n\t\t\t\t\twidth: 100%;\n\t\t\t\t\tbox-shadow: 0 15px 0 0 #fff;\n\t\t\t\t\tbottom: 8px;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\theight: 17px;\n\t\t\t\t\toverflow-x: auto;\n\t\t\t\t\toverflow-y: hidden;\n\t\t\t\t\tmargin-top: -17px;\n\t\t\t\t\tz-index: 3;\n\t\t\t\t\t").concat(style, "\n\t\t\t\t}\n\t\t\t</style>\n\t\t\t<div id=\"").concat(_this.thumbId, "\" style=\"height: 1px;\"></div>\n\t\t");
  784. });
  785. /** 把滚轴组件元素插入目标元素的后面 */
  786. _defineProperty(this, "insertScrollbar", function (el) {
  787. _this.target = el;
  788. if (typeof el === 'string') {
  789. _this.target = document.querySelector(el);
  790. }
  791. if (!_this.target) throw Error('el Dom do not exit');
  792. _this.targetParentElement = document.querySelector(el).parentElement;
  793. if (!_this.targetParentElement.querySelector("#".concat(_this.scrollbarId))) {
  794. _this.targetParentElement.insertBefore(_this.scrollbar, _this.target.nextSibling);
  795. }
  796. return _this.target;
  797. });
  798. /** 设置 滚轴组件元素尺寸 */
  799. _defineProperty(this, "setScrollbarSize", throttle(function () {
  800. _this.scrollbar.style.width = _this.target.clientWidth + 'px';
  801. _this.scrollbar.querySelector("#".concat(_this.thumbId)).style.width = _this.target.scrollWidth + 'px';
  802. }, 100));
  803. /** 监听目标元素和滚轴元素的scroll和页面resize事件 */
  804. _defineProperty(this, "onEvent", function () {
  805. _this.target.addEventListener('scroll', _this.onScrollTarget);
  806. _this.scrollbar.addEventListener('scroll', _this.onScrollScrollbar);
  807. window.addEventListener('resize', _this.setScrollbarSize);
  808. });
  809. /** 移除事件 */
  810. _defineProperty(this, "removeEvent", function () {
  811. _this.target.removeEventListener('scroll', _this.onScrollTarget);
  812. _this.scrollbar.removeEventListener('scroll', _this.onScrollScrollbar);
  813. window.removeEventListener('resize', _this.setScrollbarSize);
  814. });
  815. _defineProperty(this, "onScrollTarget", throttle(function (e) {
  816. _this.scrollbar.scrollLeft = e.target.scrollLeft;
  817. }, 100));
  818. _defineProperty(this, "onScrollScrollbar", throttle(function (e) {
  819. _this.target.scrollLeft = e.target.scrollLeft;
  820. }, 100));
  821. var _el = options.el,
  822. _options$style = options.style,
  823. _style = _options$style === void 0 ? '' : _options$style;
  824. this.createScrollbar(_style);
  825. this.insertScrollbar(_el);
  826. this.setScrollbarSize();
  827. this.onEvent();
  828. })));
  829.  
  830. /** 插入横向滚动条 */
  831. var HorizontalScrollBar = /*#__PURE__*/(/* unused pure expression or super */ null && (function () {
  832. function HorizontalScrollBar() {
  833. var _this2 = this;
  834. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  835. _classCallCheck(this, HorizontalScrollBar);
  836. /** 创建滚轴组件元素 */
  837. _defineProperty(this, "createScrollbar", function (setStyle) {
  838. if (_this2.scrollbar) return _this2.scrollbar;
  839. var timer = Date.now();
  840. _this2.scrollbarId = "scrollbar".concat(timer);
  841. _this2.scrollbar = document.createElement('div');
  842. _this2.scrollbar.setAttribute('data-part', 'scrollbar');
  843. _this2.scrollbar.setAttribute('id', _this2.scrollbarId);
  844. _this2.scrollbar.innerHTML = "\n\t\t".concat(setStyle(_this2.scrollbarId) || _this2.setDefaultStyle(_this2.scrollbarId), "\n\t\t<div data-part=\"thumb\"></div>\n\t\t");
  845. });
  846. /** 把滚轴组件元素插入目标元素的后面 */
  847. _defineProperty(this, "insertScrollbar", function (el) {
  848. _this2.target = el;
  849. if (typeof el === 'string') {
  850. _this2.target = document.querySelector(el);
  851. }
  852. if (!_this2.target) throw Error('el Dom do not exit');
  853. _this2.targetParentElement = document.querySelector(el).parentElement;
  854. if (!_this2.targetParentElement.querySelector("#".concat(_this2.scrollbarId))) {
  855. _this2.targetParentElement.insertBefore(_this2.scrollbar, _this2.target.nextSibling);
  856. }
  857. return _this2.target;
  858. });
  859. /** 根据目标元素 设置 滚轴组件元素尺寸 */
  860. _defineProperty(this, "setScrollbarSize", function () {
  861. _this2.scrollbar.style.width = _this2.target.clientWidth + 'px';
  862. _this2.thumb = _this2.scrollbar.querySelector('[data-part="thumb"]');
  863. _this2.thumb.style.width = _this2.scrollbar.clientWidth * _this2.target.clientWidth / _this2.target.scrollWidth + 'px';
  864. _this2.offsetMax = _this2.scrollbar.clientWidth - _this2.thumb.clientWidth;
  865. _this2.rate = (_this2.target.scrollWidth - _this2.target.clientWidth) / _this2.offsetMax;
  866. });
  867. /** */
  868. _defineProperty(this, "onMouseDownOfThumb", function (e) {
  869. console.log("mousedown => %O ");
  870. _this2.prePageX = e.pageX;
  871. _this2.isMousedown = true;
  872. });
  873. /** */
  874. _defineProperty(this, "onMouseUpOfWindow", function (e) {
  875. _this2.isMousedown = false;
  876. });
  877. /** */
  878. _defineProperty(this, "requestAnimationFrameCallback", function (offsetLeft) {
  879. _this2.thumb.style.left = offsetLeft + 'px';
  880. _this2.target.scrollLeft = offsetLeft * _this2.rate;
  881. });
  882. /** */
  883. _defineProperty(this, "onMousemoveOfWindow", function (e) {
  884. if (_this2.isMousedown) {
  885. var offsetLeft = Number(_this2.thumb.style.left.replace('px', '')) + Number(e.pageX - _this2.prePageX);
  886. offsetLeft = Math.max(0, offsetLeft);
  887. offsetLeft = Math.min(offsetLeft, _this2.offsetMax);
  888. _this2.requestAnimationFrameCallback(offsetLeft);
  889. _this2.prePageX = e.pageX;
  890. }
  891. });
  892. /** 监听目标元素和滚轴元素的scroll和页面resize事件 */
  893. _defineProperty(this, "onEvent", function () {
  894. _this2.thumb.addEventListener('mousedown', _this2.onMouseDownOfThumb);
  895. window.addEventListener('mouseup', _this2.onMouseUpOfWindow);
  896. window.addEventListener('mousemove', _this2.onMousemoveOfWindow);
  897. window.addEventListener('resize', _this2.setScrollbarSize);
  898. });
  899. /** 移除事件 */
  900. _defineProperty(this, "removeEvent", function () {
  901. _this2.thumb.removeEventListener('mousedown', _this2.onMouseDownOfThumb);
  902. window.removeEventListener('mouseup', _this2.onMouseUpOfWindow);
  903. window.removeEventListener('mousemove', _this2.onMousemoveOfWindow);
  904. window.removeEventListener('resize', _this2.setScrollbarSize);
  905. });
  906. var _el2 = options.el,
  907. _options$setStyle = options.setStyle,
  908. _setStyle = _options$setStyle === void 0 ? function () {
  909. return null;
  910. } : _options$setStyle;
  911. this.createScrollbar(_setStyle);
  912. this.insertScrollbar(_el2);
  913. this.setScrollbarSize();
  914. this.onEvent();
  915. }
  916. return _createClass(HorizontalScrollBar, [{
  917. key: "setDefaultStyle",
  918. value: function setDefaultStyle(scrollbarId) {
  919. return "\n\t\t<style>\n\t\t\t#".concat(scrollbarId, " {\n\t\t\t\theight: 17px;\n\t\t\t\tbackground-color: #f1f1f1;\n\t\t\t\tposition: relative;\n\t\t\t}\n\t\t\t#").concat(scrollbarId, ">[data-part=\"thumb\"] {\n\t\t\t\theight: 100%;\n\t\t\t\tbackground-color: #c1c1c1;\n\t\t\t\tposition: absolute;\n\t\t\t}\n\t\t\t#").concat(scrollbarId, ">[data-part=\"thumb\"]:active {\n\t\t\t\tbackground-color: #787878;\n\t\t\t}\n\t\t</style>\n\t");
  920. }
  921. }]);
  922. }()));
  923.  
  924. /** 持久化数据状态 */
  925. var PersistentStorage = /*#__PURE__*/(/* unused pure expression or super */ null && (function () {
  926. function PersistentStorage() {
  927. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  928. _classCallCheck(this, PersistentStorage);
  929. var _options$valKey = options.valKey,
  930. valKey = _options$valKey === void 0 ? 'valKey' : _options$valKey,
  931. _options$storageType = options.storageType,
  932. storageType = _options$storageType === void 0 ? 'sessionStorage' : _options$storageType;
  933. this.valKey = valKey;
  934. this.storageType = storageType;
  935. }
  936. return _createClass(PersistentStorage, [{
  937. key: "write",
  938. value: function write(val) {
  939. val = _typeof(val) === 'object' ? JSON.stringify(val, null, 2) : val;
  940. val && window[this.storageType].setItem(this.valKey, val);
  941. }
  942. }, {
  943. key: "read",
  944. value: function read() {
  945. var val = window[this.storageType].getItem(this.valKey);
  946. return val ? JSON.parse(val) : val;
  947. }
  948. }, {
  949. key: "remove",
  950. value: function remove() {
  951. window[this.storageType].removeItem(this.valKey);
  952. }
  953. }]);
  954. }()));
  955.  
  956. /**
  957. * @description 节流函数
  958. * @export
  959. * @param {Function} func
  960. * @param {Number} [wait=100]
  961. * @returns {Function}
  962. */
  963. function throttle(func) {
  964. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
  965. var isDoing = false;
  966. return function () {
  967. if (isDoing) return;
  968. isDoing = true;
  969. func.apply(void 0, arguments);
  970. setTimeout(function () {
  971. isDoing = false;
  972. }, wait);
  973. };
  974. }
  975.  
  976. /**
  977. * @description 防抖函数
  978. * @export
  979. * @param {Function} func
  980. * @param {Number} [wait=100]
  981. * @param {'end'|'front'} type
  982. * @returns {Function}
  983. */
  984. function debounce(func) {
  985. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
  986. var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'end';
  987. var timer = 0;
  988. return function () {
  989. clearTimeout(timer);
  990. for (var _len = arguments.length, rest = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
  991. rest[_key2] = arguments[_key2];
  992. }
  993. timer = setTimeout.apply(void 0, [func, wait].concat(rest));
  994. };
  995. }
  996.  
  997. /**
  998. * @description 等候
  999. * @export
  1000. * @param {number} [interval=17]
  1001. * @returns {Promise}
  1002. */
  1003. function awaitTime() {
  1004. var interval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 17;
  1005. return new Promise(function (resolve) {
  1006. setTimeout(resolve, interval);
  1007. });
  1008. }
  1009.  
  1010. /**
  1011. * @description 打开已在窗口仅激活,不刷新
  1012. * @export
  1013. * @class OpenPlus
  1014. */
  1015. var OpenPlus = /*#__PURE__*/(/* unused pure expression or super */ null && (_createClass(function OpenPlus() {
  1016. var _this3 = this;
  1017. var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1018. _classCallCheck(this, OpenPlus);
  1019. _defineProperty(this, "openPre", function () {
  1020. var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
  1021. return null;
  1022. };
  1023. for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key3 = 1; _key3 < _len2; _key3++) {
  1024. rest[_key3 - 1] = arguments[_key3];
  1025. }
  1026. var win = _this3.open.apply(_this3, rest);
  1027. callback === null || callback === void 0 || callback();
  1028. return win;
  1029. });
  1030. _defineProperty(this, "open", function (href) {
  1031. var willOpenTab = _this3.win.tabsCacheOfOpenPlus[href];
  1032. for (var _len3 = arguments.length, rest = new Array(_len3 > 1 ? _len3 - 1 : 0), _key4 = 1; _key4 < _len3; _key4++) {
  1033. rest[_key4 - 1] = arguments[_key4];
  1034. }
  1035. if (willOpenTab === undefined) {
  1036. var _this3$win;
  1037. willOpenTab = (_this3$win = _this3.win).open.apply(_this3$win, [href].concat(rest));
  1038. _this3.win.nextOfOpenPlus.forEach(function (item) {
  1039. return item === null || item === void 0 ? void 0 : item();
  1040. });
  1041. return _this3.win.tabsCacheOfOpenPlus[href] = willOpenTab;
  1042. } else if (willOpenTab.closed === true) {
  1043. var _this3$win2;
  1044. return (_this3$win2 = _this3.win).open.apply(_this3$win2, [href].concat(rest));
  1045. } else if (willOpenTab.closed === false) {
  1046. willOpenTab.focus();
  1047. return willOpenTab;
  1048. }
  1049. });
  1050. var _opt$win = opt.win,
  1051. _win = _opt$win === void 0 ? window : _opt$win,
  1052. _opt$next = opt.next,
  1053. next = _opt$next === void 0 ? function () {
  1054. return null;
  1055. } : _opt$next;
  1056. this.win = _win;
  1057. this.win.tabsCacheOfOpenPlus = this.win.tabsCacheOfOpenPlus || {};
  1058. this.win.nextOfOpenPlus = this.win.nextOfOpenPlus || [];
  1059. this.win.nextOfOpenPlus.push(next);
  1060. })));
  1061. function modifyStorage() {
  1062. var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1063. var _opt$storageName = opt.storageName,
  1064. storageName = _opt$storageName === void 0 ? 'localStorage' : _opt$storageName,
  1065. chainKeys = opt.chainKeys,
  1066. _opt$doType = opt.doType,
  1067. doType = _opt$doType === void 0 ? 'get' : _opt$doType,
  1068. val = opt.val,
  1069. _opt$prefix = opt.prefix,
  1070. prefix = _opt$prefix === void 0 ? 'enjoy_setting' : _opt$prefix;
  1071. if (prefix) {
  1072. chainKeys = "".concat(prefix, ".").concat(chainKeys);
  1073. }
  1074. chainKeys = chainKeys.split('.');
  1075. var keyOfLevel1 = chainKeys.shift();
  1076. var keyOfEnd = chainKeys.pop();
  1077. var isObject = true;
  1078. var storage = null;
  1079. try {
  1080. storage = JSON.parse(window[storageName].getItem(keyOfLevel1));
  1081. } catch (error) {
  1082. isObject = false;
  1083. storage = window[storageName].getItem(keyOfLevel1);
  1084. console.error("".concat(storageName, " ").concat(chainKeys, " \u4E00\u7EA7\u5C5E\u6027\u503C\u4E3A\u57FA\u672C\u7C7B\u578B"));
  1085. return;
  1086. }
  1087. var obj = storage;
  1088. chainKeys.forEach(function (key) {
  1089. obj = obj[key];
  1090. });
  1091. if (doType === 'set') {
  1092. obj[keyOfEnd] = val;
  1093. window[storageName].setItem(keyOfLevel1, JSON.stringify(storage, null, 2));
  1094. } else {
  1095. return obj[keyOfEnd];
  1096. }
  1097. }
  1098.  
  1099. /**
  1100. * @description 简便的Storage SimpleStorage({ prefix: 'prefix' })
  1101. * @param {*} opt
  1102. */
  1103. function storagex() {
  1104. var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1105. var Storage = /*#__PURE__*/_createClass(function Storage() {
  1106. var _this4 = this;
  1107. var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1108. _classCallCheck(this, Storage);
  1109. _defineProperty(this, "storage", null);
  1110. _defineProperty(this, "setItem", function (keys, val) {
  1111. _this4.formatChainKeys(keys);
  1112. _this4.getFirstLevelVal();
  1113. _this4.chainVal('set', val);
  1114. return void 0;
  1115. });
  1116. _defineProperty(this, "getItem", function (keys) {
  1117. _this4.formatChainKeys(keys);
  1118. _this4.getFirstLevelVal();
  1119. return _this4.chainVal('get');
  1120. });
  1121. _defineProperty(this, "removeItem", function (keys) {
  1122. _this4.formatChainKeys(keys);
  1123. _this4.getFirstLevelVal();
  1124. return _this4.chainVal('remove');
  1125. });
  1126. _defineProperty(this, "clear", function () {
  1127. var keysWithPrefix = Object.keys(_this4.storage).filter(function (item) {
  1128. return item.startsWith(_this4.prefix);
  1129. });
  1130. keysWithPrefix.forEach(function (key) {
  1131. return _this4.storage.removeItem(key);
  1132. });
  1133. return void 0;
  1134. });
  1135. _defineProperty(this, "getFirstLevelVal", function () {
  1136. var state = _this4.storage[_this4.prefix + _this4.startKey];
  1137. try {
  1138. state = JSON.parse(state);
  1139. } catch (error) {}
  1140. _this4.cache = state;
  1141. return state;
  1142. });
  1143. _defineProperty(this, "formatChainKeys", function (keys) {
  1144. keys = keys.split('.');
  1145. _this4.startKey = keys.shift();
  1146. _this4.endKey = keys.pop();
  1147. _this4.middlekeys = keys;
  1148. return keys;
  1149. });
  1150. _defineProperty(this, "chainVal", function (doType, val) {
  1151. var obj = _this4.cache;
  1152. _this4.middlekeys.forEach(function (key) {
  1153. obj = obj[key];
  1154. });
  1155. if (doType === 'set') {
  1156. if (_this4.endKey) {
  1157. obj[_this4.endKey] = val;
  1158. } else {
  1159. _this4.cache = val;
  1160. }
  1161. _this4.storage.setItem(_this4.prefix + _this4.startKey, _this4.isObject(_this4.cache) ? JSON.stringify(_this4.cache, null, 2) : _this4.cache);
  1162. } else if (doType === 'get') {
  1163. if (_this4.endKey) {
  1164. return obj[_this4.endKey];
  1165. }
  1166. return _this4.cache;
  1167. } else if (doType === 'remove') {
  1168. if (_this4.endKey) {
  1169. var isDeleted = delete obj[_this4.endKey];
  1170. isDeleted && _this4.setItem(_this4.startKey, _this4.cache);
  1171. return isDeleted;
  1172. }
  1173. _this4.storage.removeItem(_this4.prefix + _this4.startKey);
  1174. }
  1175. });
  1176. _defineProperty(this, "isObject", function (value) {
  1177. var type = _typeof(value);
  1178. return value != null && (type === 'object' || type === 'function');
  1179. });
  1180. var prefix = opt.prefix,
  1181. storage = opt.storage;
  1182. this.prefix = prefix ? "".concat(prefix, "_") : '';
  1183. this.storage = storage;
  1184. });
  1185. if (opt.storage && sessionStorage.__proto__.setItemX) return opt.storage;
  1186. var storage = new Storage(opt);
  1187. if (opt.storage) return storage;
  1188. if (sessionStorage.__proto__.setItemX) return;
  1189. sessionStorage.__proto__.setItemX = function (key, val) {
  1190. storage.storage = this;
  1191. storage.setItem(key, val);
  1192. };
  1193. sessionStorage.__proto__.getItemX = function (key) {
  1194. storage.storage = this;
  1195. return storage.getItem(key);
  1196. };
  1197. sessionStorage.__proto__.removeItemX = function (key) {
  1198. storage.storage = this;
  1199. return storage.removeItem(key);
  1200. };
  1201. sessionStorage.__proto__.clearX = function () {
  1202. storage.storage = this;
  1203. return storage.clear();
  1204. };
  1205. }
  1206.  
  1207. /**
  1208. * @description 处理标记内容
  1209. * @param {*} opt
  1210. * @returns {*}
  1211. */
  1212. function operateComment(opt) {
  1213. var _opt$text = opt.text,
  1214. text = _opt$text === void 0 ? '' : _opt$text,
  1215. _opt$S = opt.S,
  1216. S = _opt$S === void 0 ? '/*' : _opt$S,
  1217. _opt$E = opt.E,
  1218. E = _opt$E === void 0 ? '*/' : _opt$E,
  1219. _opt$modify = opt.modify,
  1220. modify = _opt$modify === void 0 ? function (val) {
  1221. return val;
  1222. } : _opt$modify;
  1223. var stack = [];
  1224. var index = text.indexOf(S);
  1225. if (index === -1) return text;
  1226. while (index <= text.length - 1) {
  1227. if (text[index] + text[index + 1] == S) {
  1228. stack.push(index);
  1229. } else if (text[index] + text[index + 1] == E) {
  1230. var latestIndex = stack.pop();
  1231. if (latestIndex !== undefined) {
  1232. var middle = modify(text.slice(latestIndex + S.length, index));
  1233. text = text.slice(0, latestIndex) + middle + text.slice(index + S.length);
  1234. index = latestIndex + middle.length;
  1235. }
  1236. }
  1237. index++;
  1238. }
  1239. return text;
  1240. }
  1241.  
  1242. /** 添加动画函数 */
  1243. function addAnimation(dom, className) {
  1244. if (!dom || !className) return;
  1245. if (!dom.animationend) {
  1246. dom.animationend = function () {
  1247. dom.classList.remove(className);
  1248. };
  1249. }
  1250. dom.removeEventListener('animationend', dom.animationend);
  1251. dom.addEventListener('animationend', dom.animationend);
  1252. dom.classList.add(className);
  1253. }
  1254.  
  1255. // 判断当前浏览器运行环境
  1256. function getBrowserEnv() {
  1257. var userAgent = window.navigator.userAgent.toLowerCase();
  1258. var agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
  1259. // 是否为支付宝环境
  1260. var isAliPay = /alipayclient/.test(userAgent);
  1261. // 是否为淘宝环境
  1262. var isTaoBao = /windvane/.test(userAgent);
  1263. // 是否为企业微信环境
  1264. var isWxWork = /wxwork/.test(userAgent);
  1265. // 是否为微信环境
  1266. var isWeChat = /micromessenger/.test(userAgent) && !isWxWork;
  1267. // 是否为移动端
  1268. var isPhone = agents.some(function (x) {
  1269. return new RegExp(x.toLocaleLowerCase()).test(userAgent);
  1270. });
  1271. return {
  1272. isAliPay: isAliPay,
  1273. isTaoBao: isTaoBao,
  1274. isWxWork: isWxWork,
  1275. isWeChat: isWeChat,
  1276. isPhone: isPhone
  1277. };
  1278. }
  1279. var RegisterDbltouchEvent = /*#__PURE__*/(/* unused pure expression or super */ null && (function () {
  1280. function RegisterDbltouchEvent(el, fn) {
  1281. _classCallCheck(this, RegisterDbltouchEvent);
  1282. this.el = el || window;
  1283. this.callback = fn;
  1284. this.timer = null;
  1285. this.prevPosition = {};
  1286. this.isWaiting = false;
  1287.  
  1288. // 注册click事件,注意this指向
  1289. this.el.addEventListener('click', this.handleClick.bind(this), true);
  1290. }
  1291. return _createClass(RegisterDbltouchEvent, [{
  1292. key: "handleClick",
  1293. value: function handleClick(evt) {
  1294. var _this5 = this;
  1295. var pageX = evt.pageX;
  1296. var pageY = evt.pageY;
  1297. if (this.timer) {
  1298. clearTimeout(this.timer);
  1299. this.timer = null;
  1300. }
  1301. if (!evt.isTrusted) {
  1302. return;
  1303. }
  1304. if (this.isWaiting) {
  1305. this.isWaiting = false;
  1306. var diffX = Math.abs(pageX - this.prevPosition.pageX);
  1307. var diffY = Math.abs(pageY - this.prevPosition.pageY);
  1308. // 如果满足位移小于10,则是双击
  1309. if (diffX <= 10 && diffY <= 10) {
  1310. // 取消当前事件传递,并派发1个自定义双击事件
  1311. evt.stopPropagation();
  1312. evt.target.dispatchEvent(new PointerEvent('dbltouch', {
  1313. cancelable: false,
  1314. bubbles: true
  1315. }));
  1316. // 也可以采用回调函数的方式
  1317. this.callback && this.callback(evt);
  1318. }
  1319. } else {
  1320. this.prevPostion = {
  1321. pageX: pageX,
  1322. pageY: pageY
  1323. };
  1324. // 阻止冒泡,不让事件继续传播
  1325. evt.stopPropagation();
  1326. // 开始等待第2次点击
  1327. this.isWaiting = true;
  1328. // 设置200ms倒计时,200ms后重新派发当前事件
  1329. this.timer = setTimeout(function () {
  1330. _this5.isWaiting = false;
  1331. evt.target.dispatchEvent(evt);
  1332. }, 200);
  1333. }
  1334. }
  1335. }]);
  1336. }()));
  1337. /**移动端 双击 */
  1338. function addDbltouch() {
  1339. var dom = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
  1340. var handle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (event) {
  1341. console.log('双击', event, Date.now());
  1342. };
  1343. var preTimestamp = 0;
  1344. dom.addEventListener('click', function (event) {
  1345. var currentTimestamp = Date.now();
  1346. if (currentTimestamp - preTimestamp < 200) handle(event);
  1347. preTimestamp = currentTimestamp;
  1348. });
  1349. }
  1350.  
  1351. /**
  1352. * @description 获取dom
  1353. * @export
  1354. * @param {*} element
  1355. * @param {*} selector
  1356. * @param {number} [timeout=80]
  1357. * @param {boolean} [isAlways=true]
  1358. * @returns {*}
  1359. */
  1360. function getElement(_x, _x2) {
  1361. return _getElement.apply(this, arguments);
  1362. }
  1363.  
  1364. /**
  1365. * @description 分隔dom分区
  1366. * @param {*} e
  1367. * @param {number} [divideX=3]
  1368. * @param {*} [divideY=divideX]
  1369. * @returns {*} string
  1370. */
  1371. function _getElement() {
  1372. _getElement = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(element, selector) {
  1373. var timeout,
  1374. isAlways,
  1375. count,
  1376. _args = arguments;
  1377. return _regeneratorRuntime.wrap(function _callee$(_context) {
  1378. while (1) switch (_context.prev = _context.next) {
  1379. case 0:
  1380. timeout = _args.length > 2 && _args[2] !== undefined ? _args[2] : 80;
  1381. isAlways = _args.length > 3 && _args[3] !== undefined ? _args[3] : true;
  1382. count = 0;
  1383. return _context.abrupt("return", new Promise(function (resolve, reject) {
  1384. var timeId = setInterval(function () {
  1385. if (timeout && count++ >= timeout) {
  1386. clearInterval(timeId);
  1387. console.warn('[utils.getElement] Element is not find.' + ' selector: ' + selector);
  1388. // 保持原生逻辑,即未找到时,返回null,便于之后执行埋点,比如错误上报
  1389. return resolve(null);
  1390. }
  1391. var node = element.querySelector(selector);
  1392. if (node) {
  1393. //node 总是返回 或 显示状态条件下,找到后即刻返回
  1394. if (isAlways || node.offsetParent) {
  1395. resolve(node);
  1396. clearInterval(timeId);
  1397. }
  1398. }
  1399. }, 200);
  1400. }));
  1401. case 4:
  1402. case "end":
  1403. return _context.stop();
  1404. }
  1405. }, _callee);
  1406. }));
  1407. return _getElement.apply(this, arguments);
  1408. }
  1409. function divideDom(e) {
  1410. var divideX = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
  1411. var divideY = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : divideX;
  1412. if (!divideX) {
  1413. throw new Error('divideDom 函数 divideX 参数不能为空');
  1414. }
  1415. if (!divideY) {
  1416. divideX = divideY;
  1417. console.warn("divideDom \u51FD\u6570 dom \u5206\u533A \u4E3A ".concat(divideX, "*").concat(divideY));
  1418. }
  1419. var resultStr = "".concat(getIdx(e.target.offsetWidth, divideX, e.offsetX), "-").concat(getIdx(e.target.offsetHeight, divideY, e.offsetY));
  1420. console.log("resultStr => %O ", resultStr);
  1421. return resultStr;
  1422.  
  1423. // 获取坐标
  1424. function getIdx(size, divide, offsetPosition) {
  1425. var size_step = Math.ceil(size / divide);
  1426. var posi_idx = Math.floor(offsetPosition / size_step);
  1427. if (offsetPosition % size_step) {
  1428. posi_idx++;
  1429. }
  1430. return posi_idx;
  1431. }
  1432. }
  1433. ;// CONCATENATED MODULE: ./src/NpmjsUISetting.js
  1434.  
  1435. run();
  1436. function run() {
  1437. createElement('style', {
  1438. textContent: "\n #top {\n max-width: none !important;\n width: calc(100vw - 40px);\n }\n\n #top>:nth-child(3) {\n width: calc(100% - 320px) !important;\n max-width: none !important;\n }\n\n #top>:nth-child(4) {\n width: 320px !important;\n overflow-y: auto;\n max-height: 100vh;\n position: sticky;\n top: 0;\n }\n/*\n [aria-labelledby*=link] {\n white-space: pre-line;\n display: flex;\n word-break: break-all;\n\n }\n\n [aria-labelledby*=link]>:nth-child(2) {\n text-decoration: underline;\n }\n\n #top> :nth-child(4)> :nth-child(2) {\n position: sticky;\n top: 0px;\n background: #FFF;\n box-shadow: 0px 0px 0px 7px #fff\n }\n\n #top> :nth-child(4)> :nth-child(3) {\n position: sticky;\n top: 33px;\n background: #FFF;\n }\n\n #top> :nth-child(4)> :nth-child(4) {\n position: sticky;\n top: 79px;\n background: #FFF;\n }\n #top> :nth-child(4)> :nth-child(5) {\n position: sticky;\n top: 204px;\n background: #FFF;\n }\n */\n "
  1439. });
  1440. }
  1441. })();
  1442.  
  1443. /******/ })()
  1444. ;