Last active
July 26, 2023 08:08
-
-
Save mlzxgzy/87b0ced6a52662ae38611114a2c3c27e to your computer and use it in GitHub Desktop.
VueJs Devtools Cracker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name VueJsDevtools-限制解除 | |
| // @name:zh-CN VueJsDevtools-限制解除 | |
| // @name:en VueJsDevtools-Cracker | |
| // @namespace https://gist.github.com/mlzxgzy/87b0ced6a52662ae38611114a2c3c27e | |
| // @version 1.0 | |
| // @description 允许Vue.Js Devtools修改Prod站点 | |
| // @description:zh-CN 允许Vue.Js Devtools修改Prod站点 | |
| // @description:en VueJs Devtools Cracker | |
| // @author mlzxgzy | |
| // @match http://*/* | |
| // @match https://*/* | |
| // @icon none | |
| // @grant none | |
| // @license WTFPL - see http://wtfpl.net/ | |
| // @run-at document-end | |
| // ==/UserScript== | |
| (function () { | |
| 'use strict'; | |
| // See Source : https://github.com/vuejs/devtools/blob/main/packages/shell-chrome/src/detector.js | |
| // Method 1: Check Nuxt | |
| const nuxtDetected = !!(window.__NUXT__ || window.$nuxt) | |
| if (nuxtDetected) { | |
| console.debug("[JDC] Nuxt detected!"); | |
| let Vue | |
| if (window.$nuxt) { | |
| Vue = window.$nuxt.$root && window.$nuxt.$root.constructor | |
| } | |
| if (typeof Vue !== 'undefined' && typeof Vue.config !== 'undefined') { | |
| Vue.config.devtools = true; | |
| } | |
| if (typeof window.__VUE_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined') { | |
| window.__VUE_DEVTOOLS_GLOBAL_HOOK__.enabled = true; | |
| } | |
| console.debug("[JDC] Nuxt Hacked!"); | |
| return | |
| } | |
| // Method 2: Check Vue 3 | |
| const vueDetected = !!(window.__VUE__) | |
| if (vueDetected) { | |
| console.debug("[JDC] Vue3 detected!"); | |
| if (typeof window.__VUE_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined') { | |
| window.__VUE_DEVTOOLS_GLOBAL_HOOK__.enabled = true; | |
| } | |
| console.debug("[JDC] Vue3 Hacked!"); | |
| return | |
| } | |
| // Method 3: Scan all elements inside document | |
| const all = document.querySelectorAll('*') | |
| let el | |
| for (let i = 0; i < all.length; i++) { | |
| if (all[i].__vue__) { | |
| el = all[i] | |
| break | |
| } | |
| } | |
| if (el) { | |
| console.debug("[JDC] Vue detected!"); | |
| let Vue = Object.getPrototypeOf(el.__vue__).constructor | |
| while (Vue.super) { | |
| Vue = Vue.super | |
| } | |
| if (typeof Vue !== 'undefined' && typeof Vue.config !== 'undefined') { | |
| Vue.config.devtools = true; | |
| } | |
| console.debug("[JDC] Vue Hacked!"); | |
| return | |
| } | |
| console.debug("[JDC] Detected Failed!"); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment