Force Enable Vue Devtools

Force enable Vue Devtools for any Vue2 or Vue3 production build.

As of 2021-08-13. See the latest version.

  1. // ==UserScript==
  2. // @name Force Enable Vue Devtools
  3. // @version 0.2.3
  4. // @author Huang-Huang Bao <eh5@sokka.cn> (https://github.com/EHfive)
  5. // @description Force enable Vue Devtools for any Vue2 or Vue3 production build.
  6. // @homepage https://github.com/EHfive/userscripts/tree/master/userscripts/enbale-vue-devtools
  7. // @supportURL https://github.com/EHfive/userscripts/issues
  8. // @namespace https://eh5.me
  9. // @name:zh-CN 强制开启Vue Devtools
  10. // @name:zh-TW 強制開啓Vue Devtools
  11. // @description:zh-CN 为生产构建的Vue2或Vue3应用强制开启Vue Devtools
  12. // @description:zh-TW 爲生產構建的Vue2或Vue3應用強制開啓Vue Devtools
  13. // @license MIT
  14. // @run-at document-start
  15. // @noframes
  16. // @include /^.*$/
  17. // @grant unsafeWindow
  18. // @grant GM_info
  19. // @grant GM.info
  20. // ==/UserScript==
  21.  
  22. /******/ (function(modules) { // webpackBootstrap
  23. /******/ // The module cache
  24. /******/ var installedModules = {};
  25. /******/
  26. /******/ // The require function
  27. /******/ function __webpack_require__(moduleId) {
  28. /******/
  29. /******/ // Check if module is in cache
  30. /******/ if(installedModules[moduleId]) {
  31. /******/ return installedModules[moduleId].exports;
  32. /******/ }
  33. /******/ // Create a new module (and put it into the cache)
  34. /******/ var module = installedModules[moduleId] = {
  35. /******/ i: moduleId,
  36. /******/ l: false,
  37. /******/ exports: {}
  38. /******/ };
  39. /******/
  40. /******/ // Execute the module function
  41. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  42. /******/
  43. /******/ // Flag the module as loaded
  44. /******/ module.l = true;
  45. /******/
  46. /******/ // Return the exports of the module
  47. /******/ return module.exports;
  48. /******/ }
  49. /******/
  50. /******/
  51. /******/ // expose the modules object (__webpack_modules__)
  52. /******/ __webpack_require__.m = modules;
  53. /******/
  54. /******/ // expose the module cache
  55. /******/ __webpack_require__.c = installedModules;
  56. /******/
  57. /******/ // define getter function for harmony exports
  58. /******/ __webpack_require__.d = function(exports, name, getter) {
  59. /******/ if(!__webpack_require__.o(exports, name)) {
  60. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  61. /******/ }
  62. /******/ };
  63. /******/
  64. /******/ // define __esModule on exports
  65. /******/ __webpack_require__.r = function(exports) {
  66. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  67. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  68. /******/ }
  69. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  70. /******/ };
  71. /******/
  72. /******/ // create a fake namespace object
  73. /******/ // mode & 1: value is a module id, require it
  74. /******/ // mode & 2: merge all properties of value into the ns
  75. /******/ // mode & 4: return value when already ns object
  76. /******/ // mode & 8|1: behave like require
  77. /******/ __webpack_require__.t = function(value, mode) {
  78. /******/ if(mode & 1) value = __webpack_require__(value);
  79. /******/ if(mode & 8) return value;
  80. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  81. /******/ var ns = Object.create(null);
  82. /******/ __webpack_require__.r(ns);
  83. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  84. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  85. /******/ return ns;
  86. /******/ };
  87. /******/
  88. /******/ // getDefaultExport function for compatibility with non-harmony modules
  89. /******/ __webpack_require__.n = function(module) {
  90. /******/ var getter = module && module.__esModule ?
  91. /******/ function getDefault() { return module['default']; } :
  92. /******/ function getModuleExports() { return module; };
  93. /******/ __webpack_require__.d(getter, 'a', getter);
  94. /******/ return getter;
  95. /******/ };
  96. /******/
  97. /******/ // Object.prototype.hasOwnProperty.call
  98. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  99. /******/
  100. /******/ // __webpack_public_path__
  101. /******/ __webpack_require__.p = "";
  102. /******/
  103. /******/
  104. /******/ // Load entry module and return exports
  105. /******/ return __webpack_require__(__webpack_require__.s = 1);
  106. /******/ })
  107. /************************************************************************/
  108. /******/ ([
  109. /* 0 */
  110. /***/ (function(module, exports) {
  111.  
  112. /******/ (function(modules) { // webpackBootstrap
  113. /******/ // The module cache
  114. /******/ var installedModules = {};
  115. /******/
  116. /******/ // The require function
  117. /******/ function __webpack_require__(moduleId) {
  118. /******/
  119. /******/ // Check if module is in cache
  120. /******/ if(installedModules[moduleId]) {
  121. /******/ return installedModules[moduleId].exports;
  122. /******/ }
  123. /******/ // Create a new module (and put it into the cache)
  124. /******/ var module = installedModules[moduleId] = {
  125. /******/ i: moduleId,
  126. /******/ l: false,
  127. /******/ exports: {}
  128. /******/ };
  129. /******/
  130. /******/ // Execute the module function
  131. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  132. /******/
  133. /******/ // Flag the module as loaded
  134. /******/ module.l = true;
  135. /******/
  136. /******/ // Return the exports of the module
  137. /******/ return module.exports;
  138. /******/ }
  139. /******/
  140. /******/
  141. /******/ // expose the modules object (__webpack_modules__)
  142. /******/ __webpack_require__.m = modules;
  143. /******/
  144. /******/ // expose the module cache
  145. /******/ __webpack_require__.c = installedModules;
  146. /******/
  147. /******/ // define getter function for harmony exports
  148. /******/ __webpack_require__.d = function(exports, name, getter) {
  149. /******/ if(!__webpack_require__.o(exports, name)) {
  150. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  151. /******/ }
  152. /******/ };
  153. /******/
  154. /******/ // define __esModule on exports
  155. /******/ __webpack_require__.r = function(exports) {
  156. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  157. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  158. /******/ }
  159. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  160. /******/ };
  161. /******/
  162. /******/ // create a fake namespace object
  163. /******/ // mode & 1: value is a module id, require it
  164. /******/ // mode & 2: merge all properties of value into the ns
  165. /******/ // mode & 4: return value when already ns object
  166. /******/ // mode & 8|1: behave like require
  167. /******/ __webpack_require__.t = function(value, mode) {
  168. /******/ if(mode & 1) value = __webpack_require__(value);
  169. /******/ if(mode & 8) return value;
  170. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  171. /******/ var ns = Object.create(null);
  172. /******/ __webpack_require__.r(ns);
  173. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  174. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  175. /******/ return ns;
  176. /******/ };
  177. /******/
  178. /******/ // getDefaultExport function for compatibility with non-harmony modules
  179. /******/ __webpack_require__.n = function(module) {
  180. /******/ var getter = module && module.__esModule ?
  181. /******/ function getDefault() { return module['default']; } :
  182. /******/ function getModuleExports() { return module; };
  183. /******/ __webpack_require__.d(getter, 'a', getter);
  184. /******/ return getter;
  185. /******/ };
  186. /******/
  187. /******/ // Object.prototype.hasOwnProperty.call
  188. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  189. /******/
  190. /******/ // __webpack_public_path__
  191. /******/ __webpack_require__.p = "";
  192. /******/
  193. /******/
  194. /******/ // Load entry module and return exports
  195. /******/ return __webpack_require__(__webpack_require__.s = 0);
  196. /******/ })
  197. /************************************************************************/
  198. /******/ ([
  199. /* 0 */
  200. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  201.  
  202. "use strict";
  203. __webpack_require__.r(__webpack_exports__);
  204. /* harmony import */ var _vendor_gm4_polyfill_gm4_polyfill_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1);
  205. /* harmony import */ var _vendor_gm4_polyfill_gm4_polyfill_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_vendor_gm4_polyfill_gm4_polyfill_js__WEBPACK_IMPORTED_MODULE_0__);
  206.  
  207.  
  208. (function () {
  209. if(typeof unsafeWindow === 'object' && unsafeWindow) {
  210. unsafeWindow.GM = this.GM
  211. }
  212. }).call(window);
  213.  
  214.  
  215. /***/ }),
  216. /* 1 */
  217. /***/ (function(module, exports) {
  218.  
  219. /*** IMPORTS FROM imports-loader ***/
  220.  
  221. (function() {
  222. /*
  223. This helper script bridges compatibility between the Greasemonkey 4 APIs and
  224. existing/legacy APIs. Say for example your user script includes
  225.  
  226. // @grant GM_getValue
  227.  
  228. And you'd like to be compatible with both Greasemonkey 3 and Greasemonkey 4
  229. (and for that matter all versions of Violentmonkey, Tampermonkey, and any other
  230. user script engine). Add:
  231.  
  232. // @grant GM.getValue
  233. // @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
  234.  
  235. And switch to the new (GM-dot) APIs, which return promises. If your script
  236. is running in an engine that does not provide the new asynchronous APIs, this
  237. helper will add them, based on the old APIs.
  238.  
  239. If you use `await` at the top level, you'll need to wrap your script in an
  240. `async` function to be compatible with any user script engine besides
  241. Greasemonkey 4.
  242.  
  243. (async () => {
  244. let x = await GM.getValue('x');
  245. })();
  246. */
  247.  
  248. if (typeof GM == 'undefined') {
  249. this.GM = {};
  250. }
  251.  
  252.  
  253. if (typeof GM_addStyle == 'undefined') {
  254. this.GM_addStyle = (aCss) => {
  255. 'use strict';
  256. let head = document.getElementsByTagName('head')[0];
  257. if (head) {
  258. let style = document.createElement('style');
  259. style.setAttribute('type', 'text/css');
  260. style.textContent = aCss;
  261. head.appendChild(style);
  262. return style;
  263. }
  264. return null;
  265. };
  266. }
  267.  
  268.  
  269. if (typeof GM_registerMenuCommand == 'undefined') {
  270. this.GM_registerMenuCommand = (caption, commandFunc, accessKey) => {
  271. if (!document.body) {
  272. if (document.readyState === 'loading'
  273. && document.documentElement && document.documentElement.localName === 'html') {
  274. new MutationObserver((mutations, observer) => {
  275. if (document.body) {
  276. observer.disconnect();
  277. GM_registerMenuCommand(caption, commandFunc, accessKey);
  278. }
  279. }).observe(document.documentElement, {childList: true});
  280. } else {
  281. console.error('GM_registerMenuCommand got no body.');
  282. }
  283. return;
  284. }
  285. let contextMenu = document.body.getAttribute('contextmenu');
  286. let menu = (contextMenu ? document.querySelector('menu#' + contextMenu) : null);
  287. if (!menu) {
  288. menu = document.createElement('menu');
  289. menu.setAttribute('id', 'gm-registered-menu');
  290. menu.setAttribute('type', 'context');
  291. document.body.appendChild(menu);
  292. document.body.setAttribute('contextmenu', 'gm-registered-menu');
  293. }
  294. let menuItem = document.createElement('menuitem');
  295. menuItem.textContent = caption;
  296. menuItem.addEventListener('click', commandFunc, true);
  297. menu.appendChild(menuItem);
  298. };
  299. }
  300.  
  301.  
  302. if (typeof GM_getResourceText == 'undefined') {
  303. this.GM_getResourceText = (aRes) => {
  304. 'use strict';
  305. return GM.getResourceUrl(aRes)
  306. .then(url => fetch(url))
  307. .then(resp => resp.text())
  308. .catch(function(error) {
  309. GM.log('Request failed', error);
  310. return null;
  311. });
  312. };
  313. }
  314.  
  315.  
  316. Object.entries({
  317. 'log': console.log.bind(console), // Pale Moon compatibility. See #13.
  318. 'info': GM_info,
  319. }).forEach(([newKey, old]) => {
  320. if (old && (typeof GM[newKey] == 'undefined')) {
  321. GM[newKey] = old;
  322. }
  323. });
  324.  
  325.  
  326. Object.entries({
  327. 'GM_addStyle': 'addStyle',
  328. 'GM_deleteValue': 'deleteValue',
  329. 'GM_getResourceURL': 'getResourceUrl',
  330. 'GM_getValue': 'getValue',
  331. 'GM_listValues': 'listValues',
  332. 'GM_notification': 'notification',
  333. 'GM_openInTab': 'openInTab',
  334. 'GM_registerMenuCommand': 'registerMenuCommand',
  335. 'GM_setClipboard': 'setClipboard',
  336. 'GM_setValue': 'setValue',
  337. 'GM_xmlhttpRequest': 'xmlHttpRequest',
  338. 'GM_getResourceText': 'getResourceText',
  339. }).forEach(([oldKey, newKey]) => {
  340. let old = this[oldKey];
  341. if (old && (typeof GM[newKey] == 'undefined')) {
  342. GM[newKey] = function(...args) {
  343. return new Promise((resolve, reject) => {
  344. try {
  345. resolve(old.apply(this, args));
  346. } catch (e) {
  347. reject(e);
  348. }
  349. });
  350. };
  351. }
  352. });
  353.  
  354. }.call(window));
  355.  
  356.  
  357. /***/ })
  358. /******/ ]);
  359.  
  360. /***/ }),
  361. /* 1 */
  362. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  363.  
  364. "use strict";
  365. // ESM COMPAT FLAG
  366. __webpack_require__.r(__webpack_exports__);
  367.  
  368. // EXTERNAL MODULE: /home/eh5/Projects/userscripts/packages/polyfills/dist/index.js
  369. var dist = __webpack_require__(0);
  370.  
  371. // CONCATENATED MODULE: /home/eh5/Projects/userscripts/.yarn/cache/consola-npm-2.15.0-71e35f623c-9a20844425.zip/node_modules/consola/src/logLevels.js
  372. const LogLevel = {};
  373. LogLevel[LogLevel.Fatal = 0] = 'Fatal';
  374. LogLevel[LogLevel.Error = 0] = 'Error';
  375. LogLevel[LogLevel.Warn = 1] = 'Warn';
  376. LogLevel[LogLevel.Log = 2] = 'Log';
  377. LogLevel[LogLevel.Info = 3] = 'Info';
  378. LogLevel[LogLevel.Success = 3] = 'Success';
  379. LogLevel[LogLevel.Debug = 4] = 'Debug';
  380. LogLevel[LogLevel.Trace = 5] = 'Trace';
  381. LogLevel[LogLevel.Silent = -Infinity] = 'Silent';
  382. LogLevel[LogLevel.Verbose = Infinity] = 'Verbose';
  383. // CONCATENATED MODULE: /home/eh5/Projects/userscripts/.yarn/cache/consola-npm-2.15.0-71e35f623c-9a20844425.zip/node_modules/consola/src/types.js
  384.  
  385. /* harmony default export */ var src_types = ({
  386. // Silent
  387. silent: {
  388. level: -1
  389. },
  390. // Level 0
  391. fatal: {
  392. level: LogLevel.Fatal
  393. },
  394. error: {
  395. level: LogLevel.Error
  396. },
  397. // Level 1
  398. warn: {
  399. level: LogLevel.Warn
  400. },
  401. // Level 2
  402. log: {
  403. level: LogLevel.Log
  404. },
  405. // Level 3
  406. info: {
  407. level: LogLevel.Info
  408. },
  409. success: {
  410. level: LogLevel.Success
  411. },
  412. // Level 4
  413. debug: {
  414. level: LogLevel.Debug
  415. },
  416. // Level 5
  417. trace: {
  418. level: LogLevel.Trace
  419. },
  420. // Verbose
  421. verbose: {
  422. level: LogLevel.Trace
  423. },
  424. // Legacy
  425. ready: {
  426. level: LogLevel.Info
  427. },
  428. start: {
  429. level: LogLevel.Info
  430. }
  431. });
  432. // CONCATENATED MODULE: /home/eh5/Projects/userscripts/.yarn/cache/consola-npm-2.15.0-71e35f623c-9a20844425.zip/node_modules/consola/src/utils/index.js
  433. function isPlainObject(obj) {
  434. return Object.prototype.toString.call(obj) === '[object Object]';
  435. } // TODO: remove for consola@3
  436.  
  437. function isLogObj(arg) {
  438. // Should be plain object
  439. if (!isPlainObject(arg)) {
  440. return false;
  441. } // Should contains either 'message' or 'args' field
  442.  
  443.  
  444. if (!arg.message && !arg.args) {
  445. return false;
  446. } // Handle non-standard error objects
  447.  
  448.  
  449. if (arg.stack) {
  450. return false;
  451. }
  452.  
  453. return true;
  454. }
  455. // CONCATENATED MODULE: /home/eh5/Projects/userscripts/.yarn/cache/consola-npm-2.15.0-71e35f623c-9a20844425.zip/node_modules/consola/src/consola.js
  456.  
  457.  
  458. let paused = false;
  459. const queue = [];
  460.  
  461. class consola_Consola {
  462. constructor(options = {}) {
  463. this._reporters = options.reporters || [];
  464. this._types = options.types || src_types;
  465. this.level = options.level !== undefined ? options.level : 3;
  466. this._defaults = options.defaults || {};
  467. this._async = options.async !== undefined ? options.async : undefined;
  468. this._stdout = options.stdout;
  469. this._stderr = options.stderr;
  470. this._mockFn = options.mockFn;
  471. this._throttle = options.throttle || 1000;
  472. this._throttleMin = options.throttleMin || 5; // Create logger functions for current instance
  473.  
  474. for (const type in this._types) {
  475. this[type] = this._wrapLogFn(Object.assign({
  476. type
  477. }, this._types[type], this._defaults));
  478. } // Use _mockFn if is set
  479.  
  480.  
  481. if (this._mockFn) {
  482. this.mockTypes();
  483. } // Keep serialized version of last log
  484.  
  485.  
  486. this._lastLogSerialized = undefined;
  487. this._lastLog = undefined;
  488. this._lastLogTime = undefined;
  489. this._lastLogCount = 0;
  490. this._throttleTimeout = undefined;
  491. }
  492.  
  493. get stdout() {
  494. return this._stdout || console._stdout; // eslint-disable-line no-console
  495. }
  496.  
  497. get stderr() {
  498. return this._stderr || console._stderr; // eslint-disable-line no-console
  499. }
  500.  
  501. create(options) {
  502. return new consola_Consola(Object.assign({
  503. reporters: this._reporters,
  504. level: this.level,
  505. types: this._types,
  506. defaults: this._defaults,
  507. stdout: this._stdout,
  508. stderr: this._stderr,
  509. mockFn: this._mockFn
  510. }, options));
  511. }
  512.  
  513. withDefaults(defaults) {
  514. return this.create({
  515. defaults: Object.assign({}, this._defaults, defaults)
  516. });
  517. }
  518.  
  519. withTag(tag) {
  520. return this.withDefaults({
  521. tag: this._defaults.tag ? this._defaults.tag + ':' + tag : tag
  522. });
  523. }
  524.  
  525. addReporter(reporter) {
  526. this._reporters.push(reporter);
  527.  
  528. return this;
  529. }
  530.  
  531. removeReporter(reporter) {
  532. if (reporter) {
  533. const i = this._reporters.indexOf(reporter);
  534.  
  535. if (i >= 0) {
  536. return this._reporters.splice(i, 1);
  537. }
  538. } else {
  539. this._reporters.splice(0);
  540. }
  541.  
  542. return this;
  543. }
  544.  
  545. setReporters(reporters) {
  546. this._reporters = Array.isArray(reporters) ? reporters : [reporters];
  547. return this;
  548. }
  549.  
  550. wrapAll() {
  551. this.wrapConsole();
  552. this.wrapStd();
  553. }
  554.  
  555. restoreAll() {
  556. this.restoreConsole();
  557. this.restoreStd();
  558. }
  559.  
  560. wrapConsole() {
  561. for (const type in this._types) {
  562. // Backup original value
  563. if (!console['__' + type]) {
  564. // eslint-disable-line no-console
  565. console['__' + type] = console[type]; // eslint-disable-line no-console
  566. } // Override
  567.  
  568.  
  569. console[type] = this[type]; // eslint-disable-line no-console
  570. }
  571. }
  572.  
  573. restoreConsole() {
  574. for (const type in this._types) {
  575. // Restore if backup is available
  576. if (console['__' + type]) {
  577. // eslint-disable-line no-console
  578. console[type] = console['__' + type]; // eslint-disable-line no-console
  579.  
  580. delete console['__' + type]; // eslint-disable-line no-console
  581. }
  582. }
  583. }
  584.  
  585. wrapStd() {
  586. this._wrapStream(this.stdout, 'log');
  587.  
  588. this._wrapStream(this.stderr, 'log');
  589. }
  590.  
  591. _wrapStream(stream, type) {
  592. if (!stream) {
  593. return;
  594. } // Backup original value
  595.  
  596.  
  597. if (!stream.__write) {
  598. stream.__write = stream.write;
  599. } // Override
  600.  
  601.  
  602. stream.write = data => {
  603. this[type](String(data).trim());
  604. };
  605. }
  606.  
  607. restoreStd() {
  608. this._restoreStream(this.stdout);
  609.  
  610. this._restoreStream(this.stderr);
  611. }
  612.  
  613. _restoreStream(stream) {
  614. if (!stream) {
  615. return;
  616. }
  617.  
  618. if (stream.__write) {
  619. stream.write = stream.__write;
  620. delete stream.__write;
  621. }
  622. }
  623.  
  624. pauseLogs() {
  625. paused = true;
  626. }
  627.  
  628. resumeLogs() {
  629. paused = false; // Process queue
  630.  
  631. const _queue = queue.splice(0);
  632.  
  633. for (const item of _queue) {
  634. item[0]._logFn(item[1], item[2]);
  635. }
  636. }
  637.  
  638. mockTypes(mockFn) {
  639. this._mockFn = mockFn || this._mockFn;
  640.  
  641. if (typeof this._mockFn !== 'function') {
  642. return;
  643. }
  644.  
  645. for (const type in this._types) {
  646. this[type] = this._mockFn(type, this._types[type]) || this[type];
  647. }
  648. }
  649.  
  650. _wrapLogFn(defaults) {
  651. function logFn() {
  652. if (paused) {
  653. queue.push([this, defaults, arguments]);
  654. return;
  655. }
  656.  
  657. return this._logFn(defaults, arguments);
  658. }
  659.  
  660. return logFn.bind(this);
  661. }
  662.  
  663. _logFn(defaults, args) {
  664. if (defaults.level > this.level) {
  665. return this._async ? Promise.resolve(false) : false;
  666. } // Construct a new log object
  667.  
  668.  
  669. const logObj = Object.assign({
  670. date: new Date(),
  671. args: []
  672. }, defaults); // Consume arguments
  673.  
  674. if (args.length === 1 && isLogObj(args[0])) {
  675. Object.assign(logObj, args[0]);
  676. } else {
  677. logObj.args = Array.from(args);
  678. } // Aliases
  679.  
  680.  
  681. if (logObj.message) {
  682. logObj.args.unshift(logObj.message);
  683. delete logObj.message;
  684. }
  685.  
  686. if (logObj.additional) {
  687. if (!Array.isArray(logObj.additional)) {
  688. logObj.additional = logObj.additional.split('\n');
  689. }
  690.  
  691. logObj.args.push('\n' + logObj.additional.join('\n'));
  692. delete logObj.additional;
  693. } // Normalize type and tag to lowercase
  694.  
  695.  
  696. logObj.type = typeof logObj.type === 'string' ? logObj.type.toLowerCase() : '';
  697. logObj.tag = typeof logObj.tag === 'string' ? logObj.tag.toLowerCase() : ''; // Resolve log
  698.  
  699. /**
  700. * @param newLog false if the throttle expired and
  701. * we don't want to log a duplicate
  702. */
  703.  
  704. const resolveLog = (newLog = false) => {
  705. const repeated = this._lastLogCount - this._throttleMin;
  706.  
  707. if (this._lastLog && repeated > 0) {
  708. const args = [...this._lastLog.args];
  709.  
  710. if (repeated > 1) {
  711. args.push(`(repeated ${repeated} times)`);
  712. }
  713.  
  714. this._log({ ...this._lastLog,
  715. args
  716. });
  717.  
  718. this._lastLogCount = 1;
  719. } // Log
  720.  
  721.  
  722. if (newLog) {
  723. this._lastLog = logObj;
  724.  
  725. if (this._async) {
  726. return this._logAsync(logObj);
  727. } else {
  728. this._log(logObj);
  729. }
  730. }
  731. }; // Throttle
  732.  
  733.  
  734. clearTimeout(this._throttleTimeout);
  735. const diffTime = this._lastLogTime ? logObj.date - this._lastLogTime : 0;
  736. this._lastLogTime = logObj.date;
  737.  
  738. if (diffTime < this._throttle) {
  739. try {
  740. const serializedLog = JSON.stringify([logObj.type, logObj.tag, logObj.args]);
  741. const isSameLog = this._lastLogSerialized === serializedLog;
  742. this._lastLogSerialized = serializedLog;
  743.  
  744. if (isSameLog) {
  745. this._lastLogCount++;
  746.  
  747. if (this._lastLogCount > this._throttleMin) {
  748. // Auto-resolve when throttle is timed out
  749. this._throttleTimeout = setTimeout(resolveLog, this._throttle);
  750. return; // SPAM!
  751. }
  752. }
  753. } catch (_) {// Circular References
  754. }
  755. }
  756.  
  757. resolveLog(true);
  758. }
  759.  
  760. _log(logObj) {
  761. for (const reporter of this._reporters) {
  762. reporter.log(logObj, {
  763. async: false,
  764. stdout: this.stdout,
  765. stderr: this.stderr
  766. });
  767. }
  768. }
  769.  
  770. _logAsync(logObj) {
  771. return Promise.all(this._reporters.map(reporter => reporter.log(logObj, {
  772. async: true,
  773. stdout: this.stdout,
  774. stderr: this.stderr
  775. })));
  776. }
  777.  
  778. } // Legacy support
  779.  
  780.  
  781. consola_Consola.prototype.add = consola_Consola.prototype.addReporter;
  782. consola_Consola.prototype.remove = consola_Consola.prototype.removeReporter;
  783. consola_Consola.prototype.clear = consola_Consola.prototype.removeReporter;
  784. consola_Consola.prototype.withScope = consola_Consola.prototype.withTag;
  785. consola_Consola.prototype.mock = consola_Consola.prototype.mockTypes;
  786. consola_Consola.prototype.pause = consola_Consola.prototype.pauseLogs;
  787. consola_Consola.prototype.resume = consola_Consola.prototype.resumeLogs; // Export class
  788.  
  789. /* harmony default export */ var consola = (consola_Consola);
  790. // CONCATENATED MODULE: /home/eh5/Projects/userscripts/.yarn/cache/consola-npm-2.15.0-71e35f623c-9a20844425.zip/node_modules/consola/src/reporters/browser.js
  791. class BrowserReporter {
  792. constructor(options) {
  793. this.options = Object.assign({}, options);
  794. this.defaultColor = '#7f8c8d'; // Gray
  795.  
  796. this.levelColorMap = {
  797. 0: '#c0392b',
  798. // Red
  799. 1: '#f39c12',
  800. // Yellow
  801. 3: '#00BCD4' // Cyan
  802.  
  803. };
  804. this.typeColorMap = {
  805. success: '#2ecc71' // Green
  806.  
  807. };
  808. }
  809.  
  810. log(logObj) {
  811. const consoleLogFn = logObj.level < 1 // eslint-disable-next-line no-console
  812. ? console.__error || console.error : // eslint-disable-next-line no-console
  813. logObj.level === 1 && console.warn ? console.__warn || console.warn : console.__log || console.log; // Type
  814.  
  815. const type = logObj.type !== 'log' ? logObj.type : ''; // Tag
  816.  
  817. const tag = logObj.tag ? logObj.tag : ''; // Styles
  818.  
  819. const color = this.typeColorMap[logObj.type] || this.levelColorMap[logObj.level] || this.defaultColor;
  820. const style = `
  821. background: ${color};
  822. border-radius: 0.5em;
  823. color: white;
  824. font-weight: bold;
  825. padding: 2px 0.5em;
  826. `;
  827. const badge = `%c${[tag, type].filter(Boolean).join(':')}`; // Log to the console
  828.  
  829. if (typeof logObj.args[0] === 'string') {
  830. consoleLogFn(`${badge}%c ${logObj.args[0]}`, style, // Empty string as style resets to default console style
  831. '', ...logObj.args.slice(1));
  832. } else {
  833. consoleLogFn(badge, style, ...logObj.args);
  834. }
  835. }
  836.  
  837. }
  838. // CONCATENATED MODULE: ./src/logger.js
  839.  
  840.  
  841. const pkgName = "enable-vue-devtools";
  842. const logger = new consola({
  843. reporters: [new BrowserReporter()],
  844. defaults: {
  845. tag: pkgName
  846. }
  847. });
  848. /* harmony default export */ var src_logger = (logger);
  849. // CONCATENATED MODULE: ./src/main.js
  850. /* harmony default export */ var main = (main_main);
  851.  
  852.  
  853. const _global = typeof unsafeWindow === 'object' && unsafeWindow || globalThis; // devtool hook should be ready when <body> exists
  854.  
  855.  
  856. const _devtoolHook = _global.__VUE_DEVTOOLS_GLOBAL_HOOK__;
  857.  
  858. function main_main() {
  859. if (!_devtoolHook) {
  860. src_logger.warn('No Vue Devtools hook found', _global.location);
  861. return;
  862. }
  863.  
  864. observeVueRoot(function (app, disconnect) {
  865. emitDevtoolVue2Hooks(app);
  866. }, function (app, disconnect) {
  867. emitDevtoolVue3Hooks(app);
  868. });
  869. }
  870.  
  871. function emitDevtoolVue2Hooks(app) {
  872. let Vue = app.constructor;
  873. const store = app.$store;
  874.  
  875. while (Vue.super) {
  876. // find base Vue
  877. Vue = Vue.super;
  878. }
  879.  
  880. Vue.config.devtools = true;
  881. src_logger.info('enabling devtools for Vue instance', app); // must re-emit 'init' if this Vue is different with other Vue(s)
  882. // otherwise this `Vue`'s root instance would not be added to Devtools store
  883. // https://github.com/vuejs/vue-devtools/blob/933063fd06860464be4bfd8c83ba09d7fc2c753e/packages/app-backend/src/index.js#L218-L225
  884.  
  885. _devtoolHook.emit('init', Vue); // TODO validate Vuex instance
  886.  
  887.  
  888. if (store) {
  889. src_logger.info('enabling devtools for Vuex instance', store);
  890. devtoolStorePlugin(store, _devtoolHook);
  891. }
  892. }
  893.  
  894. function emitDevtoolVue3Hooks(app) {
  895. if (!Array.isArray(_devtoolHook.apps)) return;
  896. if (_devtoolHook.apps.includes(app)) return;
  897. let version = app.version;
  898.  
  899. if (!version) {
  900. src_logger.warn('no Vue version detected, fallback to "3.0.0"');
  901. version = '3.0.0';
  902. }
  903.  
  904. src_logger.info('enabling devtools for Vue 3 instance', app); // FIXME: impossible to get those Symbols,
  905. // https://github.com/vuejs/vue-next/blob/410e7abbbb78e83989ad2e5a1793c290129dfdc7/packages/runtime-core/src/devtools.ts#L38
  906.  
  907. const types = {
  908. Fragment: undefined,
  909. Text: undefined,
  910. Comment: undefined,
  911. Static: undefined
  912. };
  913.  
  914. _devtoolHook.emit('app:init', app, version, types);
  915.  
  916. const unmount = app.unmount.bind(app);
  917.  
  918. app.unmount = function () {
  919. _devtoolHook.emit('app:unmount', app);
  920.  
  921. unmount();
  922. };
  923. }
  924.  
  925. function checkVue2Instance(target) {
  926. const vue = target && target.__vue__;
  927. return !!(vue && typeof vue === 'object' && vue._isVue && typeof vue.constructor === 'function');
  928. }
  929.  
  930. function checkVue3Instance(target) {
  931. const app = target && target.__vue_app__;
  932. return !!app;
  933. }
  934.  
  935. function noop() {}
  936.  
  937. function observeVueRoot(callbackVue2, callbackVue3) {
  938. if (typeof callbackVue2 !== 'function') {
  939. callbackVue2 = noop;
  940. }
  941.  
  942. if (typeof callbackVue3 !== 'function') {
  943. callbackVue3 = noop;
  944. }
  945.  
  946. const vue2RootSet = new WeakSet();
  947. const vue3RootSet = new WeakSet();
  948. const observer = new MutationObserver((mutations, observer) => {
  949. const disconnect = observer.disconnect.bind(observer);
  950.  
  951. for (const {
  952. target
  953. } of mutations) {
  954. if (!target) {
  955. return;
  956. } else if (checkVue2Instance(target)) {
  957. const inst = target.__vue__;
  958. const root = inst.$parent ? inst.$root : inst;
  959.  
  960. if (vue2RootSet.has(root)) {
  961. // already callback, continue loop
  962. continue;
  963. }
  964.  
  965. vue2RootSet.add(root);
  966. callbackVue2(root, disconnect);
  967. } else if (checkVue3Instance(target)) {
  968. const app = target.__vue_app__;
  969.  
  970. if (vue3RootSet.has(app)) {
  971. // already callback, continue loop
  972. continue;
  973. }
  974.  
  975. vue3RootSet.add(app);
  976. callbackVue3(app, disconnect);
  977. }
  978. }
  979. });
  980. observer.observe(document.documentElement, {
  981. attributes: true,
  982. subtree: true,
  983. childList: true
  984. });
  985. return observer;
  986. }
  987.  
  988. function devtoolStorePlugin(store, devtoolHook) {
  989. store._devtoolHook = devtoolHook;
  990. devtoolHook.emit('vuex:init', store);
  991. devtoolHook.on('vuex:travel-to-state', targetState => {
  992. store.replaceState(targetState);
  993. });
  994. store.subscribe((mutation, state) => {
  995. devtoolHook.emit('vuex:mutation', mutation, state);
  996. });
  997. }
  998. // CONCATENATED MODULE: ./src/index.js
  999.  
  1000.  
  1001.  
  1002.  
  1003. try {
  1004. main();
  1005.  
  1006. if (false) {}
  1007. } catch (e) {
  1008. src_logger.error(e);
  1009. }
  1010.  
  1011. /***/ })
  1012. /******/ ]);