Greasy Fork is available in English.

边读边看图

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

Mint 2024.06.07.. Lásd a legutóbbi verzió

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