Skip to content

Instantly share code, notes, and snippets.

@t4kemyh4nd
Created August 29, 2021 04:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save t4kemyh4nd/12603f7b7e1261d505c786cdef049b6f to your computer and use it in GitHub Desktop.
Save t4kemyh4nd/12603f7b7e1261d505c786cdef049b6f to your computer and use it in GitHub Desktop.
! function(a) {
"use strict";
var b, c = a.Base64,
d = "2.1.5";
"undefined" != typeof module && module.exports && (b = require("buffer").Buffer);
var e = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",
f = function(a) {
for (var b = {}, c = 0, d = a.length; d > c; c++) b[a.charAt(c)] = c;
return b
}(e),
g = String.fromCharCode,
h = function(a) {
if (a.length < 2) {
var b = a.charCodeAt(0);
return 128 > b ? a : 2048 > b ? g(192 | b >>> 6) + g(128 | 63 & b) : g(224 | b >>> 12 & 15) + g(128 | b >>> 6 & 63) + g(128 | 63 & b)
}
var b = 65536 + 1024 * (a.charCodeAt(0) - 55296) + (a.charCodeAt(1) - 56320);
return g(240 | b >>> 18 & 7) + g(128 | b >>> 12 & 63) + g(128 | b >>> 6 & 63) + g(128 | 63 & b)
},
i = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,
j = function(a) {
return a.replace(i, h)
},
k = function(a) {
var b = [0, 2, 1][a.length % 3],
c = a.charCodeAt(0) << 16 | (a.length > 1 ? a.charCodeAt(1) : 0) << 8 | (a.length > 2 ? a.charCodeAt(2) : 0),
d = [e.charAt(c >>> 18), e.charAt(c >>> 12 & 63), b >= 2 ? "=" : e.charAt(c >>> 6 & 63), b >= 1 ? "=" : e.charAt(63 & c)];
return d.join("")
},
l = a.btoa ? function(b) {
return a.btoa(b)
} : function(a) {
return a.replace(/[\s\S]{1,3}/g, k)
},
m = b ? function(a) {
return new b(a).toString("base64")
} : function(a) {
return l(j(a))
},
n = function(a, b) {
return b ? m(a).replace(/[+\/]/g, function(a) {
return "+" == a ? "-" : "_"
}).replace(/=/g, "") : m(a)
},
o = function(a) {
return n(a, !0)
},
p = new RegExp(["[À-ß][€-¿]", "[à-ï][€-¿]{2}", "[ð-÷][€-¿]{3}"].join("|"), "g"),
q = function(a) {
switch (a.length) {
case 4:
var b = (7 & a.charCodeAt(0)) << 18 | (63 & a.charCodeAt(1)) << 12 | (63 & a.charCodeAt(2)) << 6 | 63 & a.charCodeAt(3),
c = b - 65536;
return g((c >>> 10) + 55296) + g((1023 & c) + 56320);
case 3:
return g((15 & a.charCodeAt(0)) << 12 | (63 & a.charCodeAt(1)) << 6 | 63 & a.charCodeAt(2));
default:
return g((31 & a.charCodeAt(0)) << 6 | 63 & a.charCodeAt(1))
}
},
r = function(a) {
return a.replace(p, q)
},
s = function(a) {
var b = a.length,
c = b % 4,
d = (b > 0 ? f[a.charAt(0)] << 18 : 0) | (b > 1 ? f[a.charAt(1)] << 12 : 0) | (b > 2 ? f[a.charAt(2)] << 6 : 0) | (b > 3 ? f[a.charAt(3)] : 0),
e = [g(d >>> 16), g(d >>> 8 & 255), g(255 & d)];
return e.length -= [0, 0, 2, 1][c], e.join("")
},
t = a.atob ? function(b) {
return a.atob(b)
} : function(a) {
return a.replace(/[\s\S]{1,4}/g, s)
},
u = b ? function(a) {
return new b(a, "base64").toString()
} : function(a) {
return r(t(a))
},
v = function(a) {
return u(a.replace(/[-_]/g, function(a) {
return "-" == a ? "+" : "/"
}).replace(/[^A-Za-z0-9\+\/]/g, ""))
},
w = function() {
var b = a.Base64;
return a.Base64 = c, b
};
if (a.Base64 = {
VERSION: d,
atob: t,
btoa: l,
fromBase64: v,
toBase64: n,
utob: j,
encode: n,
encodeURI: o,
btou: r,
decode: v,
noConflict: w
}, "function" == typeof Object.defineProperty) {
var x = function(a) {
return {
value: a,
enumerable: !1,
writable: !0,
configurable: !0
}
};
a.Base64.extendString = function() {
Object.defineProperty(String.prototype, "fromBase64", x(function() {
return v(this)
})), Object.defineProperty(String.prototype, "toBase64", x(function(a) {
return n(this, a)
})), Object.defineProperty(String.prototype, "toBase64URI", x(function() {
return n(this, !0)
}))
}
}
}(this), this.Meteor && (Base64 = global.Base64),
function() {
"use strict";
var a, b, c = [],
d = 1e3,
e = {},
f = {},
g = {},
h = {},
i = {},
j = "migamecenter",
k = "__msg_type",
l = "__callback_id",
m = "__event_id",
n = "dispatch_message/",
o = function() {
return b = document.createElement("iframe"), b.id = "__miGCJsBridgeIframe_setResult", b.style.display = "none", document.documentElement.appendChild(b), a = document.createElement("iframe"), a.id = "__miGCJsBridgeIframe", a.style.display = "none", document.documentElement.appendChild(a), a
},
p = function(b) {
b && (c.push(b), a.src = j + "://" + n)
},
q = function() {
var a = JSON.stringify(c);
c = [], r("SCENE_FETCHQUEUE", a)
},
r = function(a, c) {
void 0 === c && (c = "none"), b.src = j + "://private/setresult/" + a + "&" + Base64.encode(c)
},
s = function(a, b, c, f) {
if (a && "string" == typeof a) {
"object" != typeof b && (b = {});
var g = (d++).toString();
"function" == typeof c && (e[g] = {
cb: c,
ctx: f || this || window.JsBridge
});
var h = {
func: a,
params: b
};
h[k] = "call", h[l] = g, p(h)
}
},
t = function(a) {
a && s("android.showLog", a)
},
u = function(a, b, c) {
a && "string" == typeof a && "function" == typeof b && (f[a] = {
cb: b,
ctx: c || this
})
},
v = function(a, b) {
var c = f[a];
"function" == typeof c.cb && c.cb.apply(c.ctx, [b])
},
w = function(a) {
if (a) {
var b, c, d, g = {};
switch (b = JSON.parse(Base64.decode(a)), b[k]) {
case "callback":
return c = e[b[l]], "string" == typeof b[l] && "function" == typeof c.cb ? (g.result = c.cb.call(c.ctx, b.__params), delete e[b[l]], void r("SCENE_HANDLEMSGFROMCLIENT", JSON.stringify(g))) : (g.__err_code = "cb404", void r("SCENE_HANDLEMSGFROMCLIENT", JSON.stringify(g)));
case "event":
return d = f[b[m]], "string" == typeof b[m] && "function" == typeof d.cb ? (g.result = d.cb.call(d.ctx, b.__params), void r("SCENE_HANDLEMSGFROMCLIENT", JSON.stringify(g))) : (g.__err_code = "cb404", void r("SCENE_HANDLEMSGFROMCLIENT", JSON.stringify(g)))
}
}
},
x = function(a) {
return i[a]
},
y = function() {
v("sys:init", {}), v("sys:bridged", {})
},
z = function() {
"onhashchange" in window && (window.onhashchange = function() {
s("hashChange", {
hash: window.location.hash
})
})
},
A = function(a, b, c) {
a && a.id && (g[a.id] = a, b && b.call(c || this))
},
B = function(a, b, c) {
a && (h = a, b && b.call(c || this))
},
C = function(a, b, c) {
a in g && (delete g[a], b && b.call(c || this))
},
D = function() {
return i
},
E = function() {
i && i.env && i.env.isDebug && F()
},
F = function() {},
G = function(a) {},
H = function() {
u("sys:init", function() {
window.JsBridge._hasInit || (window.JsBridge._hasInit = !0, s("get_session_data", {}, function(a) {
i = a, E();
var b = document.createEvent("Events");
b.initEvent("JsBridgeReady"), document.dispatchEvent(b)
}))
}), u("sys:bridged", function() {
window.JsBridge._hasInit || z()
}), u("download_loading", function(a) {
var b = a;
if (b && b.length)
for (var c, d, e = 0, f = b.length; f > e && (c = b[e], d = g[c.id], d); e++) {
var h = d.ctx || this;
switch (c.status) {
case "start":
d.start && d.start.call(h);
break;
case "pause":
d.pause && d.pause.call(h);
break;
case "wait":
d.wait && d.wait.call(h);
break;
case "download_complete":
d.downloadComplete && d.downloadComplete.call(h);
break;
case "install_complete":
d.installComplete && d.installComplete.call(h);
break;
case "downloading":
d.downloading && d.downloading.call(h, c.progress, c.current_bytes);
break;
case "remove":
d.remove && d.remove.call(h);
break;
case "fail":
d.fail && d.fail.call(h);
break;
default:
d.process && d.process.call(h)
}
}
}), u("uploading_media", function(a) {
var b;
b = h, b.cb && b.cb.call(this, a)
}), u("sys:refresh", function(a) {
s("get_session_data", {}, function(a) {
i = a;
var b = document.createEvent("Events");
b.initEvent("JsBridgeRefresh"), document.dispatchEvent(b)
})
}), u("sys:pause", function(a) {
var b = document.createEvent("Events");
b.initEvent("JsBridgePause"), document.dispatchEvent(b)
}), u("sys:resume", function(a) {
var b = document.createEvent("Events");
b.initEvent("JsBridgeResume"), document.dispatchEvent(b)
}), u("sys:abort", function(a) {
var b = document.createEvent("Events");
b.initEvent("JsBridgeAbort"), document.dispatchEvent(b)
}), u("sys:back", function(a) {
var b = document.createEvent("Events");
b.initEvent("JsBridgeBack"), document.dispatchEvent(b)
}), u("sys:position", function(a) {
s("get_session_data", {}, function(a) {
i = a;
var b = document.createEvent("Events");
b.initEvent("JsBridgePosition"), document.dispatchEvent(b)
})
})
};
window.JsBridge = window.JsBridge || function() {
return o(), H(), {
version: "1.0.1",
invoke: s,
on: u,
env: x,
debugTime: G,
pushItemInDLMap: A,
shiftItemFrDLMap: C,
pushItemInULMap: B,
log: t,
_init: y,
_fetchQueue: q,
_handleMessageFromClient: w,
getSessionData: D,
_hasInit: !1
}
}()
}(),
function() {
var a = window.clientApi = {},
b = function(a) {
var b = typeof a;
if (!("function" === b || "object" === b && a)) return a;
for (var c, d, e = 0, f = arguments.length; f > e; e++) {
c = arguments[e];
for (d in c) hasOwnProperty.call(c, d) && (a[d] = c[d])
}
return a
};
a.showToolBar = function() {
JsBridge.invoke("showToolBar")
}, a.hideToolBar = function() {
JsBridge.invoke("hideToolBar")
}, a.copy = function(a, b) {
if (a && "string" == typeof a) {
var c = {
txt: a
};
JsBridge.invoke("copy", c, b)
}
}, a.openBrowser = function(a) {
var b = {
url: a || window.location.href
};
JsBridge.invoke("openInBrowser", b)
}, a.enableDebugMode = function(a) {
window.onerror = function(b, c, d, e) {
if ("function" == typeof a) return void a({
message: b,
script: c,
line: d,
column: e
});
var f = [];
f.push("额,代码有错。。。"), f.push("\n错误信息:", b), f.push("\n出错文件:", c), f.push("\n出错位置:", d + "行," + e + "列"), alert(f.join(""))
}
}, a.download = function(a, b, c) {
JsBridge.pushItemInDLMap({
id: a.gameId,
start: a.start,
pause: a.pause,
wait: a.wait,
downloading: a.downloading,
downloadComplete: a.downloadComplete,
installComplete: a.installComplete,
remove: a.remove,
fail: a.fail,
ctx: a.ctx,
channel: a.channel,
from: a.from,
trace: a.trace,
type: a.type
}, function() {
JsBridge.invoke("download_start", {
id: a.gameId,
packageName: a.packageName,
channel: a.channel,
from: a.from,
trace: a.trace,
type: a.type
}, b, c)
})
}, a.pushItemInDownLoadMap = function(a, b, c) {
JsBridge.pushItemInDLMap({
id: a.gameId,
start: a.start,
pause: a.pause,
wait: a.wait,
downloading: a.downloading,
downloadComplete: a.downloadComplete,
installComplete: a.installComplete,
remove: a.remove,
fail: a.fail,
ctx: a.ctx,
channel: a.channel
}, b, c)
}, a.downloadPause = function(a, b, c) {
JsBridge.invoke("download_pause", {
id: a.gameId,
channel: a.channel
}, function(a) {
b && b.call(c)
}, c)
}, a.downloadContinue = function(a, b, c) {
JsBridge.invoke("download_continue", {
id: a.gameId,
channel: a.channel
}, function(a) {
b && b.call(c)
}, c)
}, a.downloadInstall = function(a, b, c) {
JsBridge.invoke("download_install", {
id: a.gameId,
channel: a.channel
}, function(d) {
JsBridge.shiftItemFrDLMap(a.gameId), b && b.call(c)
}, c)
}, a.openGame = function(a, b, c) {
JsBridge.invoke("open_game", {
id: a.gameId,
packageName: a.packageName,
channel: a.channel
}, function(a) {}, c)
}, a.initPageByNativeData = function(a, b, c) {
JsBridge.invoke("init_web", {
gameList: a.gameList
}, function(a) {
b && b.call(c, a)
}, c)
}, a.initPageByClientData = function(a, b, c, d) {
JsBridge.invoke("init_web_by_type", {
type: a,
param: b
}, function(a) {
c && c.call(d, a)
}, d)
};
var c = function(a) {
var b = !1,
c = function(c) {
b || (b = !0, a(c))
},
d = document.getElementsByTagName("img");
if (!d.length) return c();
var e, f, g, h, i = {},
j = !1;
for (f = 0, g = d.length; g > f; f++) e = d[f], "none" != e.style.display && "hidden" != e.style.visibility && (i[e.src] || (i[e.src] = 1, h = new Image, h.onload = function() {
j || this.width > 290 && this.height > 290 && (j = !0, c(this))
}, h.src = e.src));
i = null, setTimeout(function() {
j || c()
}, 1e3)
};
a.videoPlay = function(a, b, c) {
JsBridge.invoke("video_play", {
url: a,
title: b
}, c)
}, a.showMenu = function(a) {
JsBridge.on("menu:show", function(b) {
a && a(b)
})
}, a.share = function(a) {
var b;
if (b = "string" == typeof a.title ? a : {
link: document.documentURI,
desc: document.documentURI,
title: document.title
}, a.imgUrl) return b.img_url = a.imgUrl, void JsBridge.invoke("share", b);
var d = function(a) {
a && (b.img_url = a.src), JsBridge.invoke("share", b)
};
c(d)
}, a.inputTxtByNative = function(a, b) {
JsBridge.invoke("submit_input_txt", {
content: a
}, b)
}, a.nativeRequest = function(a, b) {
if ("" !== a.url && "" !== a.type) {
var c = {
url: a.url,
param: a.param || {},
http_method: a.http_method || "get",
secertKey: a.secertKey || "",
type: a.type
};
JsBridge.invoke("native_request", c, b)
}
}, a.showDialog = function(a, c) {
var d = {
type: "show:txt",
title: "",
content: "",
isLazyClose: !1,
lazyTime: 0,
isShowCancelBtn: !1,
cancelBtnTxt: "取消",
isShowOkBtn: !1,
okBtnTxt: "确定"
},
e = function(a) {
if (a && a.operat) switch (a.operat) {
case "ok":
c.ok && c.ok(a.content);
break;
case "cancel":
c.cancel && c.cancel(a.content)
}
};
d = b(d, a), "submit" == d.type && (d.isLazyClose = !1), JsBridge.invoke("show_dialog", d, e)
}, a.preventSwipeBack = function(a, b) {
a = a || {
prevent: !0
}, b = b || function() {}, JsBridge.invoke("prevent_swipe_back", a, b)
}, a.clientLog = function(a) {
JsBridge.invoke("client_log", {
info: a
})
}, a.reinstate = function(a, b, c) {
switch (a *= 1) {
case 1:
JsBridge.invoke("service_token_invalidate", {
tagurl: b,
param: c
});
break;
case 2:
JsBridge.invoke("login_invalidate", {
tagurl: b,
param: c
})
}
}, a.historyNotRecords = function(a) {
JsBridge.invoke("history_not_records", {}, a)
}, a.historyJumpOutWebview = function(a) {
JsBridge.invoke("history_jumpout_webview", {}, a)
}, a.goBack = function(a) {
JsBridge.invoke("web_go_back", {}, a)
}, a.viewImgList = function(a, b) {
var c = {
screenShot: a.screenShot || [],
curIndex: a.curIndex || 0
};
c.screenShot.length && JsBridge.invoke("view_img_list", c, b)
}, a.getBaseDataFromClient = function(a, b) {
var c = {
type: a
};
JsBridge.invoke("get_basedata_by_type", c, b)
}, a.notifyLoadingOver = function(a) {
JsBridge.invoke("client_loading_over", {}, a)
}, a.getSessionData = function() {
return JsBridge.getSessionData()
}, a.commentTxtByNative = function(a, b) {
var c = {
news_id: a
};
JsBridge.invoke("client_comment_txt", c, b)
}, a.h5GameLogin = function(a, b) {
return a ? a.appId ? a.appKey ? void JsBridge.invoke("h5_game_login", a, b) : void(b && b({
result: -102,
errorMessage: "appKey is null"
})) : void(b && b({
result: -101,
errorMessage: "appId is null"
})) : void(b && b({
result: -100,
errorMessage: "options is null"
}))
}, a.h5GamePay = function(a, b) {
return a ? (a.cpOrderId || b && b({
result: -104,
errorMessage: "cpOrderId is null"
}), a.cpUserInfo || b && b({
result: -105,
errorMessage: "cpUserInfo is null"
}), void JsBridge.invoke("h5_game_pay", a, b)) : void(b && b({
result: -103,
errorMessage: "options is null"
}))
}, a.executeClientMethod = function(a, b, c, d) {
JsBridge.invoke("client_method_execute", {
method: a,
param: b
}, function(a) {
c && c.call(d, a)
}, d)
}, a.showImgFromNative = function(a, b, c) {
var d = {
imgList: a,
index: b
};
JsBridge.invoke("show_img_list", d, c)
}, a.jumpMiBiRechargeList = function(a, b) {
JsBridge.invoke("jumpMiBiRechargeList", a, b)
}, a.saveDataToNative = function(a, b, c) {
var d = {};
d[a] = b, JsBridge.invoke("saveDataToNative", d, c)
}, a.showErrorTip = function() {
JsBridge.invoke("showErrorTip")
}, a.getBatteryByNative = function(a, b) {
JsBridge.invoke("battery_by_native", {}, function(c) {
a && a.call(b, c)
}, b)
}, a.dimmingByScreen = function(a, b, c) {
JsBridge.invoke("dimming_by_screen", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}, a.checkGameStatus = function(a, b, c, d) {
JsBridge.invoke("check_game_status", {
method: a,
param: b
}, function(a) {
c && c.call(d, a)
}, d)
}, a.sendStatistic = function(a, b, c) {
JsBridge.invoke("send_statistic", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}, a.changeNavigationBar = function(a, b, c) {
JsBridge.invoke("change_navigation_bar", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}, a.finishActivity = function() {
JsBridge.invoke("finish_activity")
}, a.showNativeDialog = function(a, b, c) {
JsBridge.invoke("show_native_dialog", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}, a.notifyBackKey = function() {
JsBridge.invoke("notify_back_key")
}, a.closeBackKey = function() {
JsBridge.invoke("close_back_key")
}, a.getNativeNotify = function(a, b, c) {
JsBridge.invoke("get_native_notify", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}, a.logoutByNative = function(a, b) {
JsBridge.invoke("logout_by_native", {}, function(c) {
a && a.call(b, c)
}, b)
}, a.cacheByNative = function(a, b, c) {
JsBridge.invoke("cache_data_by_native", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}, a.setDataToNative = function(a, b, c) {
JsBridge.invoke("set_data_to_native", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}, a.playVideoAd = function(a, b, c) {
JsBridge.invoke("play_video_ad", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}, a.getGameUpdateByNative = function(a, b, c) {
JsBridge.invoke("game_list_update", {
gameList: a.gameList
}, function(a) {
b && b.call(c, a)
}, c)
}, a.uploadMedia = function(a, b, c) {
JsBridge.pushItemInULMap({
cb: a.download
}, function() {
JsBridge.invoke("upload_media", {}, b, c)
})
}, a.playVideoAd = function(a, b, c) {
JsBridge.invoke("play_video_ad", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}, a.notifyNativeMsg = function(a, b, c) {
JsBridge.invoke("notify_native_msg", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}, a.getNativeAppInfo = function(a, b, c) {
JsBridge.invoke("query_package_status", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}, a.addShortcut = function(a, b, c) {
JsBridge.invoke("add_shortcut", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}, a.removeShortcut = function(a, b, c) {
JsBridge.invoke("remove_shortcut", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}, a.updateShortcut = function(a, b, c) {
JsBridge.invoke("update_shortcut", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}, a.isShortcutExist = function(a, b, c) {
JsBridge.invoke("is_shortcut_exist", {
param: a
}, function(a) {
b && b.call(c, a)
}, c)
}
}(); // This is just a sample script. Paste your real code (javascript or HTML) here.
if ('this_is' == /an_example/) {
of_beautifier();
} else {
var a = b ? (c % d) : e[f];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment