mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 02:24:05 +09:00
Added JoiseDoc
This commit is contained in:
29
work_files/JoiseDoc/Modules_files/webrtc-patch.js
Normal file
29
work_files/JoiseDoc/Modules_files/webrtc-patch.js
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
window.addEventListener('message', function (e) {
|
||||
if (e.origin !== window.location.origin) {
|
||||
return;
|
||||
}
|
||||
if (e.data.to !== 'content') {
|
||||
return;
|
||||
}
|
||||
if (e.data.type === 'webrtc-reload') {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
(function modifyWebRTC(apis) {
|
||||
apis.forEach(function (api) {
|
||||
if (!(api && api.prototype.createOffer)) {
|
||||
return;
|
||||
}
|
||||
var createOffer = api.prototype.createOffer;
|
||||
api.prototype.createOffer = function () {
|
||||
window.postMessage({
|
||||
type: 'webrtc-call',
|
||||
to: 'background'
|
||||
}, window.location.origin);
|
||||
return createOffer.apply(this, [].slice.call(arguments));
|
||||
};
|
||||
});
|
||||
})([window.RTCPeerConnection, window.webkitRTCPeerConnection, window.mozRTCPeerConnection, window.msRTCPeerConnection]);
|
||||
Reference in New Issue
Block a user