如何绕过域名限制,尝鲜小程序嵌入web页面

706 阅读3分钟
原文链接: fddcn.cn
  • 改开发者工具的源码,方法很简单,小程序开发者工具,1.01.1711020 版,/Applications/wechatwebdevtools.app/Contents/Resources/app.nw/js/c4190a2430506f3602ca550e1e75d620.js 找到这个路径下的文件,打开修改为
    'use strict';
    ! function(require, directRequire) {
        const a = require('./822bc5aa1823c9aa222d9ffad72e7f17.js'),
            b = require('./f0b1e76146041102932a0ff6c1247619.js'),
            c = require('./df6d0ff021a69fb541c733de4dbba0fe.js'),
            d = require('./common/locales/index.js'),
            e = require('./15ba1827c7f6564a45df6bd44da3a977.js'),
            f = require('./0b01a3ff1572567a994a0ceae64dfef3.js'),
            g = require('./bc78839ccca8df9e5ceeb7fae11b7be2.js'),
            h = require('./d3976cc01aeebc5b09e11c4135b6bd8d.js');
        module.exports = {
            showDevtools: function(b) { return { type: a.WEBDEBUGGER_SHOW_DEVTOOLS, webview: b } },
            setUrl: function(b) { return { type: a.WEBDEBUGGER_SET_URL, url: b } },
            getA8Key: function(e) {
                return (f) => {
                    b(e).then((b) => {
                        let g = b.baseresponse || {},
                            i = g.errcode;
                        if (i == c.NOT_LIMITS || i == c.NOT_LIMITS_QY) { let b = h.parseCgiErrorCode(i, g.errmsg); return void f({ type: a.WEBDEBUGGER_SET_CONFIRM, data: { show: !0, confirmText: '\u67E5\u770B\u6587\u6863', content: b, callback: (a) => { a && nw.Shell.openExternal('https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1455784140') } } }) } f({ type: a.WEBDEBUGGER_SET_PURVIEW, data: { purviewFormGetA8key: b.purviewFormGetA8key } });
                        let j = b.resp_url;
                        if (e.isSync || b.force_redirect || i == c.ILLEGAL_URL) return f({ type: a.WEBDEBUGGER_SET_URL, url: j, from: e.from }), void f({ type: a.WEBDEBUGGER_SET_ACT, data: 'load' });
                        let k = /\#wechat_redirect$/.test(e.url);
                        if (k && e.url.replace(/\#wechat_redirect$/, '') === j) return j = j.replace(/\#wechat_redirect/, ''), void f({ type: a.WEBDEBUGGER_SET_CONFIRM, data: { show: !0, showCancel: !1, content: d.config.CGI_ERR_OAUTH_NOT_SUPPORT } })
                    }).catch((b) => { f({ type: a.WEBDEBUGGER_SET_CONFIRM, data: { show: !0, showCancel: !1, content: b } }) })
                }
            },
            setAutoComplete: function(b) { return { type: a.WEBDEBUGGER_SET_AUTOCOMPLETE, url: b } },
            setActions: function(b) { return { type: a.WEBDEBUGGER_SET_ACT, data: b } },
            setFooter: function(b) { return { type: a.WEBDEBUGGER_SET_FOOTER, data: b } },
            setShare: function(b) { return { type: a.WEBDEBUGGER_SET_SHARE, data: b } },
            setJssdkCallback: function(b) { return { type: a.WEBDEBUGGER_SET_JSSDKCALLBACK, data: b } },
            hideCardView: function({ callbackID: b, res: c }) { return (d) => { d({ type: a.WEBDEBUGGER_SET_CARD_VIEW, data: { show: 'none', cardInfo: [] } }), b && d({ type: a.WEBDEBUGGER_SET_JSSDKCALLBACK, data: { callbackID: b, res: c } }) } },
            batchAddCard: function({ callbackID: b, list: c }) {
                return (d) => {
                    const h = g.getState(),
                        i = h.webdebugger || {},
                        j = i.cardInfo || {},
                        k = j.appid;
                    let l = { url: `${f.batchAddCardURL}?isapp=1`, body: JSON.stringify({ appid: k, acceptitem_list: c }), method: 'post', needToken: 1 };
                    e(l).then((e) => {
                        let f = e.body,
                            g = f.resp_list;
                        g = g.map((a, b) => {
                            let d = c[b],
                                e = JSON.parse(a.json_ret);
                            return { cardId: d.card_id, cartExt: d.card_ext, code: e.encrypt_code, isSuccess: !0 }
                        }), d({ type: a.WEBDEBUGGER_SET_JSSDKCALLBACK, data: { callbackID: b, res: { errMsg: `addCard:ok`, cardList: g } } })
                    }).catch((c) => { d({ type: a.WEBDEBUGGER_SET_JSSDKCALLBACK, data: { callbackID: b, res: { errMsg: `addCard:fail {c}` } } }) }), d({ type: a.WEBDEBUGGER_SET_CARD_VIEW, data: { show: 'none', cardInfo: [] } })
                }
            },
            clearAutoComplete: function() { return { type: a.WEBDEBUGGER_CLEAR_AUTOCOMPLETE } },
            setClickkey: function(b) { return (c) => { c({ type: a.TOOLBAR_TOGGLE_CLICKKEY, clickKey: b }), c({ type: a.WEBDEBUGGER_SET_CLICKKEY, data: b }) } },
            setLeftBtn: function(b) { return { type: a.WEBDEBUGGER_SET_LEFTBTN, data: b } },
            setTitle: function(b) { return { type: a.WEBDEBUGGER_SET_TITLE, data: b } },
            setUrlComplete: function(b) { return { type: a.WEBDEBUGGER_SET_URLCOMPLETE, data: b } },
            setConfirm: function(b) { return { type: a.WEBDEBUGGER_SET_CONFIRM, data: b } },
            getWeappA8Key: function(e) {
                return (f) => {
                    e.isWeapp = !0, b(e).then((_b) => {
                        let b = _b;
                        b.resp_url = b.share_url;
                        b.force_redirect = 0; // 注意上面的三行,篡改了接口的返回值,哈哈哈
                        let g = b.baseresponse || {},
                            i = g.errcode;
                        if (i == c.NOT_LIMITS || i == c.NOT_LIMITS_QY) { let b = h.parseCgiErrorCode(i, g.errmsg); return void f({ type: a.INFO_SET_CONFIRM, data: { show: !0, confirmText: '\u67E5\u770B\u6587\u6863', content: b, callback: (a) => { a && nw.Shell.openExternal('https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1455784140') } } }) } f({ type: a.WEBDEBUGGER_SET_PURVIEW, data: { purviewFormGetA8key: b.purviewFormGetA8key } });
                        let j = b.resp_url;
                        if (e.isSync || b.force_redirect || i == c.ILLEGAL_URL) return f({ type: a.WEBDEBUGGER_SET_URL, url: j }), void f({ type: a.SIMULATOR_UPDATE_HTMLWEBVIEW, data: { htmlId: e.htmlId, webviewID: e.webviewID, src: j } });
                        let k = /\#wechat_redirect$/.test(e.url);
                        if (k && e.url.replace(/\#wechat_redirect$/, '') === j) return j = j.replace(/\#wechat_redirect/, ''), void f({ type: a.INFO_SET_CONFIRM, data: { show: !0, showCancel: !1, content: d.config.CGI_ERR_OAUTH_NOT_SUPPORT } })
                    }).catch((b) => { f({ type: a.INFO_SET_CONFIRM, data: { show: !0, showCancel: !1, content: b } }) })
                }
            }
        }
    }(require('lazyload'), require);

    这样就大功告成啦!