2016-08-03 13:15:04 +00:00
|
|
|
(function () {
|
2018-07-18 13:48:08 +00:00
|
|
|
function bridgeSend(data){
|
|
|
|
WebViewBridge.send(JSON.stringify(data));
|
|
|
|
}
|
|
|
|
|
2018-07-06 19:47:59 +00:00
|
|
|
var history = window.history;
|
|
|
|
var pushState = history.pushState;
|
|
|
|
history.pushState = function(state) {
|
|
|
|
setTimeout(function () {
|
2018-07-18 13:48:08 +00:00
|
|
|
bridgeSend({
|
|
|
|
type: 'history-state-changed',
|
|
|
|
navState: { url: location.href, title: document.title }
|
|
|
|
});
|
2018-07-06 19:47:59 +00:00
|
|
|
}, 100);
|
|
|
|
return pushState.apply(history, arguments);
|
|
|
|
};
|
2016-08-03 13:15:04 +00:00
|
|
|
|
2018-07-18 13:48:08 +00:00
|
|
|
window.addEventListener('message', function (event) {
|
|
|
|
if (!event.data || !event.data.type) { return; }
|
|
|
|
if (event.data.type === 'STATUS_API_REQUEST') {
|
|
|
|
bridgeSend({
|
|
|
|
type: 'status-api-request',
|
|
|
|
permissions: event.data.permissions,
|
|
|
|
host: window.location.hostname
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2016-08-03 13:15:04 +00:00
|
|
|
}());
|