js hook 变量

// ==UserScript==
// @name         Hook global
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       悦来客栈的老板
// @include      *
// @grant        none
// @run-at       document-start
// ==/UserScript==

(function() {
    'use strict';
    //全局变量 监控
    var t = window._t
    Object.defineProperty(window, '_t', {
        get: function() {
            console.log('Getting window._t');
            return t;
        },
        set: function(val) {
            console.log('Setting window._t', val);
            debugger;
            t = val;
        }
    })
})();
原文地址:https://www.cnblogs.com/angdh/p/14942513.html