边读边看图

功能一览:1、图文对照: 双击把图片固定在页面上,同时支持缩放、移动功能,便于图文对照阅读; 2、图片背景图: 使用浏览器查看在线图片或本地图片时,增加页面背景图,以便清晰显示当前图片轮廓 3、命名链接:打开链接方式,总是以命名的新窗口,跳转同一个链接页面,只激活,不刷新;4、快捷链接:点击链接文本时,跳转相应链接页面;5、鼠标选完文字后,(0.5秒内)立马松开左键,自动复制文字;反之,保持鼠标不移动超过 0.5秒后再松开,不会复制文字; 6、一键复制代码块:鼠标悬浮代码块后,点击显示的红色边框,复制到剪贴板 7、CSDN:仅在主动触发登录时,显示登录弹层 【最后:1、localStorage中,支持配置】

Versione datata 13/11/2024. Vedi la nuova versione l'ultima versione.

  1. // ==UserScript==
  2. // @name 边读边看图
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.8.70
  5. // @description 功能一览:1、图文对照: 双击把图片固定在页面上,同时支持缩放、移动功能,便于图文对照阅读; 2、图片背景图: 使用浏览器查看在线图片或本地图片时,增加页面背景图,以便清晰显示当前图片轮廓 3、命名链接:打开链接方式,总是以命名的新窗口,跳转同一个链接页面,只激活,不刷新;4、快捷链接:点击链接文本时,跳转相应链接页面;5、鼠标选完文字后,(0.5秒内)立马松开左键,自动复制文字;反之,保持鼠标不移动超过 0.5秒后再松开,不会复制文字; 6、一键复制代码块:鼠标悬浮代码块后,点击显示的红色边框,复制到剪贴板 7、CSDN:仅在主动触发登录时,显示登录弹层 【最后:1、localStorage中,支持配置】
  6. // @author Enjoy
  7. // @icon https://foruda.gitee.com/avatar/1698283059572409586/4867929_enjoy_li_1698283059.png!avatar200
  8. // @match *://*/*
  9. // @match file:///*
  10. // @exclude *localhost*
  11. // @grant GM_addElement
  12. // @grant GM_setClipboard
  13. // @license GPL License
  14. // 函数文档 https://www.tampermonkey.net/documentation.php#api:GM_addElement
  15. // @homepageURL https://greasyfork.org/zh-CN/scripts/456560
  16. // ==/UserScript==
  17.  
  18. /******/ (() => { // webpackBootstrap
  19. /******/ var __webpack_modules__ = ({
  20.  
  21. /***/ 342:
  22. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  23.  
  24. var _typeof = (__webpack_require__(882)["default"]);
  25. function _regeneratorRuntime() {
  26. "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
  27. module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
  28. return e;
  29. }, module.exports.__esModule = true, module.exports["default"] = module.exports;
  30. var t,
  31. e = {},
  32. r = Object.prototype,
  33. n = r.hasOwnProperty,
  34. o = Object.defineProperty || function (t, e, r) {
  35. t[e] = r.value;
  36. },
  37. i = "function" == typeof Symbol ? Symbol : {},
  38. a = i.iterator || "@@iterator",
  39. c = i.asyncIterator || "@@asyncIterator",
  40. u = i.toStringTag || "@@toStringTag";
  41. function define(t, e, r) {
  42. return Object.defineProperty(t, e, {
  43. value: r,
  44. enumerable: !0,
  45. configurable: !0,
  46. writable: !0
  47. }), t[e];
  48. }
  49. try {
  50. define({}, "");
  51. } catch (t) {
  52. define = function define(t, e, r) {
  53. return t[e] = r;
  54. };
  55. }
  56. function wrap(t, e, r, n) {
  57. var i = e && e.prototype instanceof Generator ? e : Generator,
  58. a = Object.create(i.prototype),
  59. c = new Context(n || []);
  60. return o(a, "_invoke", {
  61. value: makeInvokeMethod(t, r, c)
  62. }), a;
  63. }
  64. function tryCatch(t, e, r) {
  65. try {
  66. return {
  67. type: "normal",
  68. arg: t.call(e, r)
  69. };
  70. } catch (t) {
  71. return {
  72. type: "throw",
  73. arg: t
  74. };
  75. }
  76. }
  77. e.wrap = wrap;
  78. var h = "suspendedStart",
  79. l = "suspendedYield",
  80. f = "executing",
  81. s = "completed",
  82. y = {};
  83. function Generator() {}
  84. function GeneratorFunction() {}
  85. function GeneratorFunctionPrototype() {}
  86. var p = {};
  87. define(p, a, function () {
  88. return this;
  89. });
  90. var d = Object.getPrototypeOf,
  91. v = d && d(d(values([])));
  92. v && v !== r && n.call(v, a) && (p = v);
  93. var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
  94. function defineIteratorMethods(t) {
  95. ["next", "throw", "return"].forEach(function (e) {
  96. define(t, e, function (t) {
  97. return this._invoke(e, t);
  98. });
  99. });
  100. }
  101. function AsyncIterator(t, e) {
  102. function invoke(r, o, i, a) {
  103. var c = tryCatch(t[r], t, o);
  104. if ("throw" !== c.type) {
  105. var u = c.arg,
  106. h = u.value;
  107. return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
  108. invoke("next", t, i, a);
  109. }, function (t) {
  110. invoke("throw", t, i, a);
  111. }) : e.resolve(h).then(function (t) {
  112. u.value = t, i(u);
  113. }, function (t) {
  114. return invoke("throw", t, i, a);
  115. });
  116. }
  117. a(c.arg);
  118. }
  119. var r;
  120. o(this, "_invoke", {
  121. value: function value(t, n) {
  122. function callInvokeWithMethodAndArg() {
  123. return new e(function (e, r) {
  124. invoke(t, n, e, r);
  125. });
  126. }
  127. return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
  128. }
  129. });
  130. }
  131. function makeInvokeMethod(e, r, n) {
  132. var o = h;
  133. return function (i, a) {
  134. if (o === f) throw Error("Generator is already running");
  135. if (o === s) {
  136. if ("throw" === i) throw a;
  137. return {
  138. value: t,
  139. done: !0
  140. };
  141. }
  142. for (n.method = i, n.arg = a;;) {
  143. var c = n.delegate;
  144. if (c) {
  145. var u = maybeInvokeDelegate(c, n);
  146. if (u) {
  147. if (u === y) continue;
  148. return u;
  149. }
  150. }
  151. if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
  152. if (o === h) throw o = s, n.arg;
  153. n.dispatchException(n.arg);
  154. } else "return" === n.method && n.abrupt("return", n.arg);
  155. o = f;
  156. var p = tryCatch(e, r, n);
  157. if ("normal" === p.type) {
  158. if (o = n.done ? s : l, p.arg === y) continue;
  159. return {
  160. value: p.arg,
  161. done: n.done
  162. };
  163. }
  164. "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
  165. }
  166. };
  167. }
  168. function maybeInvokeDelegate(e, r) {
  169. var n = r.method,
  170. o = e.iterator[n];
  171. 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;
  172. var i = tryCatch(o, e.iterator, r.arg);
  173. if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
  174. var a = i.arg;
  175. 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);
  176. }
  177. function pushTryEntry(t) {
  178. var e = {
  179. tryLoc: t[0]
  180. };
  181. 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
  182. }
  183. function resetTryEntry(t) {
  184. var e = t.completion || {};
  185. e.type = "normal", delete e.arg, t.completion = e;
  186. }
  187. function Context(t) {
  188. this.tryEntries = [{
  189. tryLoc: "root"
  190. }], t.forEach(pushTryEntry, this), this.reset(!0);
  191. }
  192. function values(e) {
  193. if (e || "" === e) {
  194. var r = e[a];
  195. if (r) return r.call(e);
  196. if ("function" == typeof e.next) return e;
  197. if (!isNaN(e.length)) {
  198. var o = -1,
  199. i = function next() {
  200. for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
  201. return next.value = t, next.done = !0, next;
  202. };
  203. return i.next = i;
  204. }
  205. }
  206. throw new TypeError(_typeof(e) + " is not iterable");
  207. }
  208. return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
  209. value: GeneratorFunctionPrototype,
  210. configurable: !0
  211. }), o(GeneratorFunctionPrototype, "constructor", {
  212. value: GeneratorFunction,
  213. configurable: !0
  214. }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
  215. var e = "function" == typeof t && t.constructor;
  216. return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
  217. }, e.mark = function (t) {
  218. return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
  219. }, e.awrap = function (t) {
  220. return {
  221. __await: t
  222. };
  223. }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
  224. return this;
  225. }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
  226. void 0 === i && (i = Promise);
  227. var a = new AsyncIterator(wrap(t, r, n, o), i);
  228. return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
  229. return t.done ? t.value : a.next();
  230. });
  231. }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
  232. return this;
  233. }), define(g, "toString", function () {
  234. return "[object Generator]";
  235. }), e.keys = function (t) {
  236. var e = Object(t),
  237. r = [];
  238. for (var n in e) r.push(n);
  239. return r.reverse(), function next() {
  240. for (; r.length;) {
  241. var t = r.pop();
  242. if (t in e) return next.value = t, next.done = !1, next;
  243. }
  244. return next.done = !0, next;
  245. };
  246. }, e.values = values, Context.prototype = {
  247. constructor: Context,
  248. reset: function reset(e) {
  249. 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);
  250. },
  251. stop: function stop() {
  252. this.done = !0;
  253. var t = this.tryEntries[0].completion;
  254. if ("throw" === t.type) throw t.arg;
  255. return this.rval;
  256. },
  257. dispatchException: function dispatchException(e) {
  258. if (this.done) throw e;
  259. var r = this;
  260. function handle(n, o) {
  261. return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
  262. }
  263. for (var o = this.tryEntries.length - 1; o >= 0; --o) {
  264. var i = this.tryEntries[o],
  265. a = i.completion;
  266. if ("root" === i.tryLoc) return handle("end");
  267. if (i.tryLoc <= this.prev) {
  268. var c = n.call(i, "catchLoc"),
  269. u = n.call(i, "finallyLoc");
  270. if (c && u) {
  271. if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
  272. if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
  273. } else if (c) {
  274. if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
  275. } else {
  276. if (!u) throw Error("try statement without catch or finally");
  277. if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
  278. }
  279. }
  280. }
  281. },
  282. abrupt: function abrupt(t, e) {
  283. for (var r = this.tryEntries.length - 1; r >= 0; --r) {
  284. var o = this.tryEntries[r];
  285. if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
  286. var i = o;
  287. break;
  288. }
  289. }
  290. i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
  291. var a = i ? i.completion : {};
  292. return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
  293. },
  294. complete: function complete(t, e) {
  295. if ("throw" === t.type) throw t.arg;
  296. 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;
  297. },
  298. finish: function finish(t) {
  299. for (var e = this.tryEntries.length - 1; e >= 0; --e) {
  300. var r = this.tryEntries[e];
  301. if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
  302. }
  303. },
  304. "catch": function _catch(t) {
  305. for (var e = this.tryEntries.length - 1; e >= 0; --e) {
  306. var r = this.tryEntries[e];
  307. if (r.tryLoc === t) {
  308. var n = r.completion;
  309. if ("throw" === n.type) {
  310. var o = n.arg;
  311. resetTryEntry(r);
  312. }
  313. return o;
  314. }
  315. }
  316. throw Error("illegal catch attempt");
  317. },
  318. delegateYield: function delegateYield(e, r, n) {
  319. return this.delegate = {
  320. iterator: values(e),
  321. resultName: r,
  322. nextLoc: n
  323. }, "next" === this.method && (this.arg = t), y;
  324. }
  325. }, e;
  326. }
  327. module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
  328.  
  329. /***/ }),
  330.  
  331. /***/ 882:
  332. /***/ ((module) => {
  333.  
  334. function _typeof(o) {
  335. "@babel/helpers - typeof";
  336.  
  337. return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
  338. return typeof o;
  339. } : function (o) {
  340. return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
  341. }, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
  342. }
  343. module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
  344.  
  345. /***/ }),
  346.  
  347. /***/ 501:
  348. /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
  349.  
  350. // TODO(Babel 8): Remove this file.
  351.  
  352. var runtime = __webpack_require__(342)();
  353. module.exports = runtime;
  354.  
  355. // Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
  356. try {
  357. regeneratorRuntime = runtime;
  358. } catch (accidentalStrictMode) {
  359. if (typeof globalThis === "object") {
  360. globalThis.regeneratorRuntime = runtime;
  361. } else {
  362. Function("r", "regeneratorRuntime = r")(runtime);
  363. }
  364. }
  365.  
  366.  
  367. /***/ })
  368.  
  369. /******/ });
  370. /************************************************************************/
  371. /******/ // The module cache
  372. /******/ var __webpack_module_cache__ = {};
  373. /******/
  374. /******/ // The require function
  375. /******/ function __webpack_require__(moduleId) {
  376. /******/ // Check if module is in cache
  377. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  378. /******/ if (cachedModule !== undefined) {
  379. /******/ return cachedModule.exports;
  380. /******/ }
  381. /******/ // Create a new module (and put it into the cache)
  382. /******/ var module = __webpack_module_cache__[moduleId] = {
  383. /******/ // no module.id needed
  384. /******/ // no module.loaded needed
  385. /******/ exports: {}
  386. /******/ };
  387. /******/
  388. /******/ // Execute the module function
  389. /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
  390. /******/
  391. /******/ // Return the exports of the module
  392. /******/ return module.exports;
  393. /******/ }
  394. /******/
  395. /************************************************************************/
  396. /******/ /* webpack/runtime/compat get default export */
  397. /******/ (() => {
  398. /******/ // getDefaultExport function for compatibility with non-harmony modules
  399. /******/ __webpack_require__.n = (module) => {
  400. /******/ var getter = module && module.__esModule ?
  401. /******/ () => (module['default']) :
  402. /******/ () => (module);
  403. /******/ __webpack_require__.d(getter, { a: getter });
  404. /******/ return getter;
  405. /******/ };
  406. /******/ })();
  407. /******/
  408. /******/ /* webpack/runtime/define property getters */
  409. /******/ (() => {
  410. /******/ // define getter functions for harmony exports
  411. /******/ __webpack_require__.d = (exports, definition) => {
  412. /******/ for(var key in definition) {
  413. /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
  414. /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
  415. /******/ }
  416. /******/ }
  417. /******/ };
  418. /******/ })();
  419. /******/
  420. /******/ /* webpack/runtime/hasOwnProperty shorthand */
  421. /******/ (() => {
  422. /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
  423. /******/ })();
  424. /******/
  425. /************************************************************************/
  426. // This entry need to be wrapped in an IIFE because it need to be in strict mode.
  427. (() => {
  428. "use strict";
  429.  
  430. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/typeof.js
  431. function typeof_typeof(o) {
  432. "@babel/helpers - typeof";
  433.  
  434. return typeof_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
  435. return typeof o;
  436. } : function (o) {
  437. return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
  438. }, typeof_typeof(o);
  439. }
  440.  
  441. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/toPrimitive.js
  442.  
  443. function toPrimitive(t, r) {
  444. if ("object" != typeof_typeof(t) || !t) return t;
  445. var e = t[Symbol.toPrimitive];
  446. if (void 0 !== e) {
  447. var i = e.call(t, r || "default");
  448. if ("object" != typeof_typeof(i)) return i;
  449. throw new TypeError("@@toPrimitive must return a primitive value.");
  450. }
  451. return ("string" === r ? String : Number)(t);
  452. }
  453.  
  454. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
  455.  
  456.  
  457. function toPropertyKey(t) {
  458. var i = toPrimitive(t, "string");
  459. return "symbol" == typeof_typeof(i) ? i : i + "";
  460. }
  461.  
  462. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/createClass.js
  463.  
  464. function _defineProperties(e, r) {
  465. for (var t = 0; t < r.length; t++) {
  466. var o = r[t];
  467. o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, toPropertyKey(o.key), o);
  468. }
  469. }
  470. function createClass_createClass(e, r, t) {
  471. return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
  472. writable: !1
  473. }), e;
  474. }
  475.  
  476. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/classCallCheck.js
  477. function classCallCheck_classCallCheck(a, n) {
  478. if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
  479. }
  480.  
  481. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/defineProperty.js
  482.  
  483. function defineProperty_defineProperty(e, r, t) {
  484. return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
  485. value: t,
  486. enumerable: !0,
  487. configurable: !0,
  488. writable: !0
  489. }) : e[r] = t, e;
  490. }
  491.  
  492. // EXTERNAL MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/regenerator/index.js
  493. var regenerator = __webpack_require__(501);
  494. var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator);
  495. ;// CONCATENATED MODULE: ./tools/GM.js
  496.  
  497.  
  498.  
  499.  
  500.  
  501.  
  502. 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; }
  503. 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_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; }
  504. /** @描述 函数文档 https://www.tampermonkey.net/documentation.php#api:GM_addElement */
  505.  
  506. /**
  507. * @description 创建element
  508. * @export
  509. * @param {*} tag
  510. * @param {*} [options={}]
  511. * @param {*} [win=window]
  512. * @returns {*}
  513. */
  514. function createElement(tag) {
  515. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  516. var win = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : window;
  517. if (!win.GM_createElement) {
  518. win.GM_createElement = GM_createElement;
  519. }
  520. return GM_createElement(tag, options);
  521. /**
  522. * @param {*} tag
  523. * @param {*} options {
  524. * idPrefix = `enjoy_${ENV_CRX}_${tag}`,
  525. * el = 'html',
  526. * autoInsert = true,
  527. * randomType = 'single',
  528. * id = '',
  529. * addPrefix = true,
  530. * insertType = tag === 'style' ? 'appendChild' : 'prepend',
  531. * }
  532. * @returns {*} dom
  533. */
  534. function GM_createElement(tag, options) {
  535. var _options$idPrefix = options.idPrefix,
  536. idPrefix = _options$idPrefix === void 0 ? "enjoy_".concat("ImgPreview", "_").concat(tag, "_") : _options$idPrefix,
  537. _options$el = options.el,
  538. el = _options$el === void 0 ? 'html' : _options$el,
  539. _options$autoInsert = options.autoInsert,
  540. autoInsert = _options$autoInsert === void 0 ? true : _options$autoInsert,
  541. _options$randomType = options.randomType,
  542. randomType = _options$randomType === void 0 ? 'single' : _options$randomType,
  543. _options$id = options.id,
  544. id = _options$id === void 0 ? '' : _options$id,
  545. _options$addPrefix = options.addPrefix,
  546. addPrefix = _options$addPrefix === void 0 ? true : _options$addPrefix,
  547. _options$insertType = options.insertType,
  548. insertType = _options$insertType === void 0 ? tag === 'style' ? 'appendChild' : 'prepend' : _options$insertType;
  549. if (addPrefix) {
  550. id = "".concat(idPrefix).concat(id);
  551. }
  552. if (randomType !== 'single') {
  553. id = "".concat(id, "_").concat(Math.floor(Math.random() * 1000));
  554. }
  555. options.id = id;
  556. var dom = document.querySelector("#".concat(id));
  557. if (!dom) {
  558. dom = document.createElement(tag);
  559. }
  560. for (var key in options) {
  561. if (Object.hasOwnProperty.call(options, key) && key !== 'el') {
  562. dom[key] = options[key];
  563. }
  564. }
  565. if (autoInsert) {
  566. if (typeof el === 'string') {
  567. el = document.querySelector(el);
  568. }
  569.  
  570. //insertType prepend | appendChild
  571. el[insertType](dom);
  572. }
  573. return dom;
  574. }
  575. }
  576.  
  577. /** @描述 是否匹配到目标url */
  578. function isMatched() {
  579. var urls = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  580. var currentUrl = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : location.href;
  581. if (typeof urls === 'string') {
  582. urls = [urls];
  583. }
  584. return !!urls.find(function (regUrl) {
  585. return new RegExp(regUrl).test(currentUrl);
  586. });
  587. }
  588. function prependMetaUF8() {
  589. return document.querySelector('meta[charset="UTF-8"]') || createElement('meta', {
  590. charset: 'utf-8'
  591. });
  592. }
  593.  
  594. /**
  595. * @description doCopy 复制文本到剪贴板
  596. * @export
  597. * @param {*} text
  598. */
  599. function doCopy(text) {
  600. var _navigator;
  601. if (document.hasFocus() && (_navigator = navigator) !== null && _navigator !== void 0 && (_navigator = _navigator.clipboard) !== null && _navigator !== void 0 && _navigator.writeText) {
  602. // localhost、127.0.0.1或者https中才能正常使用
  603. // 读取剪贴板
  604. // navigator.clipboard.readText().then((clipText) => {console.log('clipText=',clipText)})
  605.  
  606. // 写入剪贴板
  607. navigator.clipboard.writeText(text)["catch"](function (err) {
  608. return console.error("clipboard.writeText\uFF1A".concat(err));
  609. });
  610. return;
  611. }
  612. var textarea = document.createElement('textarea');
  613. document.body.appendChild(textarea);
  614. textarea.value = text;
  615. textarea.select();
  616. document.execCommand('Copy');
  617. setTimeout(function () {
  618. textarea.remove();
  619. }, 1000);
  620. }
  621.  
  622. /**
  623. * 检测element元素的可见性,即 非display:none
  624. * @param {*} element
  625. * @returns {*} {Boolean}
  626. */
  627. function checkVisibility(element) {
  628. if (element.checkVisibility) {
  629. return element.checkVisibility();
  630. }
  631. return !!element.offsetParent;
  632. }
  633. /**
  634. * @description 创建element的提示
  635. * @export
  636. * @param {*} [options={}]
  637. * @returns {*}
  638. */
  639. function createElementTipFn() {
  640. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  641. var _options$setTimeoutSt = options.setTimeoutStep,
  642. setTimeoutStep = _options$setTimeoutSt === void 0 ? 1000 : _options$setTimeoutSt,
  643. _options$backgroundCo = options.backgroundColors,
  644. backgroundColors = _options$backgroundCo === void 0 ? {
  645. warn: 'rgb(181 156 51 / 60%)',
  646. success: 'rgb(3 113 3 / 60%)',
  647. error: 'rgb(165 2 2 / 60%)',
  648. info: 'rgb(67 62 62 / 60%)'
  649. } : _options$backgroundCo,
  650. _options$color = options.color,
  651. color = _options$color === void 0 ? '#ffffff' : _options$color,
  652. _options$opacity = options.opacity,
  653. opacity = _options$opacity === void 0 ? 1 : _options$opacity;
  654. var setTimeoutStamp = 0;
  655. return function createElementTip() {
  656. var configs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  657. var content = configs.content,
  658. e = configs.e,
  659. _configs$type = configs.type,
  660. type = _configs$type === void 0 ? 'info' : _configs$type,
  661. _configs$tagType = configs.tagType,
  662. tagType = _configs$tagType === void 0 ? 'span' : _configs$tagType;
  663. if (!content) return;
  664. console.log("content => %O ", content);
  665. clearTimeout(setTimeoutStamp);
  666. var contentDom = createElement(tagType, {
  667. id: 'createElementTip',
  668. innerText: content,
  669. 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 ")
  670. });
  671. setTimeoutStamp = setTimeout(function () {
  672. // contentDom.remove()
  673. contentDom.style.display = 'none';
  674. }, setTimeoutStep);
  675. };
  676. }
  677. /**
  678. * @description dom是否可编辑
  679. * @param {*} [dom=document.activeElement]
  680. * @returns {*} {boolean}
  681. */
  682.  
  683. function isContentEditableOfDOM() {
  684. var dom = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : document.activeElement;
  685. if (dom.tagName === 'INPUT' || dom.tagName === 'TEXTAREA') {
  686. return !dom.disabled;
  687. } else {
  688. return !!findParentElement(dom, function (dom) {
  689. return dom.contentEditable === 'true';
  690. }, null);
  691. }
  692. }
  693.  
  694. /**
  695. * @description 数字区间
  696. * @param {*} val
  697. * @param {*} [interval=[10, window.innerWidth]]
  698. * @returns {*}
  699. */
  700. function numbericalInterval(val) {
  701. var interval = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [5, window.innerWidth - 130];
  702. var indexStart = interval[0];
  703. var indexEnd = interval[1];
  704. if (val < indexStart) return indexStart;
  705. if (val > indexEnd) return indexEnd;
  706. return val;
  707. }
  708.  
  709. /**
  710. * @description 可滚动的dom
  711. * @param {*} dom
  712. * @returns {*}
  713. */
  714. function findHasScrollbarDom(dom) {
  715. if (!(dom instanceof HTMLElement)) {
  716. console.warn("\u53EF\u6EDA\u52A8\u7684dom\u51FD\u6570 findHasScrollbarDom:\u53C2\u6570dom\u5FC5\u987B\u4E3Aelement\u5143\u7D20 ");
  717. return void 0;
  718. }
  719. while (dom) {
  720. if (dom.offsetHeight < dom.scrollHeight && !(window.getComputedStyle(dom).overflowY == 'visible' || window.getComputedStyle(dom).overflowY == 'hidden')) {
  721. break;
  722. }
  723. dom = dom.parentElement;
  724. }
  725. if (!dom || dom === document.body) {
  726. // 始终是 documentElement等同于window
  727. dom = document.documentElement;
  728. }
  729. console.warn("\u9875\u9762\u6EDA\u52A8\u5143\u7D20\u7684tagName: ", dom.tagName.toLocaleLowerCase(), 'dom.className:', dom.className);
  730. return dom;
  731. }
  732.  
  733. /**
  734. * @description 获取方法配置
  735. * @param {string} [key='']
  736. * @param {*} [defaultOpt={ includedUrls: [] }]
  737. * @returns {*} {Object}
  738. **/
  739. function getSettingFromLocalStorage() {
  740. var fileName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  741. var defaultOpt = arguments.length > 1 ? arguments[1] : undefined;
  742. var mergedSettingOpt = _objectSpread({
  743. runType: '0',
  744. includedUrls: [],
  745. excludeUrls: []
  746. }, defaultOpt);
  747. var fullSettingKey = "enjoy_setting";
  748. var storageData = localStorage.getItem(fullSettingKey);
  749. var fullSettings = storageData ? JSON.parse(storageData) : {};
  750. var SETTING = _objectSpread(_objectSpread({}, mergedSettingOpt), fullSettings === null || fullSettings === void 0 ? void 0 : fullSettings[fileName]);
  751. fullSettings[fileName] = SETTING;
  752. fullSettings.runTypeDest = undefined;
  753. 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";
  754. localStorage.setItem(fullSettingKey, JSON.stringify(fullSettings || {}, null, 2));
  755. return SETTING;
  756. }
  757.  
  758. /**
  759. * @description 是否执行该方法
  760. * @param {*} [settingOpt={}]
  761. * @returns {*} {Boolean}
  762. */
  763. function isExcutableBySetting() {
  764. var settingOpt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  765. var runType = settingOpt.runType,
  766. _settingOpt$excludeUr = settingOpt.excludeUrls,
  767. excludeUrls = _settingOpt$excludeUr === void 0 ? [] : _settingOpt$excludeUr,
  768. _settingOpt$includedU = settingOpt.includedUrls,
  769. includedUrls = _settingOpt$includedU === void 0 ? [] : _settingOpt$includedU;
  770. if (runType == '1') return true;
  771. if (runType == '2') return false;
  772. var HREF = location.href;
  773. if (excludeUrls !== null && excludeUrls !== void 0 && excludeUrls.length && isMatched(excludeUrls, HREF)) {
  774. return false;
  775. }
  776. if ((includedUrls === null || includedUrls === void 0 ? void 0 : includedUrls.length) === 0) return true;
  777. var findOne = isMatched(includedUrls, HREF);
  778. return !!findOne;
  779. }
  780.  
  781. /**
  782. * @description 是否不执行
  783. * @param {String} fileName
  784. * @param {Object} settingOpt { excludeUrls: [ ],feature:"feature",includedUrls: [ ],name: "name",runType: "0",}
  785. * @returns {Boolean}
  786. */
  787. function codeIsNotExcutable(fileName, settingOpt) {
  788. try {
  789. // logSettingOptWithColor()
  790. var setting = getSettingFromLocalStorage(fileName, settingOpt);
  791. return _objectSpread({
  792. notExcutable: !isExcutableBySetting(setting)
  793. }, setting);
  794. } catch (error) {
  795. // base64路径下,禁用storage
  796. console.error(error);
  797. return _objectSpread({
  798. notExcutable: true
  799. }, settingOpt);
  800. }
  801. }
  802.  
  803. /**
  804. * @description 彩色打印
  805. * @param {string} [key='enjoy_setting']
  806. */
  807. function logSettingOptWithColor(key) {
  808. var dataKey = 'is-log-of-enjoy';
  809. if (true) return;
  810. // if (document.body.getAttribute(dataKey)) return
  811. document.body.setAttribute(dataKey, '1');
  812.  
  813. // clearTimeout(window.EnjoyColorLogTimer || 0)
  814. window.EnjoyColorLogTimer = setTimeout(function () {
  815. var _key;
  816. (_key = key) !== null && _key !== void 0 ? _key : key = 'enjoy_setting';
  817. var SETTINGS = JSON.parse(localStorage[key] || '{}');
  818. console.log("%c\uD83D\uDC47 ".concat(key, " \u8BBE\u7F6E\u53C2\u6570\uFF1A"), 'background:#4e0ab780;color:#fff;', '\n', SETTINGS, "\n\nkeyNameList:", Object.keys(SETTINGS));
  819. 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)");
  820. }, 3 * 1000);
  821. }
  822. /**
  823. * @description 修改运行机制
  824. * @export
  825. * @param {string} keyName
  826. * @param {0|1|2} runType
  827. */
  828. function modifyRuntype(keyName, runType) {
  829. var keyOfSETTINGS = 'enjoy_setting';
  830. var SETTINGS = JSON.parse(localStorage.getItem(keyOfSETTINGS) || '{}');
  831. if (!SETTINGS[keyName]) return;
  832. SETTINGS[keyName].runType = runType || 2;
  833. localStorage.setItem(keyOfSETTINGS, JSON.stringify(SETTINGS, null, 2));
  834. }
  835.  
  836. /**
  837. * @description 查找特定条件的父级元素
  838. * @export
  839. * @param {Element} dom
  840. * @param {Function} callback
  841. * @param {Element} [defaultVal=document.documentElement]
  842. * @returns {Element}
  843. */
  844. function findParentElement(dom, callback) {
  845. var defaultVal = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : document.documentElement;
  846. if (!(dom instanceof HTMLElement)) {
  847. console.warn("\u67E5\u627E\u7279\u5B9A\u6761\u4EF6\u7684\u7236\u7EA7\u5143\u7D20\u51FD\u6570 findParentElement:\u53C2\u6570dom\u5FC5\u987B\u4E3Aelement\u5143\u7D20 ");
  848. return void 0;
  849. }
  850. while (dom) {
  851. if (callback(dom)) {
  852. break;
  853. }
  854. dom = dom.parentElement;
  855. }
  856. if (!dom || dom === document.body) {
  857. // 始终是 documentElement等同于window
  858. dom = defaultVal;
  859. }
  860. return dom;
  861. }
  862.  
  863. /** 原生横向滚动条 吸附 页面底部 */
  864. var StickyHorizontalNativeScrollBar = /*#__PURE__*/(/* unused pure expression or super */ null && (_createClass(function StickyHorizontalNativeScrollBar() {
  865. var _this = this;
  866. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  867. _classCallCheck(this, StickyHorizontalNativeScrollBar);
  868. /** 创建滚轴组件元素 */
  869. _defineProperty(this, "createScrollbar", function () {
  870. var style = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
  871. if (_this.scrollbar) return _this.scrollbar;
  872. var timer = Date.now();
  873. _this.thumbId = "thumb".concat(timer);
  874. _this.scrollbarId = "scrollbar".concat(timer);
  875. _this.scrollbar = document.createElement('div');
  876. _this.scrollbar.setAttribute('id', _this.scrollbarId);
  877. _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");
  878. });
  879. /** 把滚轴组件元素插入目标元素的后面 */
  880. _defineProperty(this, "insertScrollbar", function (el) {
  881. _this.target = el;
  882. if (typeof el === 'string') {
  883. _this.target = document.querySelector(el);
  884. }
  885. if (!_this.target) throw Error('el Dom do not exit');
  886. _this.targetParentElement = document.querySelector(el).parentElement;
  887. if (!_this.targetParentElement.querySelector("#".concat(_this.scrollbarId))) {
  888. _this.targetParentElement.insertBefore(_this.scrollbar, _this.target.nextSibling);
  889. }
  890. return _this.target;
  891. });
  892. /** 设置 滚轴组件元素尺寸 */
  893. _defineProperty(this, "setScrollbarSize", throttle(function () {
  894. _this.scrollbar.style.width = _this.target.clientWidth + 'px';
  895. _this.scrollbar.querySelector("#".concat(_this.thumbId)).style.width = _this.target.scrollWidth + 'px';
  896. }, 100));
  897. /** 监听目标元素和滚轴元素的scroll和页面resize事件 */
  898. _defineProperty(this, "onEvent", function () {
  899. _this.target.addEventListener('scroll', _this.onScrollTarget);
  900. _this.scrollbar.addEventListener('scroll', _this.onScrollScrollbar);
  901. window.addEventListener('resize', _this.setScrollbarSize);
  902. });
  903. /** 移除事件 */
  904. _defineProperty(this, "removeEvent", function () {
  905. _this.target.removeEventListener('scroll', _this.onScrollTarget);
  906. _this.scrollbar.removeEventListener('scroll', _this.onScrollScrollbar);
  907. window.removeEventListener('resize', _this.setScrollbarSize);
  908. });
  909. _defineProperty(this, "onScrollTarget", throttle(function (e) {
  910. _this.scrollbar.scrollLeft = e.target.scrollLeft;
  911. }, 100));
  912. _defineProperty(this, "onScrollScrollbar", throttle(function (e) {
  913. _this.target.scrollLeft = e.target.scrollLeft;
  914. }, 100));
  915. var _el = options.el,
  916. _options$style = options.style,
  917. _style = _options$style === void 0 ? '' : _options$style;
  918. this.createScrollbar(_style);
  919. this.insertScrollbar(_el);
  920. this.setScrollbarSize();
  921. this.onEvent();
  922. })));
  923.  
  924. /** 插入横向滚动条 */
  925. var HorizontalScrollBar = /*#__PURE__*/(/* unused pure expression or super */ null && (function () {
  926. function HorizontalScrollBar() {
  927. var _this2 = this;
  928. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  929. _classCallCheck(this, HorizontalScrollBar);
  930. /** 创建滚轴组件元素 */
  931. _defineProperty(this, "createScrollbar", function (setStyle) {
  932. if (_this2.scrollbar) return _this2.scrollbar;
  933. var timer = Date.now();
  934. _this2.scrollbarId = "scrollbar".concat(timer);
  935. _this2.scrollbar = document.createElement('div');
  936. _this2.scrollbar.setAttribute('data-part', 'scrollbar');
  937. _this2.scrollbar.setAttribute('id', _this2.scrollbarId);
  938. _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");
  939. });
  940. /** 把滚轴组件元素插入目标元素的后面 */
  941. _defineProperty(this, "insertScrollbar", function (el) {
  942. _this2.target = el;
  943. if (typeof el === 'string') {
  944. _this2.target = document.querySelector(el);
  945. }
  946. if (!_this2.target) throw Error('el Dom do not exit');
  947. _this2.targetParentElement = document.querySelector(el).parentElement;
  948. if (!_this2.targetParentElement.querySelector("#".concat(_this2.scrollbarId))) {
  949. _this2.targetParentElement.insertBefore(_this2.scrollbar, _this2.target.nextSibling);
  950. }
  951. return _this2.target;
  952. });
  953. /** 根据目标元素 设置 滚轴组件元素尺寸 */
  954. _defineProperty(this, "setScrollbarSize", function () {
  955. _this2.scrollbar.style.width = _this2.target.clientWidth + 'px';
  956. _this2.thumb = _this2.scrollbar.querySelector('[data-part="thumb"]');
  957. _this2.thumb.style.width = _this2.scrollbar.clientWidth * _this2.target.clientWidth / _this2.target.scrollWidth + 'px';
  958. _this2.offsetMax = _this2.scrollbar.clientWidth - _this2.thumb.clientWidth;
  959. _this2.rate = (_this2.target.scrollWidth - _this2.target.clientWidth) / _this2.offsetMax;
  960. });
  961. /** */
  962. _defineProperty(this, "onMouseDownOfThumb", function (e) {
  963. console.log("mousedown => %O ");
  964. _this2.prePageX = e.pageX;
  965. _this2.isMousedown = true;
  966. });
  967. /** */
  968. _defineProperty(this, "onMouseUpOfWindow", function (e) {
  969. _this2.isMousedown = false;
  970. });
  971. /** */
  972. _defineProperty(this, "requestAnimationFrameCallback", function (offsetLeft) {
  973. _this2.thumb.style.left = offsetLeft + 'px';
  974. _this2.target.scrollLeft = offsetLeft * _this2.rate;
  975. });
  976. /** */
  977. _defineProperty(this, "onMousemoveOfWindow", function (e) {
  978. if (_this2.isMousedown) {
  979. var offsetLeft = Number(_this2.thumb.style.left.replace('px', '')) + Number(e.pageX - _this2.prePageX);
  980. offsetLeft = Math.max(0, offsetLeft);
  981. offsetLeft = Math.min(offsetLeft, _this2.offsetMax);
  982. _this2.requestAnimationFrameCallback(offsetLeft);
  983. _this2.prePageX = e.pageX;
  984. }
  985. });
  986. /** 监听目标元素和滚轴元素的scroll和页面resize事件 */
  987. _defineProperty(this, "onEvent", function () {
  988. _this2.thumb.addEventListener('mousedown', _this2.onMouseDownOfThumb);
  989. window.addEventListener('mouseup', _this2.onMouseUpOfWindow);
  990. window.addEventListener('mousemove', _this2.onMousemoveOfWindow);
  991. window.addEventListener('resize', _this2.setScrollbarSize);
  992. });
  993. /** 移除事件 */
  994. _defineProperty(this, "removeEvent", function () {
  995. _this2.thumb.removeEventListener('mousedown', _this2.onMouseDownOfThumb);
  996. window.removeEventListener('mouseup', _this2.onMouseUpOfWindow);
  997. window.removeEventListener('mousemove', _this2.onMousemoveOfWindow);
  998. window.removeEventListener('resize', _this2.setScrollbarSize);
  999. });
  1000. var _el2 = options.el,
  1001. _options$setStyle = options.setStyle,
  1002. _setStyle = _options$setStyle === void 0 ? function () {
  1003. return null;
  1004. } : _options$setStyle;
  1005. this.createScrollbar(_setStyle);
  1006. this.insertScrollbar(_el2);
  1007. this.setScrollbarSize();
  1008. this.onEvent();
  1009. }
  1010. return _createClass(HorizontalScrollBar, [{
  1011. key: "setDefaultStyle",
  1012. value: function setDefaultStyle(scrollbarId) {
  1013. 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");
  1014. }
  1015. }]);
  1016. }()));
  1017.  
  1018. /** 持久化数据状态 */
  1019. var PersistentStorage = /*#__PURE__*/(/* unused pure expression or super */ null && (function () {
  1020. function PersistentStorage() {
  1021. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1022. _classCallCheck(this, PersistentStorage);
  1023. var _options$valKey = options.valKey,
  1024. valKey = _options$valKey === void 0 ? 'valKey' : _options$valKey,
  1025. _options$storageType = options.storageType,
  1026. storageType = _options$storageType === void 0 ? 'sessionStorage' : _options$storageType;
  1027. this.valKey = valKey;
  1028. this.storageType = storageType;
  1029. }
  1030. return _createClass(PersistentStorage, [{
  1031. key: "write",
  1032. value: function write(val) {
  1033. val = _typeof(val) === 'object' ? JSON.stringify(val, null, 2) : val;
  1034. val && window[this.storageType].setItem(this.valKey, val);
  1035. }
  1036. }, {
  1037. key: "read",
  1038. value: function read() {
  1039. var val = window[this.storageType].getItem(this.valKey);
  1040. return val ? JSON.parse(val) : val;
  1041. }
  1042. }, {
  1043. key: "remove",
  1044. value: function remove() {
  1045. window[this.storageType].removeItem(this.valKey);
  1046. }
  1047. }]);
  1048. }()));
  1049.  
  1050. /**
  1051. * @description 节流函数
  1052. * @export
  1053. * @param {Function} func
  1054. * @param {Number} [wait=100]
  1055. * @returns {Function}
  1056. */
  1057. function throttle(func) {
  1058. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
  1059. var isDoing = false;
  1060. return function () {
  1061. if (isDoing) return;
  1062. isDoing = true;
  1063. func.apply(void 0, arguments);
  1064. setTimeout(function () {
  1065. isDoing = false;
  1066. }, wait);
  1067. };
  1068. }
  1069.  
  1070. /**
  1071. * @description 防抖函数
  1072. * @export
  1073. * @param {Function} func
  1074. * @param {Number} [wait=100]
  1075. * @param {'end'|'front'} type
  1076. * @returns {Function}
  1077. */
  1078. function debounce(func) {
  1079. var wait = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 100;
  1080. var type = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'end';
  1081. var timer = 0;
  1082. return function () {
  1083. clearTimeout(timer);
  1084. for (var _len = arguments.length, rest = new Array(_len), _key2 = 0; _key2 < _len; _key2++) {
  1085. rest[_key2] = arguments[_key2];
  1086. }
  1087. timer = setTimeout.apply(void 0, [func, wait].concat(rest));
  1088. };
  1089. }
  1090.  
  1091. /**
  1092. * @description 等候
  1093. * @export
  1094. * @param {number} [interval=17]
  1095. * @returns {Promise}
  1096. */
  1097. function awaitTime() {
  1098. var interval = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 17;
  1099. return new Promise(function (resolve) {
  1100. setTimeout(resolve, interval);
  1101. });
  1102. }
  1103.  
  1104. /**
  1105. * @description 打开已在窗口仅激活,不刷新
  1106. * @export
  1107. * @class OpenPlus
  1108. */
  1109. var OpenPlus = /*#__PURE__*/createClass_createClass(function OpenPlus() {
  1110. var _this3 = this;
  1111. var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1112. classCallCheck_classCallCheck(this, OpenPlus);
  1113. defineProperty_defineProperty(this, "openPre", function () {
  1114. var callback = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : function () {
  1115. return null;
  1116. };
  1117. for (var _len2 = arguments.length, rest = new Array(_len2 > 1 ? _len2 - 1 : 0), _key3 = 1; _key3 < _len2; _key3++) {
  1118. rest[_key3 - 1] = arguments[_key3];
  1119. }
  1120. var win = _this3.open.apply(_this3, rest);
  1121. callback === null || callback === void 0 || callback();
  1122. return win;
  1123. });
  1124. defineProperty_defineProperty(this, "open", function (href) {
  1125. var willOpenTab = _this3.win.tabsCacheOfOpenPlus[href];
  1126. for (var _len3 = arguments.length, rest = new Array(_len3 > 1 ? _len3 - 1 : 0), _key4 = 1; _key4 < _len3; _key4++) {
  1127. rest[_key4 - 1] = arguments[_key4];
  1128. }
  1129. if (willOpenTab === undefined) {
  1130. var _this3$win;
  1131. willOpenTab = (_this3$win = _this3.win).open.apply(_this3$win, [href].concat(rest));
  1132. _this3.win.nextOfOpenPlus.forEach(function (item) {
  1133. return item === null || item === void 0 ? void 0 : item();
  1134. });
  1135. return _this3.win.tabsCacheOfOpenPlus[href] = willOpenTab;
  1136. } else if (willOpenTab.closed === true) {
  1137. var _this3$win2;
  1138. return (_this3$win2 = _this3.win).open.apply(_this3$win2, [href].concat(rest));
  1139. } else if (willOpenTab.closed === false) {
  1140. willOpenTab.focus();
  1141. return willOpenTab;
  1142. }
  1143. });
  1144. var _opt$win = opt.win,
  1145. _win = _opt$win === void 0 ? window : _opt$win,
  1146. _opt$next = opt.next,
  1147. next = _opt$next === void 0 ? function () {
  1148. return null;
  1149. } : _opt$next;
  1150. this.win = _win;
  1151. this.win.tabsCacheOfOpenPlus = this.win.tabsCacheOfOpenPlus || {};
  1152. this.win.nextOfOpenPlus = this.win.nextOfOpenPlus || [];
  1153. this.win.nextOfOpenPlus.push(next);
  1154. });
  1155. function modifyStorage() {
  1156. var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1157. var _opt$storageName = opt.storageName,
  1158. storageName = _opt$storageName === void 0 ? 'localStorage' : _opt$storageName,
  1159. chainKeys = opt.chainKeys,
  1160. _opt$doType = opt.doType,
  1161. doType = _opt$doType === void 0 ? 'get' : _opt$doType,
  1162. val = opt.val,
  1163. _opt$prefix = opt.prefix,
  1164. prefix = _opt$prefix === void 0 ? 'enjoy_setting' : _opt$prefix;
  1165. if (prefix) {
  1166. chainKeys = "".concat(prefix, ".").concat(chainKeys);
  1167. }
  1168. chainKeys = chainKeys.split('.');
  1169. var keyOfLevel1 = chainKeys.shift();
  1170. var keyOfEnd = chainKeys.pop();
  1171. var isObject = true;
  1172. var storage = null;
  1173. try {
  1174. storage = JSON.parse(window[storageName].getItem(keyOfLevel1));
  1175. } catch (error) {
  1176. isObject = false;
  1177. storage = window[storageName].getItem(keyOfLevel1);
  1178. console.error("".concat(storageName, " ").concat(chainKeys, " \u4E00\u7EA7\u5C5E\u6027\u503C\u4E3A\u57FA\u672C\u7C7B\u578B"));
  1179. return;
  1180. }
  1181. var obj = storage;
  1182. chainKeys.forEach(function (key) {
  1183. obj = obj[key];
  1184. });
  1185. if (doType === 'set') {
  1186. obj[keyOfEnd] = val;
  1187. window[storageName].setItem(keyOfLevel1, JSON.stringify(storage, null, 2));
  1188. } else {
  1189. return obj[keyOfEnd];
  1190. }
  1191. }
  1192.  
  1193. /**
  1194. * @description 简便的Storage SimpleStorage({ prefix: 'prefix' })
  1195. * @param {*} opt
  1196. */
  1197. function storagex() {
  1198. var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1199. var Storage = /*#__PURE__*/_createClass(function Storage() {
  1200. var _this4 = this;
  1201. var opt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1202. _classCallCheck(this, Storage);
  1203. _defineProperty(this, "storage", null);
  1204. _defineProperty(this, "setItem", function (keys, val) {
  1205. _this4.formatChainKeys(keys);
  1206. _this4.getFirstLevelVal();
  1207. _this4.chainVal('set', val);
  1208. return void 0;
  1209. });
  1210. _defineProperty(this, "getItem", function (keys) {
  1211. _this4.formatChainKeys(keys);
  1212. _this4.getFirstLevelVal();
  1213. return _this4.chainVal('get');
  1214. });
  1215. _defineProperty(this, "removeItem", function (keys) {
  1216. _this4.formatChainKeys(keys);
  1217. _this4.getFirstLevelVal();
  1218. return _this4.chainVal('remove');
  1219. });
  1220. _defineProperty(this, "clear", function () {
  1221. var keysWithPrefix = Object.keys(_this4.storage).filter(function (item) {
  1222. return item.startsWith(_this4.prefix);
  1223. });
  1224. keysWithPrefix.forEach(function (key) {
  1225. return _this4.storage.removeItem(key);
  1226. });
  1227. return void 0;
  1228. });
  1229. _defineProperty(this, "getFirstLevelVal", function () {
  1230. var state = _this4.storage[_this4.prefix + _this4.startKey];
  1231. try {
  1232. state = JSON.parse(state);
  1233. } catch (error) {}
  1234. _this4.cache = state;
  1235. return state;
  1236. });
  1237. _defineProperty(this, "formatChainKeys", function (keys) {
  1238. keys = keys.split('.');
  1239. _this4.startKey = keys.shift();
  1240. _this4.endKey = keys.pop();
  1241. _this4.middlekeys = keys;
  1242. return keys;
  1243. });
  1244. _defineProperty(this, "chainVal", function (doType, val) {
  1245. var obj = _this4.cache;
  1246. _this4.middlekeys.forEach(function (key) {
  1247. obj = obj[key];
  1248. });
  1249. if (doType === 'set') {
  1250. if (_this4.endKey) {
  1251. obj[_this4.endKey] = val;
  1252. } else {
  1253. _this4.cache = val;
  1254. }
  1255. _this4.storage.setItem(_this4.prefix + _this4.startKey, _this4.isObject(_this4.cache) ? JSON.stringify(_this4.cache, null, 2) : _this4.cache);
  1256. } else if (doType === 'get') {
  1257. if (_this4.endKey) {
  1258. return obj[_this4.endKey];
  1259. }
  1260. return _this4.cache;
  1261. } else if (doType === 'remove') {
  1262. if (_this4.endKey) {
  1263. var isDeleted = delete obj[_this4.endKey];
  1264. isDeleted && _this4.setItem(_this4.startKey, _this4.cache);
  1265. return isDeleted;
  1266. }
  1267. _this4.storage.removeItem(_this4.prefix + _this4.startKey);
  1268. }
  1269. });
  1270. _defineProperty(this, "isObject", function (value) {
  1271. var type = _typeof(value);
  1272. return value != null && (type === 'object' || type === 'function');
  1273. });
  1274. var prefix = opt.prefix,
  1275. storage = opt.storage;
  1276. this.prefix = prefix ? "".concat(prefix, "_") : '';
  1277. this.storage = storage;
  1278. });
  1279. if (opt.storage && sessionStorage.__proto__.setItemX) return opt.storage;
  1280. var storage = new Storage(opt);
  1281. if (opt.storage) return storage;
  1282. if (sessionStorage.__proto__.setItemX) return;
  1283. sessionStorage.__proto__.setItemX = function (key, val) {
  1284. storage.storage = this;
  1285. storage.setItem(key, val);
  1286. };
  1287. sessionStorage.__proto__.getItemX = function (key) {
  1288. storage.storage = this;
  1289. return storage.getItem(key);
  1290. };
  1291. sessionStorage.__proto__.removeItemX = function (key) {
  1292. storage.storage = this;
  1293. return storage.removeItem(key);
  1294. };
  1295. sessionStorage.__proto__.clearX = function () {
  1296. storage.storage = this;
  1297. return storage.clear();
  1298. };
  1299. }
  1300.  
  1301. /**
  1302. * @description 处理标记内容
  1303. * @param {*} opt
  1304. * @returns {*}
  1305. */
  1306. function operateComment(opt) {
  1307. var _opt$text = opt.text,
  1308. text = _opt$text === void 0 ? '' : _opt$text,
  1309. _opt$S = opt.S,
  1310. S = _opt$S === void 0 ? '/*' : _opt$S,
  1311. _opt$E = opt.E,
  1312. E = _opt$E === void 0 ? '*/' : _opt$E,
  1313. _opt$modify = opt.modify,
  1314. modify = _opt$modify === void 0 ? function (val) {
  1315. return val;
  1316. } : _opt$modify;
  1317. var stack = [];
  1318. var index = text.indexOf(S);
  1319. if (index === -1) return text;
  1320. while (index <= text.length - 1) {
  1321. if (text[index] + text[index + 1] == S) {
  1322. stack.push(index);
  1323. } else if (text[index] + text[index + 1] == E) {
  1324. var latestIndex = stack.pop();
  1325. if (latestIndex !== undefined) {
  1326. var middle = modify(text.slice(latestIndex + S.length, index));
  1327. text = text.slice(0, latestIndex) + middle + text.slice(index + S.length);
  1328. index = latestIndex + middle.length;
  1329. }
  1330. }
  1331. index++;
  1332. }
  1333. return text;
  1334. }
  1335.  
  1336. /** 添加动画函数 */
  1337. function addAnimation(dom, className) {
  1338. if (!dom || !className) return;
  1339. if (!dom.animationend) {
  1340. dom.animationend = function () {
  1341. dom.classList.remove(className);
  1342. };
  1343. }
  1344. dom.removeEventListener('animationend', dom.animationend);
  1345. dom.addEventListener('animationend', dom.animationend);
  1346. dom.classList.add(className);
  1347. }
  1348.  
  1349. // 判断当前浏览器运行环境
  1350. function getBrowserEnv() {
  1351. var userAgent = window.navigator.userAgent.toLowerCase();
  1352. var agents = ['Android', 'iPhone', 'SymbianOS', 'Windows Phone', 'iPad', 'iPod'];
  1353. // 是否为支付宝环境
  1354. var isAliPay = /alipayclient/.test(userAgent);
  1355. // 是否为淘宝环境
  1356. var isTaoBao = /windvane/.test(userAgent);
  1357. // 是否为企业微信环境
  1358. var isWxWork = /wxwork/.test(userAgent);
  1359. // 是否为微信环境
  1360. var isWeChat = /micromessenger/.test(userAgent) && !isWxWork;
  1361. // 是否为移动端
  1362. var isPhone = agents.some(function (x) {
  1363. return new RegExp(x.toLocaleLowerCase()).test(userAgent);
  1364. });
  1365. return {
  1366. isAliPay: isAliPay,
  1367. isTaoBao: isTaoBao,
  1368. isWxWork: isWxWork,
  1369. isWeChat: isWeChat,
  1370. isPhone: isPhone
  1371. };
  1372. }
  1373. var RegisterDbltouchEvent = /*#__PURE__*/(/* unused pure expression or super */ null && (function () {
  1374. function RegisterDbltouchEvent(el, fn) {
  1375. _classCallCheck(this, RegisterDbltouchEvent);
  1376. this.el = el || window;
  1377. this.callback = fn;
  1378. this.timer = null;
  1379. this.prevPosition = {};
  1380. this.isWaiting = false;
  1381.  
  1382. // 注册click事件,注意this指向
  1383. this.el.addEventListener('click', this.handleClick.bind(this), true);
  1384. }
  1385. return _createClass(RegisterDbltouchEvent, [{
  1386. key: "handleClick",
  1387. value: function handleClick(evt) {
  1388. var _this5 = this;
  1389. var pageX = evt.pageX;
  1390. var pageY = evt.pageY;
  1391. if (this.timer) {
  1392. clearTimeout(this.timer);
  1393. this.timer = null;
  1394. }
  1395. if (!evt.isTrusted) {
  1396. return;
  1397. }
  1398. if (this.isWaiting) {
  1399. this.isWaiting = false;
  1400. var diffX = Math.abs(pageX - this.prevPosition.pageX);
  1401. var diffY = Math.abs(pageY - this.prevPosition.pageY);
  1402. // 如果满足位移小于10,则是双击
  1403. if (diffX <= 10 && diffY <= 10) {
  1404. // 取消当前事件传递,并派发1个自定义双击事件
  1405. evt.stopPropagation();
  1406. evt.target.dispatchEvent(new PointerEvent('dbltouch', {
  1407. cancelable: false,
  1408. bubbles: true
  1409. }));
  1410. // 也可以采用回调函数的方式
  1411. this.callback && this.callback(evt);
  1412. }
  1413. } else {
  1414. this.prevPostion = {
  1415. pageX: pageX,
  1416. pageY: pageY
  1417. };
  1418. // 阻止冒泡,不让事件继续传播
  1419. evt.stopPropagation();
  1420. // 开始等待第2次点击
  1421. this.isWaiting = true;
  1422. // 设置200ms倒计时,200ms后重新派发当前事件
  1423. this.timer = setTimeout(function () {
  1424. _this5.isWaiting = false;
  1425. evt.target.dispatchEvent(evt);
  1426. }, 200);
  1427. }
  1428. }
  1429. }]);
  1430. }()));
  1431. /**移动端 双击 */
  1432. function addDbltouch() {
  1433. var dom = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window;
  1434. var handle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (event) {
  1435. console.log('双击', event, Date.now());
  1436. };
  1437. var preTimestamp = 0;
  1438. dom.addEventListener('click', function (event) {
  1439. var currentTimestamp = Date.now();
  1440. if (currentTimestamp - preTimestamp < 200) handle(event);
  1441. preTimestamp = currentTimestamp;
  1442. });
  1443. }
  1444.  
  1445. /**
  1446. * @description 获取dom
  1447. * @export
  1448. * @param {*} element
  1449. * @param {*} selector
  1450. * @param {number} [timeout=80]
  1451. * @param {boolean} [isAlways=true]
  1452. * @returns {*}
  1453. */
  1454. function getElement(_x, _x2) {
  1455. return _getElement.apply(this, arguments);
  1456. }
  1457.  
  1458. /**
  1459. * @description 分隔dom分区
  1460. * @param {*} e
  1461. * @param {number} [divideX=3]
  1462. * @param {*} [divideY=divideX]
  1463. * @returns {*} string
  1464. */
  1465. function _getElement() {
  1466. _getElement = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(element, selector) {
  1467. var timeout,
  1468. isAlways,
  1469. count,
  1470. _args = arguments;
  1471. return _regeneratorRuntime.wrap(function _callee$(_context) {
  1472. while (1) switch (_context.prev = _context.next) {
  1473. case 0:
  1474. timeout = _args.length > 2 && _args[2] !== undefined ? _args[2] : 80;
  1475. isAlways = _args.length > 3 && _args[3] !== undefined ? _args[3] : true;
  1476. count = 0;
  1477. return _context.abrupt("return", new Promise(function (resolve, reject) {
  1478. var timeId = setInterval(function () {
  1479. if (timeout && count++ >= timeout) {
  1480. clearInterval(timeId);
  1481. console.warn('[utils.getElement] Element is not find.' + ' selector: ' + selector);
  1482. // 保持原生逻辑,即未找到时,返回null,便于之后执行埋点,比如错误上报
  1483. return resolve(null);
  1484. }
  1485. var node = element.querySelector(selector);
  1486. if (node) {
  1487. //node 总是返回 或 显示状态条件下,找到后即刻返回
  1488. if (isAlways || node.offsetParent) {
  1489. resolve(node);
  1490. clearInterval(timeId);
  1491. }
  1492. }
  1493. }, 200);
  1494. }));
  1495. case 4:
  1496. case "end":
  1497. return _context.stop();
  1498. }
  1499. }, _callee);
  1500. }));
  1501. return _getElement.apply(this, arguments);
  1502. }
  1503. function divideDom(e) {
  1504. var divideX = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 3;
  1505. var divideY = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : divideX;
  1506. if (!divideX) {
  1507. throw new Error('divideDom 函数 divideX 参数不能为空');
  1508. }
  1509. if (!divideY) {
  1510. divideX = divideY;
  1511. console.warn("divideDom \u51FD\u6570 dom \u5206\u533A \u4E3A ".concat(divideX, "*").concat(divideY));
  1512. }
  1513. var resultStr = "".concat(getIdx(e.target.offsetWidth, divideX, e.offsetX), "-").concat(getIdx(e.target.offsetHeight, divideY, e.offsetY));
  1514. console.log("resultStr => %O ", resultStr);
  1515. return resultStr;
  1516.  
  1517. // 获取坐标
  1518. function getIdx(size, divide, offsetPosition) {
  1519. var size_step = Math.ceil(size / divide);
  1520. var posi_idx = Math.floor(offsetPosition / size_step);
  1521. if (offsetPosition % size_step) {
  1522. posi_idx++;
  1523. }
  1524. return posi_idx;
  1525. }
  1526. }
  1527. ;// CONCATENATED MODULE: ./src/tool/previewImg.js
  1528.  
  1529.  
  1530.  
  1531.  
  1532. var EMIT_EVENT_TYPE = getBrowserEnv().isPhone ? 'dbltouch' : 'dblclick';
  1533. // const EMIT_EVENT_TYPE = 'dblclick'
  1534. var ImgPreviewer = /*#__PURE__*/createClass_createClass(function ImgPreviewer() {
  1535. var _this = this;
  1536. var _options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  1537. classCallCheck_classCallCheck(this, ImgPreviewer);
  1538. defineProperty_defineProperty(this, "createGlobalStyle", function () {
  1539. createElement('style', {
  1540. randomType: 'newOne',
  1541. innerHTML: "\n\t\t\t/* \u7F29\u653E */\n\t\t\t body img {\n\n\t\t\t /* \u5149\u6807 \u5448\u73B0 \u653E\u5927\u56FE\u6807 */\n\t\t\t /*\tcursor: zoom-in !important; */\n\n\t\t\t/* \u907F\u514D pointer-events: none; \u60C5\u51B5\u51FA\u73B0 inherit initial auto */\n pointer-events: auto !important;\n\n\t\t\t}\n\n\n\t\t\t"
  1542. });
  1543. });
  1544. /** @描述 状态 */
  1545. defineProperty_defineProperty(this, "state", null);
  1546. defineProperty_defineProperty(this, "shadowRoot", null);
  1547. defineProperty_defineProperty(this, "maskContent", null);
  1548. /** @描述 创建 shadowRoot */
  1549. defineProperty_defineProperty(this, "createShadowRoot", function () {
  1550. var selector = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '#imgPreview';
  1551. selector = selector.replace(/[.#]/g, '');
  1552. var dom = document.querySelector("#".concat(selector));
  1553. if (!dom) {
  1554. dom = createElement('div', {
  1555. addPrefix: false,
  1556. id: selector,
  1557. style: 'width:0;height:0'
  1558. });
  1559. }
  1560. if (!dom.shadowRoot) {
  1561. // 添加在body下,获取 dom.shadowRoot
  1562. dom.attachShadow({
  1563. mode: 'open'
  1564. });
  1565. // dom.shadowRoot.appendChild(maskContent)
  1566. // 创建蒙层容器
  1567. var maskContent = createElement('div', {
  1568. className: 'modal',
  1569. el: dom.shadowRoot
  1570. });
  1571. maskContent.appendChild(_this.createStyle(_this.state));
  1572. }
  1573. return dom.shadowRoot;
  1574. });
  1575. /** @描述 合并选项 */
  1576. defineProperty_defineProperty(this, "mergeOptions", function (options) {
  1577. var opt = {};
  1578. var defaultOptions = {
  1579. contentSelector: 'body',
  1580. selector: 'img',
  1581. showRootSelector: '#img_preview',
  1582. backgroundColor: 'rgba(0,0,0,0)',
  1583. extraStyle: ''
  1584. };
  1585. Object.assign(opt, defaultOptions, options);
  1586. return opt;
  1587. });
  1588. /** @描述 创建shadowbox中的样式 */
  1589. defineProperty_defineProperty(this, "createStyle", function (_ref) {
  1590. var contentSelector = _ref.contentSelector,
  1591. selector = _ref.selector,
  1592. backgroundColor = _ref.backgroundColor,
  1593. extraStyle = _ref.extraStyle;
  1594. return createElement('style', {
  1595. autoInsert: false,
  1596. randomType: 'newOne',
  1597. innerHTML: "".concat(contentSelector, " ").concat(selector, " {\n cursor: zoom-in;\n }\n /* \u56FE\u7247\u9884\u89C8 */\n .modal {\n touch-action: none;\n position: fixed;\n z-index: 10000;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n background-color: ").concat(backgroundColor, ";\n user-select: none;\n pointer-events: none;\n\t\t\t--box-shadow-focus:rgb(125 230 221 / 90%);\n }\n .modal>*{\n pointer-events: auto;\n }\n .modal>img {\n position: absolute;\n padding: 0;\n margin: 0;\n box-shadow: var(--box-shadow-focus) 0 0 8px 2px;\n /* border-radius: 10px; */\n /* transition: all var(--delay_time); */\n transform: translateZ(0);\n\t\t\t/* \u900F\u660E\u56FE\u7247 \u886C\u56FE */\n\t\t\tbackground: repeating-conic-gradient(#202020 0, #202020 25%, #303030 0, #303030 50%) 0 0/30px 30px;\n }\n\n img.isPreviewed {\n animation: activeImg 0.5s 4 ease-out forwards;\n transition: all;\n\n }\n\n @keyframes activeImg {\n 0% {\n box-shadow: var(--box-shadow-focus) 0 0 8px 2px;\n }\n 50% {\n box-shadow: rgb(255 0 0 / 70%) 0 0 8px 2px;\n }\n 100% {\n box-shadow: rgb(239 126 4 / 95%) 0 0 8px 2px;\n }\n }\n ").concat(extraStyle, "\n ")
  1598. });
  1599. });
  1600. /** @描述 预览操作 */
  1601. defineProperty_defineProperty(this, "onPreviwerEvent", function () {
  1602. var that = _this;
  1603. var _that$state = that.state,
  1604. contentSelector = _that$state.contentSelector,
  1605. selector = _that$state.selector;
  1606. var eventsProxy = document.querySelector(contentSelector) || window.document.body;
  1607. var operationHandle = function operationHandle(e) {
  1608. var _e$target$imgItemInMo;
  1609. var src = that.getImgSrc(e.target);
  1610. if (!src) return;
  1611. e.preventDefault();
  1612.  
  1613. // let previewTargetDom = [...that.shadowRoot.querySelectorAll(selector)].find((item) => that.getImgSrc(item) === src)
  1614. var previewTargetDom = (_e$target$imgItemInMo = e.target.imgItemInModal) === null || _e$target$imgItemInMo === void 0 || (_e$target$imgItemInMo = _e$target$imgItemInMo.state) === null || _e$target$imgItemInMo === void 0 ? void 0 : _e$target$imgItemInMo.cloneEl;
  1615.  
  1616. // 第n+1次双击原图预览时
  1617. if (previewTargetDom) {
  1618. //原图的预览图已存在,则激活并最上面显示
  1619. if (!previewTargetDom.classList.contains('isPreviewed')) {
  1620. previewTargetDom.classList.add('isPreviewed');
  1621. // previewTargetDom.remove()
  1622. // that.shadowRoot.querySelector('.modal').appendChild(previewTargetDom)
  1623. that.setTopImg(previewTargetDom);
  1624. } else {
  1625. // previewTargetDom.remove()
  1626.  
  1627. e.target.imgItemInModal.ondblclick({
  1628. animation: 'opacity',
  1629. preventDefault: function preventDefault() {
  1630. return null;
  1631. }
  1632. });
  1633. previewTargetDom = null;
  1634. }
  1635. return;
  1636. }
  1637. // 第一次双击原图预览时
  1638. if (!previewTargetDom) {
  1639. // originalEl.style.opacity = 0
  1640. e.target.imgItemInModal = new ImgItemInModal(that.shadowRoot, e.target, src);
  1641. console.log("e.target.imgItemInModal => %O ", e.target.imgItemInModal);
  1642. }
  1643. };
  1644. getBrowserEnv().isPhone ? addDbltouch(eventsProxy, operationHandle) : eventsProxy.addEventListener(EMIT_EVENT_TYPE, operationHandle);
  1645. });
  1646. defineProperty_defineProperty(this, "getImgSrc", function (dom) {
  1647. var _dom$dataset, _window$getComputedSt;
  1648. return (dom === null || dom === void 0 || (_dom$dataset = dom.dataset) === null || _dom$dataset === void 0 ? void 0 : _dom$dataset.src) || (dom === null || dom === void 0 ? void 0 : dom.src) || ((_window$getComputedSt = window.getComputedStyle(dom).backgroundImage.match(/^url\("([^\s]+)"\)$/i)) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt[1]);
  1649. });
  1650. /** 最顶层的图片 绑定到容器*/
  1651. defineProperty_defineProperty(this, "setTopImg", function (domImg) {
  1652. if (!_this.maskContent) {
  1653. _this.maskContent = _this.shadowRoot.querySelector('.modal');
  1654. }
  1655. if (domImg && _this.maskContent && _this.maskContent.topImg !== domImg) {
  1656. if (_this.maskContent.topImg) {
  1657. _this.maskContent.topImg.style.zIndex = '';
  1658. }
  1659. domImg.style.zIndex = '1';
  1660. _this.maskContent.topImg = domImg;
  1661. }
  1662. });
  1663. this.state = this.mergeOptions(_options);
  1664. this.shadowRoot = this.createShadowRoot();
  1665. this.onPreviwerEvent();
  1666. this.createGlobalStyle();
  1667. return this.shadowRoot;
  1668. });
  1669. var ImgItemInModal = /*#__PURE__*/function () {
  1670. function ImgItemInModal(_shadowRoot, _originalEl, _src) {
  1671. var _this2 = this;
  1672. classCallCheck_classCallCheck(this, ImgItemInModal);
  1673. defineProperty_defineProperty(this, "state", {
  1674. scale: 1,
  1675. offset: {
  1676. left: 0,
  1677. top: 0
  1678. },
  1679. origin: 'center',
  1680. initialData: {
  1681. offset: {},
  1682. origin: 'center',
  1683. scale: 1
  1684. },
  1685. startPoint: {
  1686. x: 0,
  1687. y: 0
  1688. },
  1689. // 记录初始触摸点位
  1690. isTouching: false,
  1691. // 标记是否正在移动
  1692. isMove: false,
  1693. // 正在移动中,与点击做区别
  1694. touches: new Map(),
  1695. // 触摸点数组
  1696. lastDistance: 0,
  1697. lastScale: 1,
  1698. // 记录下最后的缩放值
  1699. scaleOrigin: {
  1700. x: 0,
  1701. y: 0
  1702. },
  1703. // 原图originalEl与预览图cloneEl互相引用
  1704. originalEl: null,
  1705. cloneEl: null
  1706. });
  1707. defineProperty_defineProperty(this, "mergeOptions", function (shadowRoot, originalEl, src) {
  1708. var _window = window,
  1709. winWidth = _window.innerWidth,
  1710. winHeight = _window.innerHeight;
  1711. var offsetWidth = originalEl.offsetWidth,
  1712. offsetHeight = originalEl.offsetHeight;
  1713.  
  1714. // Element.getBoundingClientRect() 方法返回元素的大小及其相对于【视口】的位置
  1715. var _originalEl$getBoundi = originalEl.getBoundingClientRect(),
  1716. top = _originalEl$getBoundi.top,
  1717. left = _originalEl$getBoundi.left;
  1718. return {
  1719. shadowRoot: shadowRoot,
  1720. originalEl: originalEl,
  1721. src: src,
  1722. winWidth: winWidth,
  1723. winHeight: winHeight,
  1724. offsetWidth: offsetWidth,
  1725. offsetHeight: offsetHeight,
  1726. top: top,
  1727. left: left,
  1728. maskContent: shadowRoot.querySelector('.modal')
  1729. };
  1730. });
  1731. /** @描述 添加图片 */
  1732. defineProperty_defineProperty(this, "appendImg", function (src, originalEl) {
  1733. // 克隆节点 能从缓存中获取图片,以便节省流量
  1734. var cloneEl = null;
  1735. if (originalEl.tagName === 'IMG') {
  1736. cloneEl = originalEl.cloneNode();
  1737. } else {
  1738. cloneEl = document.createElement('img');
  1739. cloneEl.src = src;
  1740. }
  1741. console.log("\u53CC\u51FB\u7684\u56FE\u7247\u5730\u5740 => %O ", cloneEl.src);
  1742. _this2.state.maskContent.appendChild(cloneEl);
  1743. _this2.setTopImg(cloneEl);
  1744. return cloneEl;
  1745. });
  1746. /** 最顶层的图片 绑定到容器*/
  1747. defineProperty_defineProperty(this, "setTopImg", function (domImg) {
  1748. if (domImg && _this2.state.maskContent && _this2.state.maskContent.topImg !== domImg) {
  1749. if (_this2.state.maskContent.topImg) {
  1750. _this2.state.maskContent.topImg.style.zIndex = '';
  1751. }
  1752. domImg.style.zIndex = '1';
  1753. _this2.state.maskContent.topImg = domImg;
  1754. }
  1755. });
  1756. /** @描述 预览容器modal中的Img元素 添加监听滚轴缩放、移动、双击事件 */
  1757. defineProperty_defineProperty(this, "onEventsController", function (cloneEl) {
  1758. var eventType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'addEventListener';
  1759. var events = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [EMIT_EVENT_TYPE, 'mousewheel', 'pointerdown', 'pointerup', 'pointermove', 'pointercancel', 'mouseleave'];
  1760. console.log("onEventsController \u7684 eventType=> %O ", eventType);
  1761. var that = _this2;
  1762. events.forEach(function (item) {
  1763. if (item === 'mousewheel') {
  1764. if (EMIT_EVENT_TYPE === 'dbltouch') {
  1765. addDbltouch(cloneEl, that.ondbltouch);
  1766. } else {
  1767. cloneEl[eventType]('mousewheel', that["on".concat(item)], {
  1768. passive: false
  1769. });
  1770. }
  1771. return;
  1772. }
  1773. cloneEl[eventType](item, that["on".concat(item)]);
  1774. });
  1775. });
  1776. /** @描述 双击事件 */
  1777. defineProperty_defineProperty(this, "ondblclick", function (e) {
  1778. _this2.ondbltouch(e);
  1779. return;
  1780. e.preventDefault();
  1781. var that = _this2;
  1782. var state = that.state;
  1783. console.log("\u5F53\u524D\u9884\u89C8\u56FE\u7247\u7684\u72B6\u6001\u53CA\u5F15\u7528\u5173\u7CFBstate => %O ", state);
  1784. if (state.isMove) {
  1785. state.isMove = false;
  1786. } else {
  1787. // const animationTime = this.getTimeOfClearImgAnimation(state)
  1788. var animationTime = 0.4;
  1789. var originalElPositionState = state.originalEl.getBoundingClientRect();
  1790. that.changeStyle(state.cloneEl, ["transform: translate(0,0)", "transition: all ".concat(animationTime, "s ease-out"), "left: ".concat(originalElPositionState.left, "px"), "top: ".concat(originalElPositionState.top, "px"), "width: ".concat(originalElPositionState.width, "px")]);
  1791. // state.cloneEl.removeEventListener('dblclick', that.ondblclick)
  1792.  
  1793. // this.onEventsController(state.cloneEl, 'removeEventListener')
  1794. setTimeout(function () {
  1795. // state.maskContent.removeChild(state.cloneEl)
  1796. console.log('开始执行清除预览图片');
  1797. // 先清除原图对预览图的引用
  1798. state.cloneEl.remove();
  1799. state.cloneEl = null;
  1800. state.originalEl.imgItemInModal = null;
  1801. }, animationTime * 1000 + 100);
  1802. }
  1803. });
  1804. /** @描述 双触摸事件 */
  1805. defineProperty_defineProperty(this, "ondbltouch", function (e) {
  1806. e.preventDefault();
  1807. var that = _this2;
  1808. var state = that.state;
  1809. console.log("\u5F53\u524D\u9884\u89C8\u56FE\u7247\u7684\u72B6\u6001\u53CA\u5F15\u7528\u5173\u7CFBstate => %O ", state);
  1810. if (state.isMove) {
  1811. state.isMove = false;
  1812. } else {
  1813. var animationTime = 0.4;
  1814. if (e.animation == 'opacity') {
  1815. // 点击原图清除时,透明后清除,不干扰用户浏览内容
  1816. // const animationTime = this.getTimeOfClearImgAnimation(state)
  1817. var originalElPositionState = state.originalEl.getBoundingClientRect();
  1818. that.changeStyle(state.cloneEl, ["opacity: 0", "transition: all ".concat(animationTime, "s ease-out")]);
  1819. } else {
  1820. // 点击预览图清除时,移动后清除,便于定位预览图的原图位置
  1821. // const animationTime = this.getTimeOfClearImgAnimation(state)
  1822. var _originalElPositionState = state.originalEl.getBoundingClientRect();
  1823. that.changeStyle(state.cloneEl, ["transform: translate(0,0)", "transition: all ".concat(animationTime, "s ease-out"), "left: ".concat(_originalElPositionState.left, "px"), "top: ".concat(_originalElPositionState.top, "px"), "width: ".concat(_originalElPositionState.width, "px")]);
  1824. }
  1825.  
  1826. // state.cloneEl.removeEventListener('dblclick', that.ondblclick)
  1827. _this2.onEventsController(state.cloneEl, 'removeEventListener');
  1828. setTimeout(function () {
  1829. // state.maskContent.removeChild(state.cloneEl)
  1830. console.log('开始执行清除预览图片');
  1831. // 先清除原图对预览图的引用
  1832. state.cloneEl.remove();
  1833. state.cloneEl = null;
  1834. state.originalEl.imgItemInModal = null;
  1835. }, animationTime * 1000 + 100);
  1836. }
  1837. });
  1838. /** 清除预览图片动作时长 */
  1839. defineProperty_defineProperty(this, "getTimeOfClearImgAnimation", function (state) {
  1840. var cloneElPositionState = state.cloneEl.getBoundingClientRect();
  1841. var originalElPositionState = state.originalEl.getBoundingClientRect();
  1842. var maxOffsetVal = Math.max(Math.abs(originalElPositionState.left - cloneElPositionState.left), Math.abs(originalElPositionState.top - cloneElPositionState.top));
  1843. var animationTime = 0.1 * maxOffsetVal / 400 + 0.2;
  1844. console.log('清除预览图片的距离及动作时长: ', maxOffsetVal + 'px', animationTime + 's');
  1845. return animationTime;
  1846. });
  1847. /** @描述 指针按下事件*/
  1848. defineProperty_defineProperty(this, "onpointerdown", function (e) {
  1849. e.preventDefault();
  1850. var that = _this2;
  1851. var state = that.state;
  1852. state.touches.set(e.pointerId, e);
  1853. // TODO: 点击存入触摸点
  1854. state.isTouching = true;
  1855. state.startPoint = {
  1856. x: e.clientX,
  1857. y: e.clientY
  1858. };
  1859. if (state.touches.size === 2) {
  1860. // TODO: 判断双指触摸,并立即记录初始数据
  1861. state.lastDistance = that.getDistance();
  1862. state.lastScale = state.scale;
  1863. }
  1864. _this2.setTopImg(e.target);
  1865. });
  1866. /** @描述 滚轮缩放 */
  1867. defineProperty_defineProperty(this, "onmousewheel", function (e) {
  1868. e.preventDefault();
  1869. if (!e.deltaY) return;
  1870. var that = _this2;
  1871. var state = that.state;
  1872. state.origin = "".concat(e.offsetX, "px ").concat(e.offsetY, "px");
  1873.  
  1874. // 缩放执行
  1875. if (e.deltaY < 0) {
  1876. // 放大
  1877. state.scale += 0.18;
  1878. } else if (e.deltaY > 0) {
  1879. state.scale >= 0.28 && (state.scale -= 0.18);
  1880. // 缩小
  1881. }
  1882. if (state.scale < state.initialData.scale) {
  1883. that.reduction();
  1884. }
  1885. state.offset = that.getOffsetPageCenter(e.offsetX, e.offsetY);
  1886. that.changeStyle(state.cloneEl, ['transition: all .15s', "transform-origin: ".concat(state.origin), "transform: translate(".concat(state.offset.left + 'px', ", ").concat(state.offset.top + 'px', ") scale(").concat(state.scale, ")")]);
  1887. _this2.setTopImg(e.target);
  1888. });
  1889. /** @描述 获取中心改变的偏差 */
  1890. defineProperty_defineProperty(this, "getOffsetPageCenter", function () {
  1891. var x = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
  1892. var y = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  1893. var state = _this2.state;
  1894. var touchArr = Array.from(state.touches);
  1895. if (touchArr.length === 2) {
  1896. var start = touchArr[0][1];
  1897. var end = touchArr[1][1];
  1898. x = (start.offsetX + end.offsetX) / 2;
  1899. y = (start.offsetY + end.offsetY) / 2;
  1900. }
  1901. state.origin = "".concat(x, "px ").concat(y, "px");
  1902. var offsetLeft = (state.scale - 1) * (x - state.scaleOrigin.x) + state.offset.left;
  1903. var offsetTop = (state.scale - 1) * (y - state.scaleOrigin.y) + state.offset.top;
  1904. state.scaleOrigin = {
  1905. x: x,
  1906. y: y
  1907. };
  1908. return {
  1909. left: offsetLeft,
  1910. top: offsetTop
  1911. };
  1912. });
  1913. /** @描述 获取距离*/
  1914. defineProperty_defineProperty(this, "getDistance", function () {
  1915. var touchArr = Array.from(_this2.state.touches);
  1916. if (touchArr.length < 2) {
  1917. return 0;
  1918. }
  1919. var start = touchArr[0][1];
  1920. var end = touchArr[1][1];
  1921. return Math.hypot(end.x - start.x, end.y - start.y);
  1922. });
  1923. /** @描述 修改样式,减少回流重绘*/
  1924. defineProperty_defineProperty(this, "changeStyle", function (el, arr, isResetAllStyle) {
  1925. var original = el.style.cssText.split(';');
  1926. original.pop();
  1927. if (isResetAllStyle) {
  1928. el.className = '';
  1929. el.style.cssText = arr.join(';') + ';';
  1930. } else {
  1931. el.style.cssText = original.concat(arr).join(';') + ';';
  1932. }
  1933. });
  1934. /** @描述 还原记录,用于边界处理 */
  1935. defineProperty_defineProperty(this, "reduction", function () {
  1936. var that = _this2;
  1937. var state = that.state;
  1938. that.timer && clearTimeout(that.timer);
  1939. that.timer = setTimeout(function () {
  1940. that.changeStyle(state.cloneEl, ["transform: translate(".concat(state.offset.left + 'px', ", ").concat(state.offset.top + 'px', ") scale(").concat(state.scale, ")"), "transform-origin: ".concat(state.origin)]);
  1941. }, 300);
  1942. });
  1943. /** @描述 松开指针 事件 */
  1944. defineProperty_defineProperty(this, "onpointerup", function (e) {
  1945. e.preventDefault();
  1946. var that = _this2;
  1947. var state = that.state;
  1948. state.touches["delete"](e.pointerId);
  1949. // TODO: 抬起移除触摸点
  1950. if (state.touches.size <= 0) {
  1951. state.isTouching = false;
  1952. } else {
  1953. var touchArr = Array.from(state.touches);
  1954. // 更新点位
  1955. state.startPoint = {
  1956. x: touchArr[0][1].clientX,
  1957. y: touchArr[0][1].clientY
  1958. };
  1959. }
  1960. setTimeout(function () {
  1961. state.isMove = false;
  1962. }, 300);
  1963. });
  1964. /** @描述 指针移动事件 */
  1965. defineProperty_defineProperty(this, "onpointermove", function (e) {
  1966. e.preventDefault();
  1967. var that = _this2;
  1968. var state = that.state;
  1969. if (state.isTouching) {
  1970. state.isMove = true;
  1971. if (state.touches.size < 2) {
  1972. // 单指滑动
  1973. state.offset = {
  1974. left: state.offset.left + (e.clientX - state.startPoint.x),
  1975. top: state.offset.top + (e.clientY - state.startPoint.y)
  1976. };
  1977. that.changeStyle(state.cloneEl, ['transition: all 0s', "transform: translate(".concat(state.offset.left + 'px', ", ").concat(state.offset.top + 'px', ") scale(").concat(state.scale, ")"), "transform-origin: ".concat(origin)]);
  1978. // 更新点位
  1979. state.startPoint = {
  1980. x: e.clientX,
  1981. y: e.clientY
  1982. };
  1983. } else {
  1984. // 双指缩放
  1985. state.touches.set(e.pointerId, e);
  1986. var ratio = that.getDistance() / state.lastDistance;
  1987. state.scale = ratio * state.lastScale;
  1988. state.offset = that.getOffsetPageCenter();
  1989. if (state.scale < state.initialData.scale) {
  1990. that.reduction();
  1991. }
  1992. that.changeStyle(state.cloneEl, ['transition: all 0s', "transform: translate(".concat(state.offset.left + 'px', ", ").concat(state.offset.top + 'px', ") scale(").concat(state.scale, ")"), "transform-origin: ".concat(state.origin)]);
  1993. }
  1994. }
  1995. });
  1996. /** @描述 取消指针事件 */
  1997. defineProperty_defineProperty(this, "onpointercancel", function (e) {
  1998. e.preventDefault();
  1999. _this2.state.touches.clear();
  2000. // 可能存在特定事件导致中断,真机操作时 pointerup 在某些边界情况下不会生效,所以需要清空
  2001. });
  2002. /** 鼠标离开图片时,移动操作结束 */
  2003. defineProperty_defineProperty(this, "onmouseleave", function (e) {
  2004. _this2.state.isMove = false;
  2005. _this2.state.isTouching = false;
  2006. });
  2007. /** @描述 移动图片到屏幕中心位置 */
  2008. defineProperty_defineProperty(this, "fixPosition", function (cloneEl) {
  2009. var that = _this2;
  2010. var state = that.state;
  2011.  
  2012. /** @描述 原图片 中心点 */
  2013. var originalCenterPoint = {
  2014. x: state.offsetWidth / 2 + state.left,
  2015. y: state.offsetHeight / 2 + state.top
  2016. };
  2017.  
  2018. /** @描述 页面 中心点 */
  2019. var winCenterPoint = {
  2020. x: state.winWidth / 2,
  2021. y: state.winHeight / 2
  2022. };
  2023.  
  2024. /** @描述 新建图片的定位点:通过原图片中心点到页面中心点的 偏移量*/
  2025. var offsetDistance = {
  2026. left: winCenterPoint.x - originalCenterPoint.x + state.left,
  2027. top: winCenterPoint.y - originalCenterPoint.y + state.top
  2028. };
  2029.  
  2030. /** @描述 放大后的 */
  2031. var scaleNum = _this2.adaptScale();
  2032. var diffs = {
  2033. left: (scaleNum - 1) * state.offsetWidth / 2,
  2034. top: (scaleNum - 1) * state.offsetHeight / 2
  2035. };
  2036. _this2.changeStyle(cloneEl, ["left: ".concat(state.left, "px"), "top: ".concat(state.top, "px"), 'transition: all 0.3s', "width: ".concat(state.offsetWidth * scaleNum + 'px'), "height:auto", "transform: translate(".concat(offsetDistance.left - state.left - diffs.left, "px, ").concat(offsetDistance.top - state.top - diffs.top, "px)")], true);
  2037.  
  2038. /** @描述 消除偏差:让图片相对于window 0 0定位,通过translate设置中心点重合*/
  2039. setTimeout(function () {
  2040. that.changeStyle(cloneEl, ['transition: all 0s', "left: 0", "top: 0", "transform: translate(".concat(offsetDistance.left - diffs.left, "px, ").concat(offsetDistance.top - diffs.top, "px)")]);
  2041. that.state.offset = {
  2042. left: offsetDistance.left - diffs.left,
  2043. top: offsetDistance.top - diffs.top
  2044. };
  2045. // 记录值
  2046. that.record();
  2047. }, 300);
  2048. });
  2049. /** @描述 计算自适应屏幕的缩放 */
  2050. defineProperty_defineProperty(this, "adaptScale", function () {
  2051. var _this2$state = _this2.state,
  2052. winWidth = _this2$state.winWidth,
  2053. winHeight = _this2$state.winHeight,
  2054. originalEl = _this2$state.originalEl;
  2055. var w = originalEl.offsetWidth,
  2056. h = originalEl.offsetHeight;
  2057. var scale = (winWidth - 60) / w;
  2058. if (h * scale > winHeight - 60) {
  2059. scale = (winHeight - 60) / h;
  2060. }
  2061. return scale;
  2062. });
  2063. this.state = Object.assign({}, this.state, this.mergeOptions(_shadowRoot, _originalEl, _src));
  2064. var _cloneEl = this.appendImg(_src, _originalEl);
  2065. this.state.cloneEl = _cloneEl;
  2066. this.fixPosition(_cloneEl);
  2067. this.onEventsController(_cloneEl);
  2068. // return this
  2069. }
  2070. return createClass_createClass(ImgItemInModal, [{
  2071. key: "record",
  2072. value: /** @描述 记录初始化数据 */
  2073. function record() {
  2074. var state = this.state;
  2075. state.initialData = Object.assign({}, {
  2076. offset: state.offset,
  2077. origin: state.origin,
  2078. scale: state.scale
  2079. });
  2080. }
  2081. }]);
  2082. }();
  2083. function run() {
  2084. try {
  2085. if (codeIsNotExcutable('previewImg', {
  2086. name: '图文对照阅读',
  2087. feature: '图片预览,固定图片,便于图文对照阅读',
  2088. includedUrls: []
  2089. }).notExcutable) return;
  2090. var shadowRoot = new ImgPreviewer({
  2091. backgroundColor: 'transparent'
  2092. });
  2093. } catch (error) {
  2094. console.error(error);
  2095. }
  2096. }
  2097. ;// CONCATENATED MODULE: ./src/tool/addBackgroundImg.js
  2098.  
  2099. /**
  2100. * @description 添加背景色
  2101. */
  2102. function addBackgroundImg_run() {
  2103. try {
  2104. if (codeIsNotExcutable('addBackgroundImg', {
  2105. name: '添加背景图片',
  2106. feature: '使用浏览器查看在线图片或本地图片时,增加页面背景图,以便清晰显示当前图片轮廓',
  2107. includedUrls: []
  2108. }).notExcutable) return;
  2109. addBackgroundImg();
  2110. } catch (error) {
  2111. console.error(error);
  2112. }
  2113. }
  2114.  
  2115. /** @描述 添加背景色*/
  2116. function addBackgroundImg() {
  2117. var ua = navigator.userAgent.toLowerCase();
  2118. var doc = document.body || document.documentElement;
  2119. var isQQBrowser = ua.indexOf('qqbrowser/') > -1;
  2120. if (document.contentType.startsWith('image/')) {
  2121. if (isQQBrowser && doc.tagName !== 'svg') {
  2122. setTimeout(function () {
  2123. loaded();
  2124. }, 666);
  2125. } else {
  2126. loaded();
  2127. }
  2128. }
  2129. }
  2130. function loaded() {
  2131. var doc = document.body || document.documentElement;
  2132. var win = window;
  2133. // var bgImage = `data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2NCIgaGVpZ2h0PSI2NCI+PHBhdGggZD0iTTAgMGgzMnYzMkgwem0zMiAzMmgzMnYzMkgzMnoiIGZpbGw9IiMzMzMiLz48cGF0aCBkPSJNMCAzMmgzMnYzMkgwek0zMiAwaDMydjMySDMyeiIgZmlsbD0iIzIyMiIvPjwvc3ZnPg==`
  2134.  
  2135. var bgCSS = "repeating-conic-gradient(#202020 0, #202020 25%, #303030 0, #303030 50%) 0 0/30px 30px !important";
  2136.  
  2137. /* .bgImage{
  2138. background: #202020;
  2139. background-image: linear-gradient(45deg, #303030 25%, transparent 0), linear-gradient(45deg, transparent 75%, #303030 0), linear-gradient(45deg, #303030 25%, transparent 0), linear-gradient(45deg, transparent 75%, #303030 0);
  2140. background-position: 0 0, 15px 15px, 15px 15px, 30px 30px;
  2141. background-size: 30px 30px;
  2142. } */
  2143.  
  2144. var docTagName = function (tag) {
  2145. var tagName = tag && tag.tagName.toLowerCase();
  2146. if (tagName) {
  2147. if (tagName == 'svg') {
  2148. return tagName;
  2149. }
  2150. if (tagName == 'body' && tag.children && tag.children.length) {
  2151. tagName = tag.children[0].tagName.toLowerCase();
  2152. if (tagName == 'img') {
  2153. return tagName;
  2154. } else {
  2155. tagName = document.querySelector('img');
  2156. return tagName && tagName.tagName && tagName.tagName.toLowerCase();
  2157. }
  2158. }
  2159. }
  2160. }(doc);
  2161. var isViewerMode = docTagName == 'svg' || docTagName == 'img';
  2162. var imgOutlineCss = "img:hover{outline: 0.5px dotted rgb(254 254 254 / 20%);}";
  2163. if (isViewerMode) {
  2164. if (document.head) {
  2165. var styleText = [];
  2166. if (isQQBrowserPS()) {
  2167. styleText.push("body{box-sizing: border-box;background-attachment: fixed !important;background-repeat: repeat !important;}");
  2168. // styleText.push(`body{background: url(${bgImage}) !important;}`)
  2169. styleText.push("body{background: ".concat(bgCSS, ";}"));
  2170. } else {
  2171. styleText.push("img{position: static !important;background-color: rgba(0, 0, 0, 0) !important;}".concat(imgOutlineCss));
  2172. }
  2173. if (document.body.innerText) {
  2174. createElement('style', {
  2175. randomType: 'newOne',
  2176. el: 'head',
  2177. type: 'text/css',
  2178. innerHTML: styleText.join('')
  2179. }, win);
  2180. } else {
  2181. // 本地图片文件
  2182. createElement('style', {
  2183. randomType: 'newOne',
  2184. el: 'head',
  2185. type: 'text/css',
  2186. innerHTML: "body{background: ".concat(bgCSS, ";}img{background-color: rgba(0, 0, 0, 0) !important;}").concat(imgOutlineCss)
  2187. }, win);
  2188. }
  2189. }
  2190. if (isQQBrowserPS()) {
  2191. doc.style.position = 'static';
  2192. doc.style.top = 'auto';
  2193. doc.style.left = 'auto';
  2194. doc.style.transform = 'none';
  2195. } else {
  2196. // doc.style.backgroundImage = `url(${bgImage})`
  2197. doc.style.background = bgCSS;
  2198. doc.style.backgroundAttachment = 'fixed';
  2199. doc.style.boxSizing = 'border-box';
  2200. doc.style.outline = '1px dashed #696767';
  2201. if (docTagName == 'svg') {
  2202. doc.style.position = 'absolute';
  2203. doc.style.top = '50%';
  2204. doc.style.left = '50%';
  2205. doc.style.transform = 'translate(-50%, -50%)';
  2206. doc.style.margin = '10px';
  2207. doc.style.width = 'auto';
  2208. doc.style.height = 'auto';
  2209. doc.style.maxWidth = '100%';
  2210. doc.style.maxHeight = '100%';
  2211. }
  2212. }
  2213. }
  2214. function isQQBrowserPS() {
  2215. return document && document.body && document.body.classList.contains('qb-picture-ps');
  2216. }
  2217. }
  2218. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/arrayLikeToArray.js
  2219. function _arrayLikeToArray(r, a) {
  2220. (null == a || a > r.length) && (a = r.length);
  2221. for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
  2222. return n;
  2223. }
  2224.  
  2225. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js
  2226.  
  2227. function _arrayWithoutHoles(r) {
  2228. if (Array.isArray(r)) return _arrayLikeToArray(r);
  2229. }
  2230.  
  2231. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/iterableToArray.js
  2232. function _iterableToArray(r) {
  2233. if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
  2234. }
  2235.  
  2236. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
  2237.  
  2238. function _unsupportedIterableToArray(r, a) {
  2239. if (r) {
  2240. if ("string" == typeof r) return _arrayLikeToArray(r, a);
  2241. var t = {}.toString.call(r).slice(8, -1);
  2242. return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
  2243. }
  2244. }
  2245.  
  2246. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js
  2247. function _nonIterableSpread() {
  2248. throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
  2249. }
  2250.  
  2251. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/toConsumableArray.js
  2252.  
  2253.  
  2254.  
  2255.  
  2256. function _toConsumableArray(r) {
  2257. return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
  2258. }
  2259.  
  2260. ;// CONCATENATED MODULE: ./node_modules/.pnpm/@babel+runtime@7.25.6/node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
  2261. function asyncGeneratorStep(n, t, e, r, o, a, c) {
  2262. try {
  2263. var i = n[a](c),
  2264. u = i.value;
  2265. } catch (n) {
  2266. return void e(n);
  2267. }
  2268. i.done ? t(u) : Promise.resolve(u).then(r, o);
  2269. }
  2270. function asyncToGenerator_asyncToGenerator(n) {
  2271. return function () {
  2272. var t = this,
  2273. e = arguments;
  2274. return new Promise(function (r, o) {
  2275. var a = n.apply(t, e);
  2276. function _next(n) {
  2277. asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
  2278. }
  2279. function _throw(n) {
  2280. asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
  2281. }
  2282. _next(void 0);
  2283. });
  2284. };
  2285. }
  2286.  
  2287. ;// CONCATENATED MODULE: ./src/tool/openUrlInText.js
  2288.  
  2289.  
  2290.  
  2291.  
  2292. /**
  2293. * @description 含有链接的文本,点击时跳转相应链接
  2294. * @export
  2295. */
  2296. function openUrlInText_run() {
  2297. try {
  2298. if (codeIsNotExcutable('openUrlInText', {
  2299. name: '单击打开文本中链接',
  2300. feature: '点击链接文本时,跳转相应链接,便于查看链接地址的内容',
  2301. includedUrls: []
  2302. }).notExcutable) return;
  2303. var openPlus = new OpenPlus();
  2304. window.addEventListener('click', /*#__PURE__*/function () {
  2305. var _ref = asyncToGenerator_asyncToGenerator(/*#__PURE__*/regenerator_default().mark(function _callee(e) {
  2306. var _innerTextsOfAllText$;
  2307. var dom, innerTextsOfAllText, url;
  2308. return regenerator_default().wrap(function _callee$(_context) {
  2309. while (1) switch (_context.prev = _context.next) {
  2310. case 0:
  2311. dom = e.target; // 非左击
  2312. if (!(e.button !== 0)) {
  2313. _context.next = 3;
  2314. break;
  2315. }
  2316. return _context.abrupt("return");
  2317. case 3:
  2318. if (!(dom.childElementCount && !_toConsumableArray(dom.childNodes).find(function (item) {
  2319. var _item$textContent$mat, _item$textContent;
  2320. return item.nodeName === '#text' && ((_item$textContent$mat = (_item$textContent = item.textContent).match) === null || _item$textContent$mat === void 0 ? void 0 : _item$textContent$mat.call(_item$textContent, /https?:\/\/[\S]{4,}/));
  2321. }))) {
  2322. _context.next = 5;
  2323. break;
  2324. }
  2325. return _context.abrupt("return");
  2326. case 5:
  2327. if (!(dom.tagName === 'A' && dom !== null && dom !== void 0 && dom.href)) {
  2328. _context.next = 7;
  2329. break;
  2330. }
  2331. return _context.abrupt("return");
  2332. case 7:
  2333. if (!isContentEditableOfDOM()) {
  2334. _context.next = 9;
  2335. break;
  2336. }
  2337. return _context.abrupt("return");
  2338. case 9:
  2339. if (!window.getSelection().toString()) {
  2340. _context.next = 11;
  2341. break;
  2342. }
  2343. return _context.abrupt("return");
  2344. case 11:
  2345. innerTextsOfAllText = dom.innerText;
  2346. url = innerTextsOfAllText === null || innerTextsOfAllText === void 0 || (_innerTextsOfAllText$ = innerTextsOfAllText.match) === null || _innerTextsOfAllText$ === void 0 ? void 0 : _innerTextsOfAllText$.call(innerTextsOfAllText, /https?:\/\/[\S]{4,}/);
  2347. if (url) {
  2348. /* openPlus.openPre(
  2349. async () => {
  2350. await awaitTime(100)
  2351. createLinkStyle(url[0], dom)
  2352. },
  2353. url[0],
  2354. url[0]
  2355. ) */
  2356. openPlus.open(url[0], url[0]);
  2357. }
  2358. case 14:
  2359. case "end":
  2360. return _context.stop();
  2361. }
  2362. }, _callee);
  2363. }));
  2364. return function (_x) {
  2365. return _ref.apply(this, arguments);
  2366. };
  2367. }(), {
  2368. capture: true //利用捕获阶段,解决【阻止冒泡】阻断事件传播
  2369. });
  2370. /* function createLinkStyle(url, element) {
  2371. if (!url) return
  2372. element.innerHTML = element.innerHTML.trim().split(url).join(`<a href='${url}' target='${url}'> ${url} </a>`)
  2373. } */
  2374. } catch (error) {
  2375. console.error(error);
  2376. }
  2377. }
  2378.  
  2379. /*
  2380. window.open打开已在的窗口(不同源)时只激活不刷新
  2381.  
  2382.  
  2383. 备注:
  2384.  
  2385.  
  2386.  
  2387. */
  2388. ;// CONCATENATED MODULE: ./src/tool/copySelectedText.js
  2389.  
  2390.  
  2391. /**
  2392. * @description 复制所选文字:鼠标选中文字后,0.5秒内松开左键,自动复制到剪贴板;超过 0.5秒后松开,不再进行复制;一键复制代码块:鼠标悬浮代码块后,点击显示的红色边框,复制到剪贴板
  2393. * @export
  2394. */
  2395. function copySelectedText_run() {
  2396. try {
  2397. var onEmitCopyHandle = function onEmitCopyHandle(e) {
  2398. if (isContentEditableOfDOM()) return;
  2399. var dom = e.target;
  2400. var selectedText = window.getSelection().toString(); // window.getSelection().toString() 双击空白处 会选中 \n
  2401.  
  2402. // || dom.tagName === 'BLOCKQUOTE'
  2403. // https://mp.weixin.qq.com/s/1iBEjoZeA7bUmpAA1KEYhA
  2404.  
  2405. /*
  2406. https://blog.csdn.net/Charissa2017/article/details/103863588
  2407. offsetWidth 盒子自身占据的空间 ,包含 边框
  2408. clientWidth 盒子自身容器拥有的空间 ,包含 padding,但 不包含边框
  2409. */
  2410. //
  2411.  
  2412. if (dom.tagName === 'PRE' && e.target.offsetWidth >= e.offsetX && e.target.clientWidth <= e.offsetX) {
  2413. var getCodesInnerText = function getCodesInnerText(dom, selector) {
  2414. var nodeList = dom.querySelectorAll('code');
  2415. if (nodeList.length) {
  2416. return _toConsumableArray(nodeList).reduce(function (pre, cur) {
  2417. return pre + cur.innerText + '\n';
  2418. }, '');
  2419. }
  2420. return '';
  2421. };
  2422. // dom.querySelector('code')?.innerText csdn 序号在pre标签里
  2423.  
  2424. // const willCopyText = selectedText || dom.querySelector('code')?.innerText || dom.innerText
  2425. // const willCopyText = selectedText || dom.innerText
  2426.  
  2427. var willCopyText = selectedText || getCodesInnerText(dom, 'code') || dom.innerText;
  2428. copyTextAndTip(e, willCopyText, selectedText);
  2429. } else if (selectedText.replace(/\s/g, '')) {
  2430. copyTextAndTip(e, '', selectedText);
  2431. }
  2432. }; // document.documentElement.addEventListener('click', onEmitCopyHandle, {
  2433. // capture: true, //利用捕获阶段,解决【阻止冒泡】阻断事件传播
  2434. // })
  2435. var copyTextAndTip = function copyTextAndTip(e, willCopyText, selectedText) {
  2436. setTimeout(function () {
  2437. createElementTip({
  2438. e: e,
  2439. content: selectedText ? '文字_复制成功' : '代码块_复制成功'
  2440. });
  2441. doCopy((willCopyText || selectedText).trim());
  2442. }, 500);
  2443. };
  2444. // const filename = 'copySelectedText'
  2445. var filename = "copySelectedText";
  2446. if (codeIsNotExcutable(filename, {
  2447. name: '复制所选文本',
  2448. feature: '1、复制所选文字:鼠标选中文字后,0.5秒 后松开左键后,自动复制到剪贴板,超过 0.5秒松开,不进行复制;2、一键复制代码块:鼠标悬浮代码块后,点击显示的红色边框,复制到剪贴板',
  2449. includedUrls: []
  2450. }).notExcutable) return;
  2451. createElement('style', {
  2452. el: 'head',
  2453. id: 'a_click_target',
  2454. randomType: 'newOne',
  2455. textContent: "\n\t\t/* \u5141\u8BB8\u590D\u5236 */\n\t\t* {\n\t\t\tuser-select: text !important;\n\t\t}\n\n\t\t/* fix https://developer.mozilla.org/zh-CN/play */\n\t\tpre, code{\n\t\t\tword-break: break-all;\n\t\t}\n\n\t\t/* \u4E00\u952E\u590D\u5236\u4EE3\u7801\uFF1A\u9F20\u6807\u60AC\u6D6E\u4EE3\u7801\uFF0C\u70B9\u51FB\u7EA2\u8272\u8FB9\u6846 */\n\t\t:not(blockquote, pre) > pre {\n\t\t\t/* border-left: 8px solid #6d6b6b45 !important; */\n\t\t\t/* border-left: 8px solid transparent !important; */\n\t\t\tborder-radius: 4px !important;\n\t\t\toverflow-x: auto !important;\n\t\t\twhite-space: pre-wrap !important;\n\t\t\tcursor: pointer;\n\t\t}\n\t\t:not(blockquote, pre) > pre:hover {\n\t\t\t/* border-left-color: #6709099c !important; */\n\t\t\tborder-right: 8px solid #6709099c !important;\n\t\t\tmargin-right: -8px;\n\t\t\tposition: relative;\n\t\t}\n\n\t\t/* :not(blockquote, pre) > pre:hover:after {\n\t\t\tcontent: '\u4E00\u952E\u590D\u5236';\n\t\t\tdisplay: inline-block;\n\t\t\twidth: 10px;\n\t\t\ttransform: translateX(-4px);\n\t\t\tfont-size: 10px;\n\t\t\tposition: absolute;\n\t\t\ttop: 0;\n\t\t\tright: -4px;\n\t\t\tcolor: #fff;\n\t\t\tline-height: 14px;\n\t\t\tbackground: #a26969;\n\t\t\tpadding: 0 0 6px 4px;\n\t\t\tborder-radius: 0 0 0 16px;\n\t\t} */\n\n\t\t/* \u6CE8\u91CA\u6587\u672C\u8FC7\u957F\u65F6\uFF0C\u6362\u884C */\n\t\t:not(blockquote, pre) > pre > * {\n\t\t\tborder-radius: 0 !important;\n\t\t\twhite-space: pre-wrap !important;\n\t\t\tcursor: auto;\n\t\t}\n\n\t\t:not(blockquote, pre) > pre code {\n\t\t\tdisplay: block !important;\n\t\t}\n"
  2456. });
  2457. var createElementTip = createElementTipFn();
  2458. var pre_done_time = 0;
  2459. var is_mousedown = false;
  2460. var is_mousemove = false; // 避免双击时,选中复制
  2461. document.documentElement.addEventListener('mousedown', function () {
  2462. is_mousedown = true;
  2463. pre_done_time = Date.now();
  2464. }, {
  2465. capture: true //利用捕获阶段,解决【阻止冒泡】阻断事件传播
  2466. });
  2467. document.documentElement.addEventListener('mousemove', function () {
  2468. if (is_mousedown) {
  2469. pre_done_time = Date.now();
  2470. is_mousemove = true;
  2471. }
  2472. }, {
  2473. capture: true //利用捕获阶段,解决【阻止冒泡】阻断事件传播
  2474. });
  2475. document.documentElement.addEventListener('mouseup', function (e) {
  2476. if (is_mousedown && is_mousemove && Date.now() - pre_done_time < 500) {
  2477. onEmitCopyHandle(e);
  2478. }
  2479. is_mousedown = false;
  2480. is_mousemove = false;
  2481. }, {
  2482. capture: true //利用捕获阶段,解决【阻止冒泡】阻断事件传播
  2483. });
  2484. } catch (error) {
  2485. console.error(error);
  2486. }
  2487. }
  2488. ;// CONCATENATED MODULE: ./src/tool/csdn.js
  2489.  
  2490. function csdn_run() {
  2491. try {
  2492. if (codeIsNotExcutable('csdn', {
  2493. name: 'csdn登录',
  2494. feature: 'CSDN:仅在主动触发登录时,显示登录弹层,以便减少不必要的登录',
  2495. includedUrls: ['csdn.net']
  2496. }).notExcutable) return;
  2497. createElement('style', {
  2498. el: 'head',
  2499. id: 'csdn-ui',
  2500. textContent: "\n /* csdn \u4EE3\u7801\u5185\u5BB9\u5168\u5C55\u793A */\n .hide-preCode-box{\n padding-top:0px !important;\n }\n\n /* \u9690\u85CF\u3010\u767B\u5F55\u540E\u590D\u5236\u3011\u6587\u6848*/\n .hljs-button.signin{\n opacity:0;\n }\n\n /* csdn\u767B\u5F55\u5F39\u5C42\u79FB\u81F3\u5DE6\u4E0B\u89D2\n .passport-login-container {\n top:calc(100vh - 485px) !important;\n width:410px !important;\n height: 520px !important;\n border-radius: 8px !important;\n box-shadow: -5px 5px 10px 5px #979393 !important;\n transform: scale(0.8) !important;\n left: -24px;\n }\n */\n "
  2501. });
  2502. createElement('style', {
  2503. el: 'head',
  2504. addPrefix: '',
  2505. id: 'csdn-ui-login',
  2506. randomType: 'single',
  2507. textContent: "\n /* \u9690\u85CF\u767B\u5F55\u5F39\u5C42 */\n .passport-login-container{\n display:none;\n }\n .passport-login-mark {\n display:none !important;\n }\n "
  2508. });
  2509. document.addEventListener('click', function (e) {
  2510. var _target$className, _target$className$inc;
  2511. var target = e.target;
  2512. if ((_target$className = target.className) !== null && _target$className !== void 0 && (_target$className$inc = _target$className.includes) !== null && _target$className$inc !== void 0 && _target$className$inc.call(_target$className, 'toolbar-btn-loginfun')) {
  2513. var _document$querySelect;
  2514. (_document$querySelect = document.querySelector('#csdn-ui-login')) === null || _document$querySelect === void 0 || _document$querySelect.remove();
  2515. }
  2516. });
  2517. } catch (error) {
  2518. console.error(error);
  2519. }
  2520. }
  2521. ;// CONCATENATED MODULE: ./src/tool/calibreUI.js
  2522.  
  2523. // 解压后的epub电子书 浏览器预览
  2524. function calibreUI_run() {
  2525. try {
  2526. if (location.href.toLocaleLowerCase().includes('/oebps/text/')) {
  2527. modifyUI();
  2528. }
  2529. } catch (error) {
  2530. console.error(error);
  2531. }
  2532. }
  2533. function modifyUI() {
  2534. createElement('style', {
  2535. id: 'calibreUI',
  2536. innerHTML: "\n\t\t\tbody {\n\t\t\t\tmax-width:700px;\n\t\t\t}\n\t\t\t"
  2537. }, window);
  2538. }
  2539. ;// CONCATENATED MODULE: ./src/ImgPreview.js
  2540.  
  2541. ImgPreview_run();
  2542. function ImgPreview_run() {
  2543. run();
  2544. addBackgroundImg_run();
  2545. openUrlInText_run();
  2546. copySelectedText_run();
  2547. csdn_run();
  2548. calibreUI_run();
  2549. }
  2550. })();
  2551.  
  2552. /******/ })()
  2553. ;