Greasy Fork is available in English.

边读边看图

功能一览:1、图文对照: 双击把图片固定在页面上,同时支持缩放、移动功能,便于图文对照阅读; 2、图片背景图: 使用浏览器查看在线图片或本地图片时,增加页面背景图,以便清晰显示当前图片轮廓 3、快捷链接:点击链接文本时,跳转相应链接 4、复制所选文字:鼠标选中文字,0.5秒后,自动复制到剪贴板(同时支持:一键复制代码块,鼠标悬浮代码块后,点击显示的红色边框,复制到剪贴板) 5、CSDN:仅在主动触发登录时,显示登录弹层

Od 14.03.2024.. Pogledajte najnovija verzija.

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